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

📄 class.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    if (loader == null)      return ClassLoader.getSystemResource(name);    return loader.getResource(name);  }  /**   * Get a resource using this class's package using the   * getClassLoader().getResourceAsStream() method.  If this class was loaded   * using the system classloader, ClassLoader.getSystemResource() is used   * instead.   *   * <p>If the name you supply is absolute (it starts with a <code>/</code>),   * then the leading <code>/</code> is removed and it is passed on to   * getResource(). If it is relative, the package name is prepended, and   * <code>.</code>'s are replaced with <code>/</code>.   *   * <p>The URL returned is system- and classloader-dependent, and could   * change across implementations.   *   * @param resourceName the name of the resource, generally a path   * @return an InputStream with the contents of the resource in it, or null   * @throws NullPointerException if name is null   * @since 1.1   */  public InputStream getResourceAsStream(String resourceName)  {    String name = resourcePath(resourceName);    ClassLoader loader = getClassLoader();    if (loader == null)      return ClassLoader.getSystemResourceAsStream(name);    return loader.getResourceAsStream(name);  }  private String resourcePath(String resourceName)  {    if (resourceName.length() > 0)      {	if (resourceName.charAt(0) != '/')	  {	    String pkg = getPackagePortion(getName());	    if (pkg.length() > 0)	      resourceName = pkg.replace('.','/') + '/' + resourceName;	  }	else	  {	    resourceName = resourceName.substring(1);	  }      }    return resourceName;  }  /**   * Get the signers of this class. This returns null if there are no signers,   * such as for primitive types or void.   *   * @return the signers of this class   * @since 1.1   */  public native Object[] getSigners ();    /**   * Set the signers of this class.   *   * @param signers the signers of this class   */  native void setSigners(Object[] signers);  /**   * Get the direct superclass of this class.  If this is an interface,   * Object, a primitive type, or void, it will return null. If this is an   * array type, it will return Object.   *   * @return the direct superclass of this class   */  public native Class getSuperclass ();    /**   * Return whether this class is an array type.   *   * @return whether this class is an array type   * @since 1.1   */  public native boolean isArray ();    /**   * Discover whether an instance of the Class parameter would be an   * instance of this Class as well.  Think of doing   * <code>isInstance(c.newInstance())</code> or even   * <code>c.newInstance() instanceof (this class)</code>. While this   * checks widening conversions for objects, it must be exact for primitive   * types.   *   * @param c the class to check   * @return whether an instance of c would be an instance of this class   *         as well   * @throws NullPointerException if c is null   * @since 1.1   */  public native boolean isAssignableFrom (Class c);   /**   * Discover whether an Object is an instance of this Class.  Think of it   * as almost like <code>o instanceof (this class)</code>.   *   * @param o the Object to check   * @return whether o is an instance of this class   * @since 1.1   */  public native boolean isInstance (Object o);    /**   * Check whether this class is an interface or not.  Array types are not   * interfaces.   *   * @return whether this class is an interface or not   */  public native boolean isInterface ();    /**   * Return whether this class is a primitive type.  A primitive type class   * is a class representing a kind of "placeholder" for the various   * primitive types, or void.  You can access the various primitive type   * classes through java.lang.Boolean.TYPE, java.lang.Integer.TYPE, etc.,   * or through boolean.class, int.class, etc.   *   * @return whether this class is a primitive type   * @see Boolean#TYPE   * @see Byte#TYPE   * @see Character#TYPE   * @see Short#TYPE   * @see Integer#TYPE   * @see Long#TYPE   * @see Float#TYPE   * @see Double#TYPE   * @see Void#TYPE   * @since 1.1   */  public native boolean isPrimitive ();    /**   * Get a new instance of this class by calling the no-argument constructor.   * The class is initialized if it has not been already. A security check   * may be performed, with <code>checkMemberAccess(this, Member.PUBLIC)</code>   * as well as <code>checkPackageAccess</code> both having to succeed.   *   * @return a new instance of this class   * @throws InstantiationException if there is not a no-arg constructor   *         for this class, including interfaces, abstract classes, arrays,   *         primitive types, and void; or if an exception occurred during   *         the constructor   * @throws IllegalAccessException if you are not allowed to access the   *         no-arg constructor because of scoping reasons   * @throws SecurityException if the security check fails   * @throws ExceptionInInitializerError if class initialization caused by   *         this call fails with an exception   */  public native Object newInstance ()    throws InstantiationException, IllegalAccessException;  // We need a native method to retrieve the protection domain, because we  // can't add fields to java.lang.Class that are accessible from Java.  private native ProtectionDomain getProtectionDomain0();  /**   * Returns the protection domain of this class. If the classloader did not   * record the protection domain when creating this class the unknown   * protection domain is returned which has a <code>null</code> code source   * and all permissions. A security check may be performed, with   * <code>RuntimePermission("getProtectionDomain")</code>.   *   * @return the protection domain   * @throws SecurityException if the security manager exists and the caller   * does not have <code>RuntimePermission("getProtectionDomain")</code>.   * @see RuntimePermission   * @since 1.2   */  public ProtectionDomain getProtectionDomain()  {    SecurityManager sm = System.getSecurityManager();    if (sm != null)      sm.checkPermission(VMClassLoader.protectionDomainPermission);        ProtectionDomain protectionDomain = getProtectionDomain0();    if (protectionDomain == null)      return VMClassLoader.unknownProtectionDomain;    else      return protectionDomain;  }  /**   * Return the human-readable form of this Object.  For an object, this   * is either "interface " or "class " followed by <code>getName()</code>,   * for primitive types and void it is just <code>getName()</code>.   *   * @return the human-readable form of this Object   */  public String toString()  {    if (isPrimitive())      return getName();    return (isInterface() ? "interface " : "class ") + getName();  }  /**   * Returns the desired assertion status of this class, if it were to be   * initialized at this moment. The class assertion status, if set, is   * returned; the backup is the default package status; then if there is   * a class loader, that default is returned; and finally the system default   * is returned. This method seldom needs calling in user code, but exists   * for compilers to implement the assert statement. Note that there is no   * guarantee that the result of this method matches the class's actual   * assertion status.   *   * @return the desired assertion status   * @see ClassLoader#setClassAssertionStatus(String, boolean)   * @see ClassLoader#setPackageAssertionStatus(String, boolean)   * @see ClassLoader#setDefaultAssertionStatus(boolean)   * @since 1.4   */  public boolean desiredAssertionStatus()  {    ClassLoader c = getClassLoader();    Object status;    if (c == null)      return VMClassLoader.defaultAssertionStatus();    if (c.classAssertionStatus != null)      synchronized (c)        {          status = c.classAssertionStatus.get(getName());          if (status != null)            return status.equals(Boolean.TRUE);        }    else      {        status = ClassLoader.systemClassAssertionStatus.get(getName());        if (status != null)          return status.equals(Boolean.TRUE);      }    if (c.packageAssertionStatus != null)      synchronized (c)        {          String name = getPackagePortion(getName());          if ("".equals(name))            status = c.packageAssertionStatus.get(null);          else            do              {                status = c.packageAssertionStatus.get(name);                name = getPackagePortion(name);              }            while (! "".equals(name) && status == null);          if (status != null)            return status.equals(Boolean.TRUE);        }    else      {        String name = getPackagePortion(getName());        if ("".equals(name))          status = ClassLoader.systemPackageAssertionStatus.get(null);        else          do            {              status = ClassLoader.systemPackageAssertionStatus.get(name);              name = getPackagePortion(name);            }          while (! "".equals(name) && status == null);        if (status != null)          return status.equals(Boolean.TRUE);      }    return c.defaultAssertionStatus;  }  /**   * Strip the last portion of the name (after the last dot).   *   * @param name the name to get package of   * @return the package name, or "" if no package   */  private static String getPackagePortion(String name)  {    int lastInd = name.lastIndexOf('.');    if (lastInd == -1)      return "";    return name.substring(0, lastInd);  }  /**   * Perform security checks common to all of the methods that   * get members of this Class.   */  private void memberAccessCheck(int which)  {    SecurityManager sm = System.getSecurityManager();    if (sm != null)      {	sm.checkMemberAccess(this, which);	Package pkg = getPackage();	if (pkg != null)	  sm.checkPackageAccess(pkg.getName());      }  }}

⌨️ 快捷键说明

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