Lines Matching defs:Class

86  * Instances of the class {@code Class} represent classes and
89 * belongs to a class that is reflected as a {@code Class} object
95 * represented as {@code Class} objects.
97 * <p> {@code Class} has no public constructor. Instead {@code Class}
102 * <p> The following example uses a {@code Class} object to print the
112 * <p> It is also possible to get the {@code Class} object for a named
121 * @param <T> the type of the class modeled by this {@code Class}
123 * Class<String>}. Use {@code Class<?>} if the class being modeled is
130 public final class Class<T> implements java.io.Serializable,
144 * Private constructor. Only the Java Virtual Machine creates Class objects.
148 private Class(ClassLoader loader, Class<?> arrayComponentType) {
159 * {@code getName}. If this {@code Class} object represents a
161 * this {@code Class} object represents void this method returns
162 * "void". If this {@code Class} object represents an array type,
173 * Returns a string describing this {@code Class}, including
199 * @return a string describing this {@code Class}, including
209 Class<?> component = this;
219 // Class modifiers are a superset of interface modifiers
258 * Returns the {@code Class} object associated with the class or
263 * {@code Class.forName(className, true, currentLoader)}
270 * runtime {@code Class} descriptor for the class named
274 * {@code Class t = Class.forName("java.lang.Thread")}
281 * @return the {@code Class} object for the class with the
289 public static Class<?> forName(String className)
291 Class<?> caller = Reflection.getCallerClass();
297 * Returns the {@code Class} object associated with the class or
311 * obtain any of the {@code Class} objects representing primitive
320 * {@code Class.forName("Foo")}
326 * {@code Class.forName("Foo", true, this.getClass().getClassLoader())}
352 * @see java.lang.Class#forName(String)
357 public static Class<?> forName(String name, boolean initialize,
361 Class<?> caller = null;
379 private static native Class<?> forName0(String name, boolean initialize,
381 Class<?> caller)
386 * Returns the {@code Class} with the given <a href="ClassLoader.html#name">
410 * @return {@code Class} object of the given name defined in the given module;
431 public static Class<?> forName(Module module, String name) {
435 Class<?> caller = Reflection.getCallerClass();
437 // if caller is null, Class.forName is the last java frame on the stack.
455 * Creates a new instance of the class represented by this {@code Class}
493 * if this {@code Class} represents an abstract class,
522 if (this == Class.class) {
524 "Can not call newInstance() on the Class for java.lang.Class"
528 Class<?>[] empty = {};
550 Class<?> caller = Reflection.getCallerClass();
566 private transient volatile Class<?> newInstanceCallerCache;
571 * with the object represented by this {@code Class}. This method is
575 * reference type represented by this {@code Class} object without
579 * <p> Specifically, if this {@code Class} object represents a
583 * this {@code Class} object represents an array class, this method
587 * {@code false} otherwise. If this {@code Class} object
591 * this {@code Class} object represents a primitive type, this method
605 * {@code Class} object is either the same as, or is a superclass or
607 * {@code Class} parameter. It returns {@code true} if so;
608 * otherwise it returns {@code false}. If this {@code Class}
610 * {@code true} if the specified {@code Class} parameter is
611 * exactly this {@code Class} object; otherwise it returns
615 * specified {@code Class} parameter can be converted to the type
616 * represented by this {@code Class} object via an identity conversion
620 * @param cls the {@code Class} object to be checked
623 * @exception NullPointerException if the specified Class parameter is
628 public native boolean isAssignableFrom(Class<?> cls);
632 * Determines if the specified {@code Class} object represents an
643 * Determines if this {@code Class} object represents an array class.
654 * Determines if the specified {@code Class} object represents a
657 * <p> There are nine predefined {@code Class} objects to represent
665 * final variables, and are the only {@code Class} objects for which
685 * Returns true if this {@code Class} object represents an annotation
711 * primitive type, or void) represented by this {@code Class} object,
858 public TypeVariable<Class<T>>[] getTypeParameters() {
861 return (TypeVariable<Class<T>>[])info.getTypeParameters();
863 return (TypeVariable<Class<T>>[])new TypeVariable<?>[0];
868 * Returns the {@code Class} representing the direct superclass of the
870 * this {@code Class}. If this {@code Class} represents either the
873 * {@code Class} object representing the {@code Object} class is
879 public native Class<? super T> getSuperclass();
885 * this {@code Class}.
894 * this {@code Class} represents either the {@code Object}
897 * {@code Class} object representing the {@code Object} class is
976 Class<?> c = this;
1013 * is the {@code Class} object that represents interface
1018 * is the {@code Class} object that represents interface
1033 * <p>If this {@code Class} object represents an array type, the
1039 public Class<?>[] getInterfaces() {
1044 private Class<?>[] getInterfaces(boolean cloneArray) {
1050 Class<?>[] interfaces = rd.interfaces;
1060 private native Class<?>[] getInterfaces0();
1094 * <p>If this {@code Class} object represents an array type, the
1117 * Returns the {@code Class} representing the component type of an
1121 * @return the {@code Class} representing the component type of this
1126 public Class<?> getComponentType() {
1127 // Only return for array types. Storage may be reused for Class for instance types.
1135 private final Class<?> componentType;
1149 * {@code Class} represents a primitive type or void, its
1187 * If this {@code Class} object represents a local or anonymous
1234 Class<?> returnType = toClass(typeInfo.getReturnType());
1236 Class<?>[] parameterClasses = new Class<?>[parameterTypes.length];
1245 final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
1287 private final Class<?> enclosingClass;
1298 Class<?> enclosingClass = (Class<?>)enclosingInfo[0];
1316 this.enclosingClass = (Class<?>)enclosingInfo[0];
1329 Class<?> getEnclosingClass() { return enclosingClass; }
1337 private static Class<?> toClass(Type o) {
1342 return (Class<?>)o;
1346 * If this {@code Class} object represents a local or anonymous
1392 Class<?>[] parameterClasses = new Class<?>[parameterTypes.length];
1401 final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
1428 * If the class or interface represented by this {@code Class} object
1429 * is a member of another class, returns the {@code Class} object
1432 * this {@code Class} object represents an array class, a primitive
1445 public Class<?> getDeclaringClass() throws SecurityException {
1446 final Class<?> candidate = getDeclaringClass0();
1458 private native Class<?> getDeclaringClass0();
1475 public Class<?> getEnclosingClass() throws SecurityException {
1488 Class<?> enclosingCandidate;
1494 Class<?> enclosingClass = enclosingInfo.getEnclosingClass();
1545 Class<?> cl = this;
1582 Class<?> enclosingClass = getEnclosingClass();
1674 * Returns an array containing {@code Class} objects representing all
1676 * represented by this {@code Class} object. This includes public
1679 * array of length 0 if this {@code Class} object has no public member
1681 * this {@code Class} object represents a primitive type, an array
1684 * @return the array of {@code Class} objects representing the public
1697 public Class<?>[] getClasses() {
1711 public Class<?>[] run() {
1712 List<Class<?>> list = new ArrayList<>();
1713 Class<?> currentClass = Class.this;
1715 for (Class<?> m : currentClass.getDeclaredClasses()) {
1722 return list.toArray(new Class<?>[0]);
1731 * this {@code Class} object.
1733 * <p> If this {@code Class} object represents a class or interface with
1737 * <p> If this {@code Class} object represents a class, then this method
1741 * <p> If this {@code Class} object represents an interface, then this
1745 * <p> If this {@code Class} object represents an array type, a primitive
1762 * @jls 8.2 Class Members
1778 * Class} object, including those declared by the class or interface and
1781 * <p> If this {@code Class} object represents an array type, then the
1786 * <p> If this {@code Class} object represents an interface then the
1790 * has length 0. (Note that a {@code Class} object which represents a class
1800 * Let C be the class or interface represented by this {@code Class} object:
1851 * @jls 8.2 Class Members
1868 * {@code Class} object. An array of length 0 is returned if the
1906 * field of the class or interface represented by this {@code Class}
1925 * <p> If this {@code Class} object represents an array type, then this
1943 * @jls 8.2 Class Members
1965 * {@code Class} object. The {@code name} parameter is a
1967 * {@code parameterTypes} parameter is an array of {@code Class}
1972 * <p> If this {@code Class} object represents an array type, then this
1976 * <p> If this {@code Class} object represents an interface then this
1987 * Let C be the class or interface represented by this {@code Class} object:
2051 * @jls 8.2 Class Members
2056 public Method getMethod(String name, Class<?>... parameterTypes)
2072 * public constructor of the class represented by this {@code Class}
2074 * {@code Class} objects that identify the constructor's formal
2077 * If this {@code Class} object represents an inner class
2082 * represented by this {@code Class} object whose formal parameter
2100 public Constructor<T> getConstructor(Class<?>... parameterTypes)
2113 * Returns an array of {@code Class} objects reflecting all the
2115 * this {@code Class} object. This includes public, protected, default
2119 * interfaces as members, or if this {@code Class} object represents a
2122 * @return the array of {@code Class} objects representing all the
2148 public Class<?>[] getDeclaredClasses() throws SecurityException {
2160 * {@code Class} object. This includes public, protected, default
2163 * <p> If this {@code Class} object represents a class or interface with no
2166 * <p> If this {@code Class} object represents an array type, a primitive
2196 * @jls 8.2 Class Members
2212 * Class} object, including public, protected, default (package)
2215 * <p> If this {@code Class} object represents a type that has multiple
2220 * <p> If this {@code Class} object represents a type that has a class
2224 * <p> If this {@code Class} object represents a class or interface with no
2227 * <p> If this {@code Class} object represents an array type, a primitive
2256 * @jls 8.2 Class Members
2273 * {@code Class} object. These are public, protected, default
2277 * This method returns an array of length 0 if this {@code Class}
2320 * field of the class or interface represented by this {@code Class}
2324 * <p> If this {@code Class} object represents an array type, then this
2355 * @jls 8.2 Class Members
2377 * {@code Class} object. The {@code name} parameter is a
2380 * {@code Class} objects that identify the method's formal parameter
2388 * <p> If this {@code Class} object represents an array type, then this
2418 * @jls 8.2 Class Members
2423 public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
2447 List<Method> getDeclaredPublicMethods(String name, Class<?>... parameterTypes) {
2465 * {@code Class} object. The {@code parameterTypes} parameter is
2466 * an array of {@code Class} objects that identify the constructor's
2469 * If this {@code Class} object represents an inner class
2501 public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
2707 private boolean isOpenToCaller(String name, Class<?> caller) {
2777 * Return the Virtual Machine's Class object for the named
2780 static native Class<?> getPrimitiveClass(String name);
2794 Class<?> caller, boolean checkProxyInterfaces) {
2842 Class<?> c = this;
2860 // initialize Unsafe machinery here, since we need to call Class.class instance method
2861 // and have to avoid calling it in the static initializer of the Class class...
2863 // offset of Class.reflectionData instance field
2865 // offset of Class.annotationType instance field
2867 // offset of Class.annotationData instance field
2871 Field[] fields = Class.class.getDeclaredFields0(false); // bypass caches
2880 throw new Error("No " + fieldName + " field found in java.lang.Class");
2885 static <T> boolean casReflectionData(Class<?> clazz,
2891 static <T> boolean casAnnotationType(Class<?> clazz,
2897 static <T> boolean casAnnotationData(Class<?> clazz,
2919 volatile Class<?>[] interfaces;
3038 private Field[] privateGetPublicFields(Set<Class<?>> traversedInterfaces) {
3058 for (Class<?> c : getInterfaces()) {
3067 Class<?> c = getSuperclass();
3168 Class<?> sc = getSuperclass();
3175 for (Class<?> intf : getInterfaces(/* cloneArray */ false)) {
3223 Class<?>[] interfaces = getInterfaces(/* cloneArray */ false);
3224 for (Class<?> c : interfaces) {
3231 Class<?> c = getSuperclass();
3244 Class<?>[] parameterTypes)
3260 private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
3265 private Method getMethod0(String name, Class<?>[] parameterTypes) {
3277 Class<?>[] parameterTypes,
3292 Class<?> sc = getSuperclass();
3299 for (Class<?> intf : getInterfaces(/* cloneArray */ false)) {
3311 private Constructor<T> getConstructor0(Class<?>[] parameterTypes,
3381 private native Class<?>[] getDeclaredClasses0();
3386 private String methodToString(String name, Class<?>[] argTypes) {
3390 Class<?> c = argTypes[i];
3402 * Class Class is special cased within the Serialization Stream Protocol.
3404 * A Class instance is written initially into an ObjectOutputStream in the
3462 private static native boolean desiredAssertionStatus0(Class<?> clazz);
3493 * Class object does not represent an enum type.
3496 * represented by this Class object in the order they're
3497 * declared, or null if this Class object does not
3508 * Class object does not represent an enum type;
3541 * {@code public static <T extends Enum<T>> T valueOf(Class<T>, String)}
3564 * by this {@code Class} object.
3587 * Casts this {@code Class} object to represent a subclass of the class
3593 * a {@code Class} object to pass it to an API that restricts the
3594 * {@code Class} objects that it is willing to accept. A cast would
3601 * @return this {@code Class} object, cast to represent a subclass of
3603 * @throws ClassCastException if this {@code Class} object does not
3609 public <U> Class<? extends U> asSubclass(Class<U> clazz) {
3611 return (Class<? extends U>) this;
3621 public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
3633 public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
3642 public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationClass) {
3664 public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass) {
3675 public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationClass) {
3691 final Map<Class<? extends Annotation>, Annotation> annotations;
3692 final Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
3697 AnnotationData(Map<Class<? extends Annotation>, Annotation> annotations,
3698 Map<Class<? extends Annotation>, Annotation> declaredAnnotations,
3729 Map<Class<? extends Annotation>, Annotation> declaredAnnotations =
3731 Class<?> superClass = getSuperclass();
3732 Map<Class<? extends Annotation>, Annotation> annotations = null;
3734 Map<Class<? extends Annotation>, Annotation> superAnnotations =
3736 for (Map.Entry<Class<? extends Annotation>, Annotation> e : superAnnotations.entrySet()) {
3737 Class<? extends Annotation> annotationClass = e.getKey();
3773 Map<Class<? extends Annotation>, Annotation> getDeclaredAnnotationMap() {
3785 * Class} object. (The <em>use</em> of type Foo to specify the superclass
3789 * <p> If this {@code Class} object represents a type whose declaration
3794 * <p> If this {@code Class} represents either the {@code Object} class, an
3816 * {@code Class} object. (The <em>use</em> of type Foo to specify a
3820 * <p> If this {@code Class} object represents a class, the return value is
3824 * 'implements' clause of the declaration of this {@code Class} object.
3826 * <p> If this {@code Class} object represents an interface, the return
3831 * {@code Class} object.
3833 * <p> If this {@code Class} object represents a class or interface whose
3837 * <p> If this {@code Class} object represents either the {@code Object}