|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
java.lang.Class.getAnnotation() is currently implemented with a cache:
public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
if (annotationClass == null)
throw new NullPointerException();
initAnnotationsIfNecessary();
return (A) annotations.get(annotationClass);
}
<snip>
private synchronized void initAnnotationsIfNecessary() {
if (annotations != null)
return;
declaredAnnotations = AnnotationParser.parseAnnotations(
getRawAnnotations(), getConstantPool(), this);
Class<?> superClass = getSuperclass();
if (superClass == null) {
annotations = declaredAnnotations;
} else {
annotations = new HashMap<Class, Annotation>();
superClass.initAnnotationsIfNecessary();
for (Map.Entry<Class, Annotation> e : superClass.annotations.entrySet()) {
Class annotationClass = e.getKey();
if (AnnotationType.getInstance(annotationClass).isInherited())
annotations.put(annotationClass, e.getValue());
}
annotations.putAll(declaredAnnotations);
}
}
This cache means that getRawAnnotations() is only called once
which doesn't interact well with JVM/TI RedefineClasses(). If
a set of annotations is modified by RedefineClasses(), then
the VM will return the modified annotation (once 5002251 is
fixed), but the Java layer will never present the modified
annotations to the caller.
|