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
*** 3336,3347 ****
*
* @return an object representing the superclass
* @since 1.8
*/
public AnnotatedType getAnnotatedSuperclass() {
return TypeAnnotationParser.buildAnnotatedSuperclass(getRawTypeAnnotations(), getConstantPool(), this);
! }
/**
* Returns an array of AnnotatedType objects that represent the use of types to
* specify superinterfaces of the entity represented by this Class. (The <em>use</em>
* of type Foo to specify a superinterface in '... implements Foo' is
--- 3336,3355 ----
*
* @return an object representing the superclass
* @since 1.8
*/
public AnnotatedType getAnnotatedSuperclass() {
+ if (this == Object.class ||
+ isInterface() ||
+ isArray() ||
+ isPrimitive() ||
+ this == Void.TYPE) {
+ return null;
+ }
+
return TypeAnnotationParser.buildAnnotatedSuperclass(getRawTypeAnnotations(), getConstantPool(), this);
! }
/**
* Returns an array of AnnotatedType objects that represent the use of types to
* specify superinterfaces of the entity represented by this Class. (The <em>use</em>
* of type Foo to specify a superinterface in '... implements Foo' is