< prev index next >

src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReferenceType.java

Print this page


   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.bcel.internal.generic;
  23 


 245 
 246     // Huh? Did you ask for Type.OBJECT's superclass??
 247     return null;
 248   }
 249 
 250   /**
 251    * This commutative operation returns the first common superclass (narrowest ReferenceType
 252    * referencing a class, not an interface).
 253    * If one of the types is a superclass of the other, the former is returned.
 254    * If "this" is Type.NULL, then t is returned.
 255    * If t is Type.NULL, then "this" is returned.
 256    * If "this" equals t ['this.equals(t)'] "this" is returned.
 257    * If "this" or t is an ArrayType, then Type.OBJECT is returned.
 258    * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
 259    * If not all of the two classes' superclasses cannot be found, "null" is returned.
 260    * See the JVM specification edition 2, "4.9.2 The Bytecode Verifier".
 261    *
 262    * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has
 263    *             slightly changed semantics.
 264    */

 265   public ReferenceType firstCommonSuperclass(ReferenceType t) {
 266     if (this.equals(Type.NULL)) return t;
 267     if (t.equals(Type.NULL)) return this;
 268     if (this.equals(t)) return this;
 269     /*
 270      * TODO: Above sounds a little arbitrary. On the other hand, there is
 271      * no object referenced by Type.NULL so we can also say all the objects
 272      * referenced by Type.NULL were derived from java.lang.Object.
 273      * However, the Java Language's "instanceof" operator proves us wrong:
 274      * "null" is not referring to an instance of java.lang.Object :)
 275      */
 276 
 277     if ((this instanceof ArrayType) || (t instanceof ArrayType))
 278       return Type.OBJECT;
 279     // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
 280 
 281     if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface()) ||
 282         ((t instanceof ObjectType) && ((ObjectType) t).referencesInterface()))
 283       return Type.OBJECT;
 284     // TODO: The above line is correct comparing to the vmspec2. But one could


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.

   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.bcel.internal.generic;
  22 


 244 
 245     // Huh? Did you ask for Type.OBJECT's superclass??
 246     return null;
 247   }
 248 
 249   /**
 250    * This commutative operation returns the first common superclass (narrowest ReferenceType
 251    * referencing a class, not an interface).
 252    * If one of the types is a superclass of the other, the former is returned.
 253    * If "this" is Type.NULL, then t is returned.
 254    * If t is Type.NULL, then "this" is returned.
 255    * If "this" equals t ['this.equals(t)'] "this" is returned.
 256    * If "this" or t is an ArrayType, then Type.OBJECT is returned.
 257    * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
 258    * If not all of the two classes' superclasses cannot be found, "null" is returned.
 259    * See the JVM specification edition 2, "4.9.2 The Bytecode Verifier".
 260    *
 261    * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has
 262    *             slightly changed semantics.
 263    */
 264   @Deprecated
 265   public ReferenceType firstCommonSuperclass(ReferenceType t) {
 266     if (this.equals(Type.NULL)) return t;
 267     if (t.equals(Type.NULL)) return this;
 268     if (this.equals(t)) return this;
 269     /*
 270      * TODO: Above sounds a little arbitrary. On the other hand, there is
 271      * no object referenced by Type.NULL so we can also say all the objects
 272      * referenced by Type.NULL were derived from java.lang.Object.
 273      * However, the Java Language's "instanceof" operator proves us wrong:
 274      * "null" is not referring to an instance of java.lang.Object :)
 275      */
 276 
 277     if ((this instanceof ArrayType) || (t instanceof ArrayType))
 278       return Type.OBJECT;
 279     // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
 280 
 281     if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface()) ||
 282         ((t instanceof ObjectType) && ((ObjectType) t).referencesInterface()))
 283       return Type.OBJECT;
 284     // TODO: The above line is correct comparing to the vmspec2. But one could


< prev index next >