Lines Matching refs:Class

65  * called "reflection". There are basically three types of {@code Class}
69 * <h4>Class instances representing object types (classes or interfaces)</h4>
72 * hierarchy. The name associated with these {@code Class} instances is simply
83 * not possible to create new instances based on these {@code Class} instances,
85 * component type of array classes. There is one {@code Class} instance for each
102 * These represent the classes of Java arrays. There is one such {@code Class}
104 * dimensions). In this case, the name associated with the {@code Class}
108 * {@code Class} representing an array type is the same as its name. Examples
117 public final class Class<T> implements Serializable, AnnotatedElement, GenericDeclaration, Type {
126 private Class() {
150 * Returns a {@code Class} object which represents the class with the
152 * the {@link Class class definition}; however, {@code Class}es representing
162 * @return the named {@code Class} instance.
171 public static Class<?> forName(String className) throws ClassNotFoundException {
176 * Returns a {@code Class} object which represents the class with the
178 * the {@link Class class definition}, however {@code Class}es representing
194 * @return the named {@code Class} instance.
203 public static Class<?> forName(String className, boolean initializeBoolean,
215 Class<?> result;
239 static native Class<?> classForName(String className, boolean initializeBoolean,
243 * Returns an array containing {@code Class} objects for all public classes
251 public Class<?>[] getClasses() {
255 @Override public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
266 for (Class<?> sup = getSuperclass(); sup != null; sup = sup.getSuperclass()) {
296 HashMap<Class, Annotation> map = new HashMap<Class, Annotation>();
302 for (Class<?> sup = getSuperclass(); sup != null; sup = sup.getSuperclass()) {
305 Class<?> clazz = declaredAnnotations[i].annotationType();
363 * this {@code Class}. Implementations are free to return {@code null} for
388 * this Class without doing any security checks. The bootstrap ClassLoader
405 private static native ClassLoader getClassLoader(Class<?> clazz);
408 * Returns a {@code Class} object which represents the component type if
415 public native Class<?> getComponentType();
423 * {@code (Class[]) null} is equivalent to the empty array.
427 * @see #getDeclaredConstructor(Class[])
430 public Constructor<T> getConstructor(Class<?>... parameterTypes) throws NoSuchMethodException {
441 boolean publicOnly, Class<?>[] parameterTypes) throws NoSuchMethodException {
451 for (Class<?> c : parameterTypes) {
458 : Class.getDeclaredConstructorOrMethod(this, name, parameterTypes);
465 private Member getPublicConstructorOrMethodRecursive(String name, Class<?>[] parameterTypes) {
467 for (Class<?> c = this; c != null; c = c.getSuperclass()) {
468 Member result = Class.getDeclaredConstructorOrMethod(c, name, parameterTypes);
475 for (Class<?> c = this; c != null; c = c.getSuperclass()) {
476 for (Class<?> ifc : c.getInterfaces()) {
489 * constructors for the class represented by this {@code Class}. If there
490 * are no public constructors or if this {@code Class} represents an array
494 * this {@code Class}.
503 * represented by this {@code Class}. Annotations that are inherited are not
508 * class that this {@code Class} represents.
516 native private <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass);
521 native private boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationClass);
524 * Returns an array containing {@code Class} objects for all classes and
526 * Class} represents. If there are no classes or interfaces declared or if
530 * @return an array with {@code Class} objects for all the classes and
533 public Class<?>[] getDeclaredClasses() {
545 private Class<?>[] getFullListOfClasses(boolean publicOnly) {
546 Class<?>[] result = getDeclaredClasses(this, publicOnly);
549 Class<?> clazz = this.getSuperclass();
551 Class<?>[] temp = getDeclaredClasses(clazz, publicOnly);
553 result = arraycopy(new Class[result.length + temp.length], result, temp);
570 private static native Class<?>[] getDeclaredClasses(Class<?> clazz, boolean publicOnly);
575 * represented by this {@code Class}.
579 * {@code (Class[]) null} is equivalent to the empty array.
583 * @see #getConstructor(Class[])
586 public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
593 * constructors declared in the class represented by this {@code Class}. If
594 * there are no constructors or if this {@code Class} represents an array
598 * by this {@code Class}.
614 Class<T> clazz, boolean publicOnly);
618 * which is declared in the class represented by this {@code Class}.
638 * in the class represented by this {@code Class}. If there are no fields or
639 * if this {@code Class} represents an array class, a primitive type or void
658 static native Field[] getDeclaredFields(Class<?> clazz, boolean publicOnly);
664 static native Field getDeclaredField(Class<?> clazz, String name);
669 * represented by this {@code Class}.
675 * {@code (Class[]) null} is equivalent to the empty array.
681 * @see #getMethod(String, Class[])
683 public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
694 * declared in the class represented by this {@code Class}. If there are no
695 * methods or if this {@code Class} represents an array class, a primitive
699 * this {@code Class}.
710 static native Method[] getDeclaredMethods(Class<?> clazz, boolean publicOnly);
718 static native Member getDeclaredConstructorOrMethod(Class clazz, String name, Class[] args);
721 * Returns the declaring {@code Class} of this {@code Class}. Returns
723 * {@code Class} represents an array class, a primitive type or void.
725 * @return the declaring {@code Class} or {@code null}.
727 native public Class<?> getDeclaringClass();
730 * Returns the enclosing {@code Class} of this {@code Class}. If there is no
733 * @return the enclosing {@code Class} or {@code null}.
735 native public Class<?> getEnclosingClass();
738 * Gets the enclosing {@code Constructor} of this {@code Class}, if it is an
746 * Gets the enclosing {@code Method} of this {@code Class}, if it is an
754 * Gets the {@code enum} constants associated with this {@code Class}.
755 * Returns {@code null} if this {@code Class} does not represent an {@code
765 return (T[]) Enum.getSharedConstants((Class) this).clone();
771 * this {@code Class}, then the interfaces implemented by C and finally the
794 for (Class<?> c = this; c != null; c = c.getSuperclass()) {
795 Field result = Class.getDeclaredField(c, name);
802 for (Class<?> c = this; c != null; c = c.getSuperclass()) {
803 for (Class<?> ifc : c.getInterfaces()) {
816 * for the class C represented by this {@code Class}. Fields may be declared
824 * {@code Class}.
845 for (Class<?> c = this; c != null; c = c.getSuperclass()) {
846 for (Field field : Class.getDeclaredFields(c, true)) {
852 for (Class<?> c = this; c != null; c = c.getSuperclass()) {
853 for (Class<?> ifc : c.getInterfaces()) {
860 * Gets the {@link Type}s of the interfaces that this {@code Class} directly
861 * implements. If the {@code Class} represents a primitive type or {@code
886 * Returns an array of {@code Class} objects that match the interfaces
888 * by this {@code Class}. The order of the elements in the array is
895 public native Class<?>[] getInterfaces();
900 * class C represented by this {@code Class}, then the superclasses of C and
908 * {@code (Class[]) null} is equivalent to the empty array.
912 * @see #getDeclaredMethod(String, Class[])
914 public Method getMethod(String name, Class<?>... parameterTypes) throws NoSuchMethodException {
924 * for the class C represented by this {@code Class}. Methods may be
928 * If there are no public methods or if this {@code Class} represents a
933 * {@code Class}.
954 for (Class<?> c = this; c != null; c = c.getSuperclass()) {
955 for (Method method : Class.getDeclaredMethods(c, true)) {
961 for (Class<?> c = this; c != null; c = c.getSuperclass()) {
962 for (Class<?> ifc : c.getInterfaces()) {
970 * by this {@code Class}. The returned value is a combination of bits
973 * @return the modifiers of the class represented by this {@code Class}.
986 private static native int getModifiers(Class<?> clazz, boolean ignoreInnerClassesAttrib);
989 * Returns the name of the class represented by this {@code Class}. For a
991 * {@link Class}.
993 * @return the name of the class represented by this {@code Class}.
1003 * Returns the simple name of the class represented by this {@code Class} as
1009 * @return the simple name of the class represented by this {@code Class}.
1134 * Returns the {@code Class} object which represents the superclass of the
1135 * class represented by this {@code Class}. If this {@code Class} represents
1137 * method returns {@code null}. If this {@code Class} represents an array
1140 * @return the superclass of the class represented by this {@code Class}.
1142 public native Class<? super T> getSuperclass();
1147 * Class}. Returns an empty array if the class is not generic.
1153 public synchronized TypeVariable<Class<T>>[] getTypeParameters() {
1160 * Indicates whether this {@code Class} represents an annotation class.
1162 * @return {@code true} if this {@code Class} represents an annotation
1171 @Override public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
1181 for (Class<?> sup = getSuperclass(); sup != null; sup = sup.getSuperclass()) {
1192 * Indicates whether the class represented by this {@code Class} is
1195 * @return {@code true} if the class represented by this {@code Class} is
1201 * Indicates whether the class represented by this {@code Class} is an array
1204 * @return {@code true} if the class represented by this {@code Class} is an
1213 * represented by this {@code Class}. Conversion may be done via an identity
1221 * represented by this {@code Class}; {@code false} otherwise.
1225 public native boolean isAssignableFrom(Class<?> cls);
1228 * Indicates whether the class represented by this {@code Class} is an
1231 * @return {@code true} if the class represented by this {@code Class} is an
1240 * represented by this {@code Class}. This is the runtime version of the
1246 * represented by this {@code Class}; {@code false} if {@code
1252 * Indicates whether this {@code Class} represents an interface.
1254 * @return {@code true} if this {@code Class} represents an interface;
1260 * Indicates whether the class represented by this {@code Class} is defined
1263 * @return {@code true} if the class represented by this {@code Class} is
1273 * Indicates whether the class represented by this {@code Class} is a member
1276 * @return {@code true} if the class represented by this {@code Class} is a
1284 * Indicates whether this {@code Class} represents a primitive type.
1286 * @return {@code true} if this {@code Class} represents a primitive type;
1292 * Indicates whether this {@code Class} represents a synthetic type.
1294 * @return {@code true} if this {@code Class} represents a synthetic type;
1304 * Returns a new instance of the class represented by this {@code Class},
1312 * @return a new instance of the class represented by this {@code Class}.
1335 * {@code Class} is a member. Returns {@code null} if no {@code Package}
1338 * @return Package the {@code Package} of which this {@code Class} is a
1354 * Class}. Assertion is enabled / disabled based on the class loader,
1358 * Class}.
1363 * Casts this {@code Class} to represent a subclass of the specified class.
1364 * If successful, this {@code Class} is returned; otherwise a {@code
1369 * @return this {@code Class} cast as a subclass of the given type.
1371 * if this {@code Class} cannot be cast to the specified type.
1374 public <U> Class<? extends U> asSubclass(Class<U> clazz) {
1376 return (Class<? extends U>)this;
1384 * Casts the specified object to the type represented by this {@code Class}.