java.lang.Class.getClassCache()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(231)

本文整理了Java中java.lang.Class.getClassCache()方法的一些代码示例,展示了Class.getClassCache()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Class.getClassCache()方法的具体详情如下:
包路径:java.lang.Class
类名称:Class
方法名:getClassCache

Class.getClassCache介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns an array containing {@code Class} objects for all public classes
  3. * and interfaces that are members of this class. This includes public
  4. * members inherited from super classes and interfaces. If there are no such
  5. * class members or if this object represents a primitive type then an array
  6. * of length 0 is returned.
  7. *
  8. * @return the public class members of the class represented by this object.
  9. */
  10. public Class<?>[] getClasses() {
  11. return getClassCache().getClasses(true);
  12. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns an array containing all the annotations of this class. If there are no annotations
  3. * then an empty array is returned.
  4. *
  5. * @see #getDeclaredAnnotations()
  6. */
  7. public Annotation[] getAnnotations() {
  8. return getClassCache().getAnnotations(true);
  9. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns the annotations that are directly defined on the class
  3. * represented by this {@code Class}. Annotations that are inherited are not
  4. * included in the result. If there are no annotations at all, an empty
  5. * array is returned.
  6. *
  7. * @see #getAnnotations()
  8. */
  9. public Annotation[] getDeclaredAnnotations() {
  10. return getClassCache().getDeclaredAnnotations(true);
  11. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns an array containing {@code Constructor} objects for all
  3. * constructors declared in the class represented by this {@code Class}. If
  4. * there are no constructors or if this {@code Class} represents an array
  5. * class, a primitive type, or void then an empty array is returned.
  6. *
  7. * @see #getConstructors()
  8. */
  9. public Constructor<?>[] getDeclaredConstructors() {
  10. return getClassCache().getDeclaredConstructors(true);
  11. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns the name of the class represented by this {@code Class}. For a
  3. * description of the format which is used, see the class definition of
  4. * {@link Class}.
  5. */
  6. public String getName() {
  7. return getClassCache().getName();
  8. }

代码示例来源:origin: robovm/robovm

  1. private List<Class<?>> buildClassesList(List<Class<?>> result, Set<String> seen, boolean publicOnly) {
  2. for (Class<?> c = clazz; c != null; c = c.getSuperclass()) {
  3. for (Class<?> f : c.getClassCache().getDeclaredClasses(false, publicOnly)) {
  4. String s = f.toString();
  5. if (!seen.contains(s)) {
  6. result.add(f);
  7. seen.add(s);
  8. }
  9. }
  10. }
  11. return result;
  12. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns an array containing {@code Constructor} objects for all public
  3. * constructors for this {@code Class}. If there
  4. * are no public constructors or if this {@code Class} represents an array
  5. * class, a primitive type or void then an empty array is returned.
  6. *
  7. * @see #getDeclaredConstructors()
  8. */
  9. public Constructor<?>[] getConstructors() {
  10. return getClassCache().getDeclaredPublicConstructors(true);
  11. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns an array containing {@code Method} objects for all methods
  3. * declared in the class represented by this {@code Class}. If there are no
  4. * methods or if this {@code Class} represents an array class, a primitive
  5. * type or void then an empty array is returned.
  6. *
  7. * @see #getMethods()
  8. */
  9. public Method[] getDeclaredMethods() {
  10. return getClassCache().getDeclaredMethods(true);
  11. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns a {@code Field} object for the field with the given name
  3. * which is declared in the class represented by this {@code Class}.
  4. *
  5. * @throws NoSuchFieldException if the requested field can not be found.
  6. * @see #getField(String)
  7. */
  8. public Field getDeclaredField(String name) throws NoSuchFieldException {
  9. if (name == null) {
  10. throw new NullPointerException("name == null");
  11. }
  12. return getClassCache().getDeclaredField(true, name);
  13. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns an array containing {@code Class} objects for all classes and
  3. * interfaces that are declared as members of the class which this {@code
  4. * Class} represents. If there are no classes or interfaces declared or if
  5. * this class represents an array class, a primitive type or void, then an
  6. * empty array is returned.
  7. */
  8. public Class<?>[] getDeclaredClasses() {
  9. return getClassCache().getDeclaredClasses(true);
  10. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns an array containing {@code Field} objects for all fields declared
  3. * in the class represented by this {@code Class}. If there are no fields or
  4. * if this {@code Class} represents an array class, a primitive type or void
  5. * then an empty array is returned.
  6. *
  7. * @see #getFields()
  8. */
  9. public Field[] getDeclaredFields() {
  10. return getClassCache().getDeclaredFields(true);
  11. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns an array containing {@code Field} objects for all public fields
  3. * for the class C represented by this {@code Class}. Fields may be declared
  4. * in C, the interfaces it implements or in the superclasses of C. The
  5. * elements in the returned array are in no particular order.
  6. *
  7. * <p>If there are no public fields or if this class represents an array class,
  8. * a primitive type or {@code void} then an empty array is returned.
  9. *
  10. * @see #getDeclaredFields()
  11. */
  12. public Field[] getFields() {
  13. return getClassCache().getFields(true);
  14. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns a {@code Constructor} object which represents the public
  3. * constructor matching the given parameter types.
  4. * {@code (Class[]) null} is equivalent to the empty array.
  5. *
  6. * <p>See {@link #getMethod} for details of the search order.
  7. * Use {@link #getDeclaredConstructor} if you don't want to search superclasses.
  8. *
  9. * @throws NoSuchMethodException
  10. * if the constructor can not be found.
  11. */
  12. @SuppressWarnings("unchecked")
  13. public Constructor<T> getConstructor(Class<?>... parameterTypes) throws NoSuchMethodException {
  14. return getClassCache().getConstructor(true, parameterTypes);
  15. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns an array containing {@code Method} objects for all public methods
  3. * for the class C represented by this {@code Class}. Methods may be
  4. * declared in C, the interfaces it implements or in the superclasses of C.
  5. * The elements in the returned array are in no particular order.
  6. *
  7. * <p>If there are no public methods or if this {@code Class} represents a
  8. * primitive type or {@code void} then an empty array is returned.
  9. *
  10. * @see #getDeclaredMethods()
  11. */
  12. public Method[] getMethods() {
  13. return getClassCache().getMethods(true);
  14. }

代码示例来源:origin: robovm/robovm

  1. private List<Field> buildFieldsList(List<Field> result, Set<String> seen, boolean publicOnly) {
  2. for (Class<?> c = clazz; c != null; c = c.getSuperclass()) {
  3. for (Field f : c.getClassCache().getDeclaredFields(false, publicOnly)) {
  4. String s = f.toString();
  5. if (!seen.contains(s)) {
  6. result.add(f);
  7. seen.add(s);
  8. }
  9. }
  10. for (Class<?> intf : c.getInterfaces()) {
  11. intf.getClassCache().buildFieldsList(result, seen, publicOnly);
  12. }
  13. }
  14. return result;
  15. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns the annotation if it exists.
  3. */
  4. private <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass) {
  5. if (annotationClass == null) {
  6. throw new NullPointerException("annotationClass == null");
  7. }
  8. Annotation[] annos = getClassCache().getDeclaredAnnotations(false);
  9. for (int i = annos.length-1; i >= 0; --i) {
  10. if (annos[i].annotationType() == annotationClass) {
  11. return (A) annos[i];
  12. }
  13. }
  14. return null;
  15. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns a {@code Constructor} object which represents the constructor
  3. * matching the given parameter types that is declared by the class
  4. * represented by this {@code Class}.
  5. * {@code (Class[]) null} is equivalent to the empty array.
  6. *
  7. * <p>Use {@link #getConstructor} if you want to search superclasses.
  8. *
  9. * @throws NoSuchMethodException
  10. * if the requested constructor can not be found.
  11. */
  12. @SuppressWarnings("unchecked")
  13. public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
  14. throws NoSuchMethodException {
  15. return getClassCache().getDeclaredConstructor(true, parameterTypes);
  16. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns a {@code Field} object which represents the public field with the
  3. * given name. This method first searches the class C represented by
  4. * this {@code Class}, then the interfaces implemented by C and finally the
  5. * superclasses of C.
  6. *
  7. * @throws NoSuchFieldException
  8. * if the field can not be found.
  9. * @see #getDeclaredField(String)
  10. */
  11. public Field getField(String name) throws NoSuchFieldException {
  12. if (name == null) {
  13. throw new NullPointerException("name == null");
  14. }
  15. return getClassCache().getField(true, name);
  16. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns a {@code Method} object which represents the method matching the
  3. * given name and parameter types that is declared by the class
  4. * represented by this {@code Class}.
  5. * {@code (Class[]) null} is equivalent to the empty array.
  6. *
  7. * <p>See {@link #getMethod} if you want to search superclasses.
  8. *
  9. * @throws NoSuchMethodException
  10. * if the requested method can not be found.
  11. * @throws NullPointerException
  12. * if {@code name} is {@code null}.
  13. */
  14. public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
  15. throws NoSuchMethodException {
  16. return getClassCache().getDeclaredMethod(true, name, parameterTypes);
  17. }

代码示例来源:origin: robovm/robovm

  1. private List<Method> buildMethodsList(List<Method> result, Set<MethodHashKey> seen, boolean publicOnly) {
  2. for (Class<?> c = clazz; c != null; c = c.getSuperclass()) {
  3. for (Method m : c.getClassCache().getDeclaredMethods(false, publicOnly)) {
  4. MethodHashKey key = new MethodHashKey(m);
  5. if (!seen.contains(key)) {
  6. result.add(m);
  7. seen.add(key);
  8. }
  9. }
  10. }
  11. for (Class<?> c = clazz; c != null; c = c.getSuperclass()) {
  12. for (Class<?> intf : c.getInterfaces()) {
  13. intf.getClassCache().buildMethodsList(result, seen, publicOnly);
  14. }
  15. }
  16. return result;
  17. }

相关文章

Class类方法