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

📄 classloader.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 4 页
字号:
 <li> Call the <code>loadClass</code> method on the parent class      loader.  If the parent is <code>null</code> the class loader      built-in to the virtual machine is used, instead. <p> <li> Call the <A HREF="../../java/lang/ClassLoader.html#findClass(java.lang.String)"><CODE>findClass(String)</CODE></A> method to find the class. <p> </ol> If the class was found using the above steps, and the <code>resolve</code> flag is true, this method will then call the <A HREF="../../java/lang/ClassLoader.html#resolveClass(java.lang.Class)"><CODE>resolveClass(Class)</CODE></A> method on the resulting class object. <p> From the Java 2 SDK, v1.2, subclasses of ClassLoader are  encouraged to override <A HREF="../../java/lang/ClassLoader.html#findClass(java.lang.String)"><CODE>findClass(String)</CODE></A>, rather than this method.<p><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the class<DD><CODE>resolve</CODE> - if <code>true</code> then resolve the class<DT><B>Returns:</B><DD>the resulting <code>Class</code> object<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A></CODE> - if the class could not be found</DL></DD></DL><HR><A NAME="findClass(java.lang.String)"><!-- --></A><H3>findClass</H3><PRE>protected <A HREF="../../java/lang/Class.html">Class</A> <B>findClass</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;name)                   throws <A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A></PRE><DL><DD>Finds the specified class. This method should be overridden by class loader implementations that follow the new delegation model for loading classes, and will be called by the <code>loadClass</code> method after checking the parent class loader for the requested class. The default implementation throws <code>ClassNotFoundException</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the class<DT><B>Returns:</B><DD>the resulting <code>Class</code> object<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A></CODE> - if the class could not be found<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="defineClass(byte[], int, int)"><!-- --></A><H3>defineClass</H3><PRE>protected final <A HREF="../../java/lang/Class.html">Class</A> <B>defineClass</B>(byte[]&nbsp;b,                                  int&nbsp;off,                                  int&nbsp;len)                           throws <A HREF="../../java/lang/ClassFormatError.html">ClassFormatError</A></PRE><DL><DD><B>Deprecated.</B>&nbsp;<I>Replaced by defineClass(java.lang.String, byte[], int, int)</I><P><DD>Converts an array of bytes into an instance of class <code>Class</code>.  Before the Class can be used it must be resolved. This method is deprecated in favor of the version that takes the class name as its first argument, and is more secure.<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the bytes that make up the class data. The bytes in              positions <code>off</code> through <code>off+len-1</code>              should have the format of a valid class file as defined              by the              <a href="http://java.sun.com/docs/books/vmspec/">Java              Virtual Machine Specification</a>.<DD><CODE>off</CODE> - the start offset of the class data<DD><CODE>len</CODE> - the length of the class data<DT><B>Returns:</B><DD>the <code>Class</code> object that was created from the             specified class data<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassFormatError.html">ClassFormatError</A></CODE> - if the data did not contain a valid class<DT><B>See Also: </B><DD><A HREF="../../java/lang/ClassLoader.html#loadClass(java.lang.String, boolean)"><CODE>loadClass(java.lang.String, boolean)</CODE></A>, <A HREF="../../java/lang/ClassLoader.html#resolveClass(java.lang.Class)"><CODE>resolveClass(java.lang.Class)</CODE></A></DL></DD></DL><HR><A NAME="defineClass(java.lang.String, byte[], int, int)"><!-- --></A><H3>defineClass</H3><PRE>protected final <A HREF="../../java/lang/Class.html">Class</A> <B>defineClass</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;name,                                  byte[]&nbsp;b,                                  int&nbsp;off,                                  int&nbsp;len)                           throws <A HREF="../../java/lang/ClassFormatError.html">ClassFormatError</A></PRE><DL><DD>Converts an array of bytes into an instance of class <code>Class</code>. Before the Class can be used it must be resolved. <p> This method assigns a default <code>ProtectionDomain</code> to  the newly defined class. The <code>ProtectionDomain</code>  contains the set of permissions granted when a call to <code>Policy.getPolicy().getPermissions()</code> is made with a Codesource of <code>null,null</code>. The default domain is  created on the first invocation of <code>defineClass</code>, and re-used on subsequent calls. <p> To assign a specific <code>ProtectionDomain</code> to the class, use the <code>defineClass</code> method that takes a  <code>ProtectionDomain</code> as one of its arguments.<DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the expected name of the class, or <code>null</code>                  if not known, using '.' and not '/' as the separator                  and without a trailing ".class" suffix.<DD><CODE>b</CODE> - the bytes that make up the class data. The bytes in              positions <code>off</code> through <code>off+len-1</code>              should have the format of a valid class file as defined              by the              <a href="http://java.sun.com/docs/books/vmspec/">Java              Virtual Machine Specification</a>.<DD><CODE>off</CODE> - the start offset of the class data<DD><CODE>len</CODE> - the length of the class data<DT><B>Returns:</B><DD>the <code>Class</code> object that was created from the             specified class data<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassFormatError.html">ClassFormatError</A></CODE> - if the data did not contain a valid class<DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if either <code>off</code> or              <code>len</code> is negative, or if              <code>off+len</code> is greater than <code>b.length</code>.<DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if an attempt is made to add this class             to a package that contains classes that were signed by             a different set of certificates then this class, which             is unsigned.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/ClassLoader.html#loadClass(java.lang.String, boolean)"><CODE>loadClass(java.lang.String, boolean)</CODE></A>, <A HREF="../../java/lang/ClassLoader.html#resolveClass(java.lang.Class)"><CODE>resolveClass(java.lang.Class)</CODE></A>, <A HREF="../../java/security/ProtectionDomain.html"><CODE>ProtectionDomain</CODE></A>, <A HREF="../../java/security/Policy.html"><CODE>Policy</CODE></A>, <A HREF="../../java/security/CodeSource.html"><CODE>CodeSource</CODE></A>, <A HREF="../../java/security/SecureClassLoader.html"><CODE>SecureClassLoader</CODE></A></DL></DD></DL><HR><A NAME="defineClass(java.lang.String, byte[], int, int, java.security.ProtectionDomain)"><!-- --></A><H3>defineClass</H3><PRE>protected final <A HREF="../../java/lang/Class.html">Class</A> <B>defineClass</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;name,                                  byte[]&nbsp;b,                                  int&nbsp;off,                                  int&nbsp;len,                                  <A HREF="../../java/security/ProtectionDomain.html">ProtectionDomain</A>&nbsp;protectionDomain)                           throws <A HREF="../../java/lang/ClassFormatError.html">ClassFormatError</A></PRE><DL><DD>Converts an array of bytes into an instance of class Class, with an optional ProtectionDomain. If the domain is <code>null</code>, then a default domain will be assigned to the class as specified in the documentation for <A HREF="../../java/lang/ClassLoader.html#defineClass(java.lang.String, byte[], int, int)"><CODE>defineClass(String,byte[],int,int)</CODE></A>. Before the class can be used it must be resolved. <p>The first class defined in a package determines the exact set of certificates that all subsequent classes defined in that package must contain. The set of certificates for a class is obtained from the  <code>CodeSource</code> within the <code>ProtectionDomain</code> of the class. Any classes added to that package must contain the same set of certificates or a <code>SecurityException</code> will be thrown. Note that if the <code>name</code> argument is null, this check is not performed. You should always pass in the name of the class you are defining as well as the bytes. This ensures that the class you are defining is indeed the class you think it is. <p>The specified class name cannot begin with "java.", since all  classes in the java.* packages can only be defined by the bootstrap  class loader.<DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the class<DD><CODE>b</CODE> - the class bytes<DD><CODE>off</CODE> - the start offset of the class bytes<DD><CODE>len</CODE> - the length of the class bytes<DD><CODE>protectionDomain</CODE> - the ProtectionDomain of the class<DT><B>Returns:</B><DD>the <code>Class</code> object created from the data,         and optional ProtectionDomain.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassFormatError.html">ClassFormatError</A></CODE> - if the data did not contain a valid class<DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if either <code>off</code> or              <code>len</code> is negative, or if              <code>off+len</code> is greater than <code>b.length</code>.<DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if an attempt is made to add this class             to a package that contains classes that were signed by             a different set of certificates than this class, or if              the class name begins with "java.".</DL></DD></DL><HR><A NAME="resolveClass(java.lang.Class)"><!-- --></A><H3>resolveClass</H3><PRE>protected final void <B>resolveClass</B>(<A HREF="../../java/lang/Class.html">Class</A>&nbsp;c)</PRE><DL><DD>Links the specified class.  This (misleadingly named) method may be used by a class loader to  link a class. If the class <code>c</code> has already been linked,  then this method simply returns. Otherwise, the class is linked  as described in the "Execution" chapter of the <i>Java Language  Specification</i>.<DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - the class to link<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if <code>c</code> is <code>null</code>.<DT><B>See Also: </B><DD><A HREF="../../java/lang/ClassLoader.html#defineClass(java.lang.String, byte[], int, int)"><CODE>defineClass(java.lang.String,byte[],int,int)</CODE></A></DL></DD></DL><HR><A NAME="findSystemClass(java.lang.String)"><!-- --></A><H3>findSystemClass</H3><PRE>protected final <A HREF="../../java/lang/Class.html">Class</A> <B>findSystemClass</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;name)                               throws <A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A></PRE><DL><DD>Finds a class with the specified name, loading it if necessary.<p> Prior to the Java 2 SDK, this method loads a class from the local file system in a platform-dependent manner, and returns a class object that has no associated class loader.<p> Since the Java 2 SDK v1.2, this method loads the class through the system class loader(see <A HREF="../../java/lang/ClassLoader.html#getSystemClassLoader()"><CODE>getSystemClassLoader()</CODE></A>).  Class objects returned might have <code>ClassLoader</code>s associated with them. Subclasses of <code>ClassLoader</code> need not usually call this method, because most class loaders need to override just <A HREF="../../java/lang/ClassLoader.html#findClass(java.lang.String)"><CODE>findClass(String)</CODE></A>.<p><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the class that is to be found<DT><B>Returns:</B><DD>the <code>Class</code> object for the specified <code>name</code><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A></CODE> - if the class could not be found<DT><B>See Also: </B><DD><A HREF="../../java/lang/ClassLoader.html#ClassLoader(java.lang.ClassLoader)"><CODE>ClassLoader(ClassLoader)</CODE></A>, <A HREF="../../java/lang/ClassLoader.html#getParent()"><CODE>getParent()</CODE></A></DL></DD></DL><HR><A NAME="getParent()"><!-- --></A><H3>getParent</H3><PRE>public final <A HREF="../../java/lang/ClassLoader.html">ClassLoader</A> <B>getParent</B>()</PRE><DL><DD>Returns the parent class loader for delegation. Some implementations  may use <code>null</code> to represent the bootstrap class  loader. This method will return <code>null</code> in such  implementations if this class loader's parent is the bootstrap  class loader.  <p> If a security manager is present, and the caller's class loader is not null and is not an ancestor of this class loader, then this method calls the security manager's <code>checkPermission</code>  method with a <code>RuntimePermission("getClassLoader")</code>  permission to ensure it's ok to access the parent class loader. If not, a <code>SecurityException</code> will be thrown.<DD><DL><DT><B>Returns:</B><DD>the parent <code>ClassLoader</code><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if a security manager exists and its     <code>checkPermission</code> method doesn't allow    access to this class loader's parent class loader.<DT><B>Since: </B><DD>1.2</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/SecurityManager.html#checkPermission(java.security.Permission)"><CODE>SecurityManager.checkPermission(java.security.Permission)</CODE></A>, <A HREF="../../java/lang/RuntimePermission.html"><CODE>RuntimePermission</CODE></A></DL></DD></DL><HR><A NAME="setSigners(java.lang.Class, java.lang.Object[])"><!-- --></A><H3>setSigners</H3><PRE>protected final void <B>setSigners</B>(<A HREF="../../java/lang/Class.html">Class</A>&nbsp;c,                                <A HREF="../../java/lang/Object.html">Object</A>[]&nbsp;signers)</PRE><DL><DD>Sets the signers of a class. This should be called after defining a class.<DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - the <code>Class</code> object<DD><CODE>signers</CODE> - the signers for the class<DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="findLoadedClass(java.lang.String)"><!-- --></A><H3>findLoadedClass</H3><PRE>protected final <A HREF="../../java/lang/Class.html">Class</A> <B>findLoadedClass</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;name)</PRE><DL><DD>Finds the class with the given name if it had been previously loaded through this class loader.<DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the class name<DT><B>Returns:</B><DD>the <code>Class</code> object, or <code>null</code> if         the class has not been loaded<DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="getResource(java.lang.String)"><!-- --></A><H3>getResource</H3><PRE>public <A HREF="../../java/net/URL.html">URL</A> <B>getResource</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;name)</PRE><DL><DD>Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.<p> The name of a resource is a "/"-separated path name that identifies the resource.<p> This method will first search the parent class loader for the resource; if the parent is <code>null</code> the path of the class loader built-in to the virtual machine is searched.  That failing, this method will call <code>findResource</code> to find the resource.<p><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - resource name<DT><B>Returns:</B><DD>a URL for reading the resource, or <code>null</code> if         the resource could not be found or the caller doesn't have         adequate privileges to get the resource.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/ClassLoader.html#findResource(java.lang.String)"><CODE>findResource(String)</CODE></A></DL></DD></DL><HR>

⌨️ 快捷键说明

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