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

Print this page

        

*** 706,717 **** * <cite>The Java&trade; Virtual Machine Specification</cite> * @since 1.5 */ @SuppressWarnings("unchecked") public TypeVariable<Class<T>>[] getTypeParameters() { ! if (getGenericSignature() != null) ! return (TypeVariable<Class<T>>[])getGenericInfo().getTypeParameters(); else return (TypeVariable<Class<T>>[])new TypeVariable<?>[0]; } --- 706,718 ---- * <cite>The Java&trade; Virtual Machine Specification</cite> * @since 1.5 */ @SuppressWarnings("unchecked") public TypeVariable<Class<T>>[] getTypeParameters() { ! ClassRepository info = getGenericInfo(); ! if (info != null) ! return (TypeVariable<Class<T>>[])info.getTypeParameters(); else return (TypeVariable<Class<T>>[])new TypeVariable<?>[0]; }
*** 757,775 **** * instantiated for any reason * @return the superclass of the class represented by this object * @since 1.5 */ public Type getGenericSuperclass() { ! if (getGenericSignature() != null) { // Historical irregularity: // Generic signature marks interfaces with superclass = Object // but this API returns null for interfaces ! if (isInterface()) return null; ! return getGenericInfo().getSuperclass(); ! } else ! return getSuperclass(); } /** * Gets the package for this class. The class loader of this class is used * to find the package. If the class was loaded by the bootstrap class --- 758,780 ---- * instantiated for any reason * @return the superclass of the class represented by this object * @since 1.5 */ public Type getGenericSuperclass() { ! ClassRepository info = getGenericInfo(); ! if (info == null) { ! return getSuperclass(); ! } ! // Historical irregularity: // Generic signature marks interfaces with superclass = Object // but this API returns null for interfaces ! if (isInterface()) { return null; ! } ! ! return info.getSuperclass(); } /** * Gets the package for this class. The class loader of this class is used * to find the package. If the class was loaded by the bootstrap class
*** 828,838 **** * <p> If this object represents a primitive type or void, the method * returns an array of length 0. * * @return an array of interfaces implemented by this class. */ ! public native Class<?>[] getInterfaces(); /** * Returns the {@code Type}s representing the interfaces * directly implemented by the class or interface represented by * this object. --- 833,857 ---- * <p> If this object represents a primitive type or void, the method * returns an array of length 0. * * @return an array of interfaces implemented by this class. */ ! public Class<?>[] getInterfaces() { ! ReflectionData<T> rd = reflectionData(); ! if (rd == null) { ! // no cloning required ! return getInterfaces0(); ! } else { ! if (rd.interfaces == null) { ! rd.interfaces = getInterfaces0(); ! } ! // defensively copy before handing over to user code ! return rd.interfaces.clone(); ! } ! } ! ! private native Class<?>[] getInterfaces0(); /** * Returns the {@code Type}s representing the interfaces * directly implemented by the class or interface represented by * this object.
*** 880,893 **** * type that cannot be instantiated for any reason * @return an array of interfaces implemented by this class * @since 1.5 */ public Type[] getGenericInterfaces() { ! if (getGenericSignature() != null) ! return getGenericInfo().getSuperInterfaces(); ! else ! return getInterfaces(); } /** * Returns the {@code Class} representing the component type of an --- 899,910 ---- * type that cannot be instantiated for any reason * @return an array of interfaces implemented by this class * @since 1.5 */ public Type[] getGenericInterfaces() { ! ClassRepository info = getGenericInfo(); ! return (info == null) ? getInterfaces() : info.getSuperInterfaces(); } /** * Returns the {@code Class} representing the component type of an
*** 2311,2320 **** --- 2328,2339 ---- volatile Constructor<T>[] declaredConstructors; volatile Constructor<T>[] publicConstructors; // Intermediate results for getFields and getMethods volatile Field[] declaredPublicFields; volatile Method[] declaredPublicMethods; + volatile Class<?>[] interfaces; + // Value of classRedefinedCount when we created this ReflectionData instance final int redefinedCount; ReflectionData(int redefinedCount) { this.redefinedCount = redefinedCount;
*** 2386,2415 **** } } } // Generic signature handling ! private native String getGenericSignature(); // Generic info repository; lazily initialized ! private transient ClassRepository genericInfo; // accessor for factory private GenericsFactory getFactory() { // create scope and factory return CoreReflectionFactory.make(this, ClassScope.make(this)); } ! // accessor for generic info repository private ClassRepository getGenericInfo() { ! // lazily initialize repository if necessary if (genericInfo == null) { ! // create and cache generic info repository ! genericInfo = ClassRepository.make(getGenericSignature(), ! getFactory()); } ! return genericInfo; //return cached repository } // Annotations handling private native byte[] getRawAnnotations(); // Since 1.8 --- 2405,2439 ---- } } } // Generic signature handling ! private native String getGenericSignature0(); // Generic info repository; lazily initialized ! private volatile transient ClassRepository genericInfo; // accessor for factory private GenericsFactory getFactory() { // create scope and factory return CoreReflectionFactory.make(this, ClassScope.make(this)); } ! // accessor for generic info repository; ! // generic info is lazily initialized private ClassRepository getGenericInfo() { ! ClassRepository genericInfo = this.genericInfo; if (genericInfo == null) { ! String signature = getGenericSignature0(); ! if (signature == null) { ! genericInfo = ClassRepository.NONE; ! } else { ! genericInfo = ClassRepository.make(signature, getFactory()); ! } ! this.genericInfo = genericInfo; } ! return (genericInfo != ClassRepository.NONE) ? genericInfo : null; } // Annotations handling private native byte[] getRawAnnotations(); // Since 1.8