src/share/classes/java/lang/Class.java

Print this page
rev 7916 : 8022343: j.l.Class.getAnnotatedSuperclass() doesn't return null in some cases
Reviewed-by: darcy, vromero, psandoz


3321      * Maintained by the ClassValue class.
3322      */
3323     transient ClassValue.ClassValueMap classValueMap;
3324 
3325     /**
3326      * Returns an AnnotatedType object that represents the use of a type to specify
3327      * the superclass of the entity represented by this Class. (The <em>use</em> of type
3328      * Foo to specify the superclass in '... extends Foo' is distinct from the
3329      * <em>declaration</em> of type Foo.)
3330      *
3331      * If this Class represents a class type whose declaration does not explicitly
3332      * indicate an annotated superclass, the return value is null.
3333      *
3334      * If this Class represents either the Object class, an interface type, an
3335      * array type, a primitive type, or void, the return value is null.
3336      *
3337      * @return an object representing the superclass
3338      * @since 1.8
3339      */
3340     public AnnotatedType getAnnotatedSuperclass() {








3341          return TypeAnnotationParser.buildAnnotatedSuperclass(getRawTypeAnnotations(), getConstantPool(), this);
3342 }
3343 
3344     /**
3345      * Returns an array of AnnotatedType objects that represent the use of types to
3346      * specify superinterfaces of the entity represented by this Class. (The <em>use</em>
3347      * of type Foo to specify a superinterface in '... implements Foo' is
3348      * distinct from the <em>declaration</em> of type Foo.)
3349      *
3350      * If this Class represents a class, the return value is an array
3351      * containing objects representing the uses of interface types to specify
3352      * interfaces implemented by the class. The order of the objects in the
3353      * array corresponds to the order of the interface types used in the
3354      * 'implements' clause of the declaration of this Class.
3355      *
3356      * If this Class represents an interface, the return value is an array
3357      * containing objects representing the uses of interface types to specify
3358      * interfaces directly extended by the interface. The order of the objects in
3359      * the array corresponds to the order of the interface types used in the
3360      * 'extends' clause of the declaration of this Class.
3361      *
3362      * If this Class represents a class or interface whose declaration does not


3321      * Maintained by the ClassValue class.
3322      */
3323     transient ClassValue.ClassValueMap classValueMap;
3324 
3325     /**
3326      * Returns an AnnotatedType object that represents the use of a type to specify
3327      * the superclass of the entity represented by this Class. (The <em>use</em> of type
3328      * Foo to specify the superclass in '... extends Foo' is distinct from the
3329      * <em>declaration</em> of type Foo.)
3330      *
3331      * If this Class represents a class type whose declaration does not explicitly
3332      * indicate an annotated superclass, the return value is null.
3333      *
3334      * If this Class represents either the Object class, an interface type, an
3335      * array type, a primitive type, or void, the return value is null.
3336      *
3337      * @return an object representing the superclass
3338      * @since 1.8
3339      */
3340     public AnnotatedType getAnnotatedSuperclass() {
3341         if (this == Object.class ||
3342                 isInterface() ||
3343                 isArray() ||
3344                 isPrimitive() ||
3345                 this == Void.TYPE) {
3346             return null;
3347         }
3348 
3349         return TypeAnnotationParser.buildAnnotatedSuperclass(getRawTypeAnnotations(), getConstantPool(), this);
3350     }
3351 
3352     /**
3353      * Returns an array of AnnotatedType objects that represent the use of types to
3354      * specify superinterfaces of the entity represented by this Class. (The <em>use</em>
3355      * of type Foo to specify a superinterface in '... implements Foo' is
3356      * distinct from the <em>declaration</em> of type Foo.)
3357      *
3358      * If this Class represents a class, the return value is an array
3359      * containing objects representing the uses of interface types to specify
3360      * interfaces implemented by the class. The order of the objects in the
3361      * array corresponds to the order of the interface types used in the
3362      * 'implements' clause of the declaration of this Class.
3363      *
3364      * If this Class represents an interface, the return value is an array
3365      * containing objects representing the uses of interface types to specify
3366      * interfaces directly extended by the interface. The order of the objects in
3367      * the array corresponds to the order of the interface types used in the
3368      * 'extends' clause of the declaration of this Class.
3369      *
3370      * If this Class represents a class or interface whose declaration does not