⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* Class.java -- Representation of a Java class.   Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005   Free Software FoundationThis file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package java.lang;import java.io.InputStream;import java.io.Serializable;import java.lang.reflect.Constructor;import java.lang.reflect.Field;import java.lang.reflect.Member;import java.lang.reflect.Method;import java.net.URL;import java.security.ProtectionDomain;import java.util.ArrayList;import java.util.Arrays;import java.util.HashSet;/** * A Class represents a Java type.  There will never be multiple Class * objects with identical names and ClassLoaders. Primitive types, array * types, and void also have a Class object. * * <p>Arrays with identical type and number of dimensions share the same class. * The array class ClassLoader is the same as the ClassLoader of the element * type of the array (which can be null to indicate the bootstrap classloader). * The name of an array class is <code>[&lt;signature format&gt;;</code>. * <p> For example, * String[]'s class is <code>[Ljava.lang.String;</code>. boolean, byte, * short, char, int, long, float and double have the "type name" of * Z,B,S,C,I,J,F,D for the purposes of array classes.  If it's a * multidimensioned array, the same principle applies: * <code>int[][][]</code> == <code>[[[I</code>. * * <p>There is no public constructor - Class objects are obtained only through * the virtual machine, as defined in ClassLoaders. * * @serialData Class objects serialize specially: * <code>TC_CLASS ClassDescriptor</code>. For more serialization information, * see {@link ObjectStreamClass}. * * @author John Keiser * @author Eric Blake (ebb9@email.byu.edu) * @author Tom Tromey (tromey@cygnus.com) * @since 1.0 * @see ClassLoader */public final class Class implements Serializable{  /**   * Class is non-instantiable from Java code; only the VM can create   * instances of this class.   */  private Class ()  {  }  // Initialize the class.  private native void initializeClass ();  // finalization  protected native void finalize () throws Throwable;  /**   * Use the classloader of the current class to load, link, and initialize   * a class. This is equivalent to your code calling   * <code>Class.forName(name, true, getClass().getClassLoader())</code>.   *   * @param name the name of the class to find   * @return the Class object representing the class   * @throws ClassNotFoundException if the class was not found by the   *         classloader   * @throws LinkageError if linking the class fails   * @throws ExceptionInInitializerError if the class loads, but an exception   *         occurs during initialization   */  public static native Class forName (String className)    throws ClassNotFoundException;  /**   * Use the specified classloader to load and link a class. If the loader   * is null, this uses the bootstrap class loader (provide the security   * check succeeds). Unfortunately, this method cannot be used to obtain   * the Class objects for primitive types or for void, you have to use   * the fields in the appropriate java.lang wrapper classes.   *   * <p>Calls <code>classloader.loadclass(name, initialize)</code>.   *   * @param name the name of the class to find   * @param initialize whether or not to initialize the class at this time   * @param classloader the classloader to use to find the class; null means   *        to use the bootstrap class loader   * @throws ClassNotFoundException if the class was not found by the   *         classloader   * @throws LinkageError if linking the class fails   * @throws ExceptionInInitializerError if the class loads, but an exception   *         occurs during initialization   * @throws SecurityException if the <code>classloader</code> argument   *         is <code>null</code> and the caller does not have the   *         <code>RuntimePermission("getClassLoader")</code> permission   * @see ClassLoader   * @since 1.2   */  public static native Class forName (String className, boolean initialize,				      ClassLoader loader)    throws ClassNotFoundException;    /**   * Get all the public member classes and interfaces declared in this   * class or inherited from superclasses. This returns an array of length   * 0 if there are no member classes, including for primitive types. A   * security check may be performed, with   * <code>checkMemberAccess(this, Member.PUBLIC)</code> as well as   * <code>checkPackageAccess</code> both having to succeed.   *   * @return all public member classes in this class   * @throws SecurityException if the security check fails   * @since 1.1   */  public Class[] getClasses()  {    memberAccessCheck(Member.PUBLIC);    return internalGetClasses();  }  /**   * Like <code>getClasses()</code> but without the security checks.   */  private Class[] internalGetClasses()  {    ArrayList list = new ArrayList();    list.addAll(Arrays.asList(getDeclaredClasses(true)));    Class superClass = getSuperclass();    if (superClass != null)      list.addAll(Arrays.asList(superClass.internalGetClasses()));    return (Class[])list.toArray(new Class[list.size()]);  }    /**   * Get the ClassLoader that loaded this class.  If the class was loaded   * by the bootstrap classloader, this method will return null.   * If there is a security manager, and the caller's class loader is not   * an ancestor of the requested one, a security check of   * <code>RuntimePermission("getClassLoader")</code>   * must first succeed. Primitive types and void return null.   *   * @return the ClassLoader that loaded this class   * @throws SecurityException if the security check fails   * @see ClassLoader   * @see RuntimePermission   */  public native ClassLoader getClassLoader ();    /**   * If this is an array, get the Class representing the type of array.   * Examples: "[[Ljava.lang.String;" would return "[Ljava.lang.String;", and   * calling getComponentType on that would give "java.lang.String".  If   * this is not an array, returns null.   *   * @return the array type of this class, or null   * @see Array   * @since 1.1   */  public native Class getComponentType ();  /**   * Get a public constructor declared in this class. If the constructor takes   * no argument, an array of zero elements and null are equivalent for the   * types argument. A security check may be performed, with   * <code>checkMemberAccess(this, Member.PUBLIC)</code> as well as   * <code>checkPackageAccess</code> both having to succeed.   *   * @param types the type of each parameter   * @return the constructor   * @throws NoSuchMethodException if the constructor does not exist   * @throws SecurityException if the security check fails   * @see #getConstructors()   * @since 1.1   */  public native Constructor getConstructor(Class[] args)    throws NoSuchMethodException;  /**   * Get all the public constructors of this class. This returns an array of   * length 0 if there are no constructors, including for primitive types,   * arrays, and interfaces. It does, however, include the default   * constructor if one was supplied by the compiler. A security check may   * be performed, with <code>checkMemberAccess(this, Member.PUBLIC)</code>   * as well as <code>checkPackageAccess</code> both having to succeed.   *   * @return all public constructors in this class   * @throws SecurityException if the security check fails   * @since 1.1   */  public Constructor[] getConstructors()  {    memberAccessCheck(Member.PUBLIC);    return getDeclaredConstructors(true);  }  /**   * Get a constructor declared in this class. If the constructor takes no   * argument, an array of zero elements and null are equivalent for the   * types argument. A security check may be performed, with   * <code>checkMemberAccess(this, Member.DECLARED)</code> as well as   * <code>checkPackageAccess</code> both having to succeed.   *   * @param types the type of each parameter   * @return the constructor   * @throws NoSuchMethodException if the constructor does not exist   * @throws SecurityException if the security check fails   * @see #getDeclaredConstructors()   * @since 1.1   */  public native Constructor getDeclaredConstructor(Class[] args)    throws NoSuchMethodException;  /**   * Get all the declared member classes and interfaces in this class, but   * not those inherited from superclasses. This returns an array of length   * 0 if there are no member classes, including for primitive types. A   * security check may be performed, with   * <code>checkMemberAccess(this, Member.DECLARED)</code> as well as   * <code>checkPackageAccess</code> both having to succeed.   *   * @return all declared member classes in this class   * @throws SecurityException if the security check fails   * @since 1.1   */  public Class[] getDeclaredClasses()  {    memberAccessCheck(Member.DECLARED);    return getDeclaredClasses(false);  }  native Class[] getDeclaredClasses (boolean publicOnly);  /**   * Get all the declared constructors of this class. This returns an array of   * length 0 if there are no constructors, including for primitive types,   * arrays, and interfaces. It does, however, include the default   * constructor if one was supplied by the compiler. A security check may   * be performed, with <code>checkMemberAccess(this, Member.DECLARED)</code>   * as well as <code>checkPackageAccess</code> both having to succeed.   *   * @return all constructors in this class   * @throws SecurityException if the security check fails   * @since 1.1   */  public Constructor[] getDeclaredConstructors()  {    memberAccessCheck(Member.DECLARED);    return getDeclaredConstructors(false);  }  native Constructor[] getDeclaredConstructors (boolean publicOnly);  /**   * Get a field declared in this class, where name is its simple name. The   * implicit length field of arrays is not available. A security check may   * be performed, with <code>checkMemberAccess(this, Member.DECLARED)</code>   * as well as <code>checkPackageAccess</code> both having to succeed.   *   * @param name the name of the field   * @return the field   * @throws NoSuchFieldException if the field does not exist   * @throws SecurityException if the security check fails   * @see #getDeclaredFields()   * @since 1.1   */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -