< prev index next >

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

Print this page

  66 import java.util.List;
  67 import java.util.Map;
  68 import java.util.Objects;
  69 import java.util.Optional;
  70 import java.util.Set;
  71 import java.util.stream.Collectors;
  72 
  73 import jdk.internal.javac.PreviewFeature;
  74 import jdk.internal.loader.BootLoader;
  75 import jdk.internal.loader.BuiltinClassLoader;
  76 import jdk.internal.misc.PreviewFeatures;
  77 import jdk.internal.misc.Unsafe;
  78 import jdk.internal.module.Resources;
  79 import jdk.internal.reflect.CallerSensitive;
  80 import jdk.internal.reflect.CallerSensitiveAdapter;
  81 import jdk.internal.reflect.ConstantPool;
  82 import jdk.internal.reflect.Reflection;
  83 import jdk.internal.reflect.ReflectionFactory;
  84 import jdk.internal.vm.annotation.ForceInline;
  85 import jdk.internal.vm.annotation.IntrinsicCandidate;

  86 
  87 import sun.invoke.util.Wrapper;
  88 import sun.reflect.generics.factory.CoreReflectionFactory;
  89 import sun.reflect.generics.factory.GenericsFactory;
  90 import sun.reflect.generics.repository.ClassRepository;
  91 import sun.reflect.generics.repository.MethodRepository;
  92 import sun.reflect.generics.repository.ConstructorRepository;
  93 import sun.reflect.generics.scope.ClassScope;
  94 import sun.security.util.SecurityConstants;
  95 import sun.reflect.annotation.*;
  96 import sun.reflect.misc.ReflectUtil;
  97 
  98 /**
  99  * Instances of the class {@code Class} represent classes and
 100  * interfaces in a running Java application. An enum class and a record
 101  * class are kinds of class; an annotation interface is a kind of
 102  * interface. Every array also belongs to a class that is reflected as
 103  * a {@code Class} object that is shared by all arrays with the same
 104  * element type and number of dimensions.  The primitive Java types
 105  * ({@code boolean}, {@code byte}, {@code char}, {@code short}, {@code

1043      * Returns the module that this class or interface is a member of.
1044      *
1045      * If this class represents an array type then this method returns the
1046      * {@code Module} for the element type. If this class represents a
1047      * primitive type or void, then the {@code Module} object for the
1048      * {@code java.base} module is returned.
1049      *
1050      * If this class is in an unnamed module then the {@linkplain
1051      * ClassLoader#getUnnamedModule() unnamed} {@code Module} of the class
1052      * loader for this class is returned.
1053      *
1054      * @return the module that this class or interface is a member of
1055      *
1056      * @since 9
1057      */
1058     public Module getModule() {
1059         return module;
1060     }
1061 
1062     // set by VM

1063     private transient Module module;
1064 
1065     // Initialized in JVM not by private constructor
1066     // This field is filtered from reflection access, i.e. getDeclaredField
1067     // will throw NoSuchFieldException
1068     private final ClassLoader classLoader;
1069 
1070     // Set by VM
1071     private transient Object classData;
1072 
1073     // package-private
1074     Object getClassData() {
1075         return classData;
1076     }
1077 
1078     /**
1079      * Returns an array of {@code TypeVariable} objects that represent the
1080      * type variables declared by the generic declaration represented by this
1081      * {@code GenericDeclaration} object, in declaration order.  Returns an
1082      * array of length 0 if the underlying generic declaration declares no type

  66 import java.util.List;
  67 import java.util.Map;
  68 import java.util.Objects;
  69 import java.util.Optional;
  70 import java.util.Set;
  71 import java.util.stream.Collectors;
  72 
  73 import jdk.internal.javac.PreviewFeature;
  74 import jdk.internal.loader.BootLoader;
  75 import jdk.internal.loader.BuiltinClassLoader;
  76 import jdk.internal.misc.PreviewFeatures;
  77 import jdk.internal.misc.Unsafe;
  78 import jdk.internal.module.Resources;
  79 import jdk.internal.reflect.CallerSensitive;
  80 import jdk.internal.reflect.CallerSensitiveAdapter;
  81 import jdk.internal.reflect.ConstantPool;
  82 import jdk.internal.reflect.Reflection;
  83 import jdk.internal.reflect.ReflectionFactory;
  84 import jdk.internal.vm.annotation.ForceInline;
  85 import jdk.internal.vm.annotation.IntrinsicCandidate;
  86 import jdk.internal.vm.annotation.Stable;
  87 
  88 import sun.invoke.util.Wrapper;
  89 import sun.reflect.generics.factory.CoreReflectionFactory;
  90 import sun.reflect.generics.factory.GenericsFactory;
  91 import sun.reflect.generics.repository.ClassRepository;
  92 import sun.reflect.generics.repository.MethodRepository;
  93 import sun.reflect.generics.repository.ConstructorRepository;
  94 import sun.reflect.generics.scope.ClassScope;
  95 import sun.security.util.SecurityConstants;
  96 import sun.reflect.annotation.*;
  97 import sun.reflect.misc.ReflectUtil;
  98 
  99 /**
 100  * Instances of the class {@code Class} represent classes and
 101  * interfaces in a running Java application. An enum class and a record
 102  * class are kinds of class; an annotation interface is a kind of
 103  * interface. Every array also belongs to a class that is reflected as
 104  * a {@code Class} object that is shared by all arrays with the same
 105  * element type and number of dimensions.  The primitive Java types
 106  * ({@code boolean}, {@code byte}, {@code char}, {@code short}, {@code

1044      * Returns the module that this class or interface is a member of.
1045      *
1046      * If this class represents an array type then this method returns the
1047      * {@code Module} for the element type. If this class represents a
1048      * primitive type or void, then the {@code Module} object for the
1049      * {@code java.base} module is returned.
1050      *
1051      * If this class is in an unnamed module then the {@linkplain
1052      * ClassLoader#getUnnamedModule() unnamed} {@code Module} of the class
1053      * loader for this class is returned.
1054      *
1055      * @return the module that this class or interface is a member of
1056      *
1057      * @since 9
1058      */
1059     public Module getModule() {
1060         return module;
1061     }
1062 
1063     // set by VM
1064     @Stable
1065     private transient Module module;
1066 
1067     // Initialized in JVM not by private constructor
1068     // This field is filtered from reflection access, i.e. getDeclaredField
1069     // will throw NoSuchFieldException
1070     private final ClassLoader classLoader;
1071 
1072     // Set by VM
1073     private transient Object classData;
1074 
1075     // package-private
1076     Object getClassData() {
1077         return classData;
1078     }
1079 
1080     /**
1081      * Returns an array of {@code TypeVariable} objects that represent the
1082      * type variables declared by the generic declaration represented by this
1083      * {@code GenericDeclaration} object, in declaration order.  Returns an
1084      * array of length 0 if the underlying generic declaration declares no type
< prev index next >