ClassMetadata exposes isAnnotation() now, and correctly returns false from hasSuperClass() for interfaces and annotations
Issue: SPR-11711
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,6 +38,12 @@ public interface ClassMetadata {
|
||||
*/
|
||||
boolean isInterface();
|
||||
|
||||
/**
|
||||
* Return whether the underlying class represents an annotation.
|
||||
* @since 4.1
|
||||
*/
|
||||
boolean isAnnotation();
|
||||
|
||||
/**
|
||||
* Return whether the underlying class is marked as abstract.
|
||||
*/
|
||||
@@ -100,6 +106,7 @@ public interface ClassMetadata {
|
||||
* access, and private classes and interfaces declared by the class, but excludes
|
||||
* inherited classes and interfaces. An empty array is returned if no member classes
|
||||
* or interfaces exist.
|
||||
* @since 3.1
|
||||
*/
|
||||
String[] getMemberClassNames();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,6 +60,11 @@ public class StandardClassMetadata implements ClassMetadata {
|
||||
return this.introspectedClass.isInterface();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnnotation() {
|
||||
return this.introspectedClass.isAnnotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstract() {
|
||||
return Modifier.isAbstract(this.introspectedClass.getModifiers());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,6 +47,8 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata
|
||||
|
||||
private boolean isInterface;
|
||||
|
||||
private boolean isAnnotation;
|
||||
|
||||
private boolean isAbstract;
|
||||
|
||||
private boolean isFinal;
|
||||
@@ -71,9 +73,10 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata
|
||||
public void visit(int version, int access, String name, String signature, String supername, String[] interfaces) {
|
||||
this.className = ClassUtils.convertResourcePathToClassName(name);
|
||||
this.isInterface = ((access & Opcodes.ACC_INTERFACE) != 0);
|
||||
this.isAnnotation = ((access & Opcodes.ACC_ANNOTATION) != 0);
|
||||
this.isAbstract = ((access & Opcodes.ACC_ABSTRACT) != 0);
|
||||
this.isFinal = ((access & Opcodes.ACC_FINAL) != 0);
|
||||
if (supername != null) {
|
||||
if (supername != null && !this.isInterface) {
|
||||
this.superClassName = ClassUtils.convertResourcePathToClassName(supername);
|
||||
}
|
||||
this.interfaces = new String[interfaces.length];
|
||||
@@ -146,6 +149,11 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata
|
||||
return this.isInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnnotation() {
|
||||
return this.isAnnotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstract() {
|
||||
return this.isAbstract;
|
||||
|
||||
Reference in New Issue
Block a user