< prev index next >

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

Print this page

        

*** 65,76 **** --- 65,78 ---- import sun.reflect.generics.repository.ClassRepository; import sun.reflect.generics.repository.MethodRepository; import sun.reflect.generics.repository.ConstructorRepository; import sun.reflect.generics.scope.ClassScope; import sun.security.util.SecurityConstants; + import java.lang.annotation.Annotation; import java.lang.reflect.Proxy; + import sun.reflect.annotation.*; import sun.reflect.misc.ReflectUtil; /** * Instances of the class {@code Class} represent classes and
*** 2420,2437 **** --- 2422,2442 ---- // initialize Unsafe machinery here, since we need to call Class.class instance method // and have to avoid calling it in the static initializer of the Class class... private static final Unsafe unsafe = Unsafe.getUnsafe(); // offset of Class.reflectionData instance field private static final long reflectionDataOffset; + // offset of Class.classData instance field + private static final long classDataOffset; // offset of Class.annotationType instance field private static final long annotationTypeOffset; // offset of Class.annotationData instance field private static final long annotationDataOffset; static { Field[] fields = Class.class.getDeclaredFields0(false); // bypass caches reflectionDataOffset = objectFieldOffset(fields, "reflectionData"); + classDataOffset = objectFieldOffset(fields, "classData"); annotationTypeOffset = objectFieldOffset(fields, "annotationType"); annotationDataOffset = objectFieldOffset(fields, "annotationData"); } private static long objectFieldOffset(Field[] fields, String fieldName) {
*** 2446,2455 **** --- 2451,2466 ---- SoftReference<ReflectionData<T>> oldData, SoftReference<ReflectionData<T>> newData) { return unsafe.compareAndSwapObject(clazz, reflectionDataOffset, oldData, newData); } + static <T> boolean casClassData(Class<?> clazz, + Object oldData, + Object newData) { + return unsafe.compareAndSwapObject(clazz, classDataOffset, oldData, newData); + } + static <T> boolean casAnnotationType(Class<?> clazz, AnnotationType oldType, AnnotationType newType) { return unsafe.compareAndSwapObject(clazz, annotationTypeOffset, oldType, newType); }
*** 2459,2468 **** --- 2470,2493 ---- AnnotationData newData) { return unsafe.compareAndSwapObject(clazz, annotationDataOffset, oldData, newData); } } + private volatile transient Object classData; + + /* package */ Object classData() { + return this.classData; + } + + /* package */ boolean casClassData(Object oldData, Object newData) { + return Atomic.casClassData(this, oldData, newData); + } + + /* package */ int classRedefinedCount() { + return classRedefinedCount; + } + /** * Reflection support. */ // Caches for certain reflective results
< prev index next >