📄 proxy.html
字号:
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="getProxyClass(java.lang.ClassLoader, java.lang.Class[])"><!-- --></A><H3>getProxyClass</H3><PRE>public static <A HREF="../../../java/lang/Class.html">Class</A> <B>getProxyClass</B>(<A HREF="../../../java/lang/ClassLoader.html">ClassLoader</A> loader, <A HREF="../../../java/lang/Class.html">Class</A>[] interfaces) throws <A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></PRE><DL><DD>Returns the <code>java.lang.Class</code> object for a proxy class given a class loader and an array of interfaces. The proxy class will be defined in the specified class loader and will implement all of the supplied interfaces. If a proxy class for the same permutation of interfaces has already been defined in the class loader, then the existing proxy class will be returned; otherwise, a proxy class for those interfaces will be generated dynamically and defined in the class loader. <p>There are several restrictions on the parameters that may be passed to <code>Proxy.getProxyClass</code>: <ul> <li>All of the <code>Class</code> objects in the <code>interfaces</code> array must represent interfaces, not classes or primitive types. <li>No two elements in the <code>interfaces</code> array may refer to identical <code>Class</code> objects. <li>All of the interface types must be visible by name through the specified class loader. In other words, for class loader <code>cl</code> and every interface <code>i</code>, the following expression must be true: <pre> Class.forName(i.getName(), false, cl) == i </pre> <li>All non-public interfaces must be in the same package; otherwise, it would not be possible for the proxy class to implement all of the interfaces, regardless of what package it is defined in. <li>No two interfaces may each have a method with the same name and parameter signature but different return type. <li>The resulting proxy class must not exceed any limits imposed on classes by the virtual machine. For example, the VM may limit the number of interfaces that a class may implement to 65535; in that case, the size of the <code>interfaces</code> array must not exceed 65535. </ul> <p>If any of these restrictions are violated, <code>Proxy.getProxyClass</code> will throw an <code>IllegalArgumentException</code>. If the <code>interfaces</code> array argument or any of its elements are <code>null</code>, a <code>NullPointerException</code> will be thrown. <p>Note that the order of the specified proxy interfaces is significant: two requests for a proxy class with the same combination of interfaces but in a different order will result in two distinct proxy classes.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>loader</CODE> - the class loader to define the proxy class in<DD><CODE>interfaces</CODE> - the list of interfaces for the proxy class to implement<DT><B>Returns:</B><DD>a proxy class that is defined in the specified class loader and that implements the specified interfaces<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if any of the restrictions on the parameters that may be passed to <code>getProxyClass</code> are violated<DD><CODE><A HREF="../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if the <code>interfaces</code> array argument or any of its elements are <code>null</code></DL></DD></DL><HR><A NAME="newProxyInstance(java.lang.ClassLoader, java.lang.Class[], java.lang.reflect.InvocationHandler)"><!-- --></A><H3>newProxyInstance</H3><PRE>public static <A HREF="../../../java/lang/Object.html">Object</A> <B>newProxyInstance</B>(<A HREF="../../../java/lang/ClassLoader.html">ClassLoader</A> loader, <A HREF="../../../java/lang/Class.html">Class</A>[] interfaces, <A HREF="../../../java/lang/reflect/InvocationHandler.html">InvocationHandler</A> h) throws <A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></PRE><DL><DD>Returns an instance of a proxy class for the specified interfaces that dispatches method invocations to the specified invocation handler. This method is equivalent to: <pre> Proxy.getProxyClass(loader, interfaces). getConstructor(new Class[] { InvocationHandler.class }). newInstance(new Object[] { handler }); </pre> <p><code>Proxy.newProxyInstance</code> throws <code>IllegalArgumentException</code> for the same reasons that <code>Proxy.getProxyClass</code> does.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>loader</CODE> - the class loader to define the proxy class in<DD><CODE>interfaces</CODE> - the list of interfaces for the proxy class to implement<DD><CODE>h</CODE> - the invocation handler to dispatch method invocations to<DT><B>Returns:</B><DD>a proxy instance with the specified invocation handler of a proxy class that is defined in the specified class loader and that implements the specified interfaces<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if any of the restrictions on the parameters that may be passed to <code>getProxyClass</code> are violated<DD><CODE><A HREF="../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if the <code>interfaces</code> array argument or any of its elements are <code>null</code>, or if the invocation handler, <code>h</code>, is <code>null</code></DL></DD></DL><HR><A NAME="isProxyClass(java.lang.Class)"><!-- --></A><H3>isProxyClass</H3><PRE>public static boolean <B>isProxyClass</B>(<A HREF="../../../java/lang/Class.html">Class</A> cl)</PRE><DL><DD>Returns true if and only if the specified class was dynamically generated to be a proxy class using the <code>getProxyClass</code> method or the <code>newProxyInstance</code> method. <p>The reliability of this method is important for the ability to use it to make security decisions, so its implementation should not just test if the class in question extends <code>Proxy</code>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>cl</CODE> - the class to test<DT><B>Returns:</B><DD><code>true</code> if the class is a proxy class and <code>false</code> otherwise<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if <code>cl</code> is <code>null</code></DL></DD></DL><HR><A NAME="getInvocationHandler(java.lang.Object)"><!-- --></A><H3>getInvocationHandler</H3><PRE>public static <A HREF="../../../java/lang/reflect/InvocationHandler.html">InvocationHandler</A> <B>getInvocationHandler</B>(<A HREF="../../../java/lang/Object.html">Object</A> proxy) throws <A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></PRE><DL><DD>Returns the invocation handler for the specified proxy instance.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>proxy</CODE> - the proxy instance to return the invocation handler for<DT><B>Returns:</B><DD>the invocation handler for the proxy instance<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the argument is not a proxy instance</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Proxy.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../java/lang/reflect/Modifier.html"><B>PREV CLASS</B></A> <A HREF="../../../java/lang/reflect/ReflectPermission.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Proxy.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -