6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.misc;
27
28 import java.io.ByteArrayOutputStream;
29 import java.io.DataOutputStream;
30 import java.io.File;
31 import java.io.IOException;
32 import java.io.OutputStream;
33 import java.lang.reflect.Array;
34 import java.lang.reflect.Method;
35 import java.nio.file.Files;
36 import java.nio.file.Path;
37 import java.nio.file.Paths;
38 import java.util.ArrayList;
39 import java.util.HashMap;
40 import java.util.LinkedList;
41 import java.util.List;
42 import java.util.ListIterator;
43 import java.util.Map;
44 import sun.security.action.GetBooleanAction;
45
46 /**
297 // private static final int opc_monitorexit = 195;
298 private static final int opc_wide = 196;
299 // private static final int opc_multianewarray = 197;
300 // private static final int opc_ifnull = 198;
301 // private static final int opc_ifnonnull = 199;
302 // private static final int opc_goto_w = 200;
303 // private static final int opc_jsr_w = 201;
304
305 // end of constants copied from sun.tools.java.RuntimeConstants
306
307 /** name of the superclass of proxy classes */
308 private static final String superclassName = "java/lang/reflect/Proxy";
309
310 /** name of field for storing a proxy instance's invocation handler */
311 private static final String handlerFieldName = "h";
312
313 /** debugging flag for saving generated class files */
314 private static final boolean saveGeneratedFiles =
315 java.security.AccessController.doPrivileged(
316 new GetBooleanAction(
317 "sun.misc.ProxyGenerator.saveGeneratedFiles")).booleanValue();
318
319 /**
320 * Generate a public proxy class given a name and a list of proxy interfaces.
321 */
322 public static byte[] generateProxyClass(final String name,
323 Class<?>[] interfaces) {
324 return generateProxyClass(name, interfaces, (ACC_PUBLIC | ACC_FINAL | ACC_SUPER));
325 }
326
327 /**
328 * Generate a proxy class given a name and a list of proxy interfaces.
329 *
330 * @param name the class name of the proxy class
331 * @param interfaces proxy interfaces
332 * @param accessFlags access flags of the proxy class
333 */
334 public static byte[] generateProxyClass(final String name,
335 Class<?>[] interfaces,
336 int accessFlags)
337 {
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.internal.reflect;
27
28 import java.io.ByteArrayOutputStream;
29 import java.io.DataOutputStream;
30 import java.io.File;
31 import java.io.IOException;
32 import java.io.OutputStream;
33 import java.lang.reflect.Array;
34 import java.lang.reflect.Method;
35 import java.nio.file.Files;
36 import java.nio.file.Path;
37 import java.nio.file.Paths;
38 import java.util.ArrayList;
39 import java.util.HashMap;
40 import java.util.LinkedList;
41 import java.util.List;
42 import java.util.ListIterator;
43 import java.util.Map;
44 import sun.security.action.GetBooleanAction;
45
46 /**
297 // private static final int opc_monitorexit = 195;
298 private static final int opc_wide = 196;
299 // private static final int opc_multianewarray = 197;
300 // private static final int opc_ifnull = 198;
301 // private static final int opc_ifnonnull = 199;
302 // private static final int opc_goto_w = 200;
303 // private static final int opc_jsr_w = 201;
304
305 // end of constants copied from sun.tools.java.RuntimeConstants
306
307 /** name of the superclass of proxy classes */
308 private static final String superclassName = "java/lang/reflect/Proxy";
309
310 /** name of field for storing a proxy instance's invocation handler */
311 private static final String handlerFieldName = "h";
312
313 /** debugging flag for saving generated class files */
314 private static final boolean saveGeneratedFiles =
315 java.security.AccessController.doPrivileged(
316 new GetBooleanAction(
317 "jdk.internal.reflect.ProxyGenerator.saveGeneratedFiles")).booleanValue();
318
319 /**
320 * Generate a public proxy class given a name and a list of proxy interfaces.
321 */
322 public static byte[] generateProxyClass(final String name,
323 Class<?>[] interfaces) {
324 return generateProxyClass(name, interfaces, (ACC_PUBLIC | ACC_FINAL | ACC_SUPER));
325 }
326
327 /**
328 * Generate a proxy class given a name and a list of proxy interfaces.
329 *
330 * @param name the class name of the proxy class
331 * @param interfaces proxy interfaces
332 * @param accessFlags access flags of the proxy class
333 */
334 public static byte[] generateProxyClass(final String name,
335 Class<?>[] interfaces,
336 int accessFlags)
337 {
|