< prev index next >
src/java.base/share/classes/java/lang/reflect/ProxyGenerator_v49.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 28,43 ****
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
- import java.lang.reflect.Array;
- import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import sun.security.action.GetBooleanAction;
--- 28,42 ----
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
+ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import sun.security.action.GetBooleanAction;
*** 50,60 ****
* "generateProxyClass" method.
*
* @author Peter Jones
* @since 1.3
*/
! class ProxyGenerator {
/*
* In the comments below, "JVMS" refers to The Java Virtual Machine
* Specification Second Edition and "JLS" refers to the original
* version of The Java Language Specification, unless otherwise
* specified.
--- 49,59 ----
* "generateProxyClass" method.
*
* @author Peter Jones
* @since 1.3
*/
! class ProxyGenerator_v49 {
/*
* In the comments below, "JVMS" refers to The Java Virtual Machine
* Specification Second Edition and "JLS" refers to the original
* version of The Java Language Specification, unless otherwise
* specified.
*** 317,327 ****
/**
* Generate a public proxy class given a name and a list of proxy interfaces.
*/
static byte[] generateProxyClass(final String name,
! Class<?>[] interfaces) {
return generateProxyClass(name, interfaces, (ACC_PUBLIC | ACC_FINAL | ACC_SUPER));
}
/**
* Generate a proxy class given a name and a list of proxy interfaces.
--- 316,326 ----
/**
* Generate a public proxy class given a name and a list of proxy interfaces.
*/
static byte[] generateProxyClass(final String name,
! List<Class<?>> interfaces) {
return generateProxyClass(name, interfaces, (ACC_PUBLIC | ACC_FINAL | ACC_SUPER));
}
/**
* Generate a proxy class given a name and a list of proxy interfaces.
*** 329,342 ****
* @param name the class name of the proxy class
* @param interfaces proxy interfaces
* @param accessFlags access flags of the proxy class
*/
static byte[] generateProxyClass(final String name,
! Class<?>[] interfaces,
int accessFlags)
{
! ProxyGenerator gen = new ProxyGenerator(name, interfaces, accessFlags);
final byte[] classFile = gen.generateClassFile();
if (saveGeneratedFiles) {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
--- 328,341 ----
* @param name the class name of the proxy class
* @param interfaces proxy interfaces
* @param accessFlags access flags of the proxy class
*/
static byte[] generateProxyClass(final String name,
! List<Class<?>> interfaces,
int accessFlags)
{
! ProxyGenerator_v49 gen = new ProxyGenerator_v49(name, interfaces, accessFlags);
final byte[] classFile = gen.generateClassFile();
if (saveGeneratedFiles) {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
*** 381,391 ****
/** name of proxy class */
private String className;
/** proxy interfaces */
! private Class<?>[] interfaces;
/** proxy class access flags */
private int accessFlags;
/** constant pool of class being generated */
--- 380,390 ----
/** name of proxy class */
private String className;
/** proxy interfaces */
! private List<Class<?>> interfaces;
/** proxy class access flags */
private int accessFlags;
/** constant pool of class being generated */
*** 399,409 ****
/**
* maps method signature string to list of ProxyMethod objects for
* proxy methods with that signature
*/
! private Map<String, List<ProxyMethod>> proxyMethods = new HashMap<>();
/** count of ProxyMethod objects added to proxyMethods */
private int proxyMethodCount = 0;
/**
--- 398,408 ----
/**
* maps method signature string to list of ProxyMethod objects for
* proxy methods with that signature
*/
! private Map<String, List<ProxyMethod>> proxyMethods = new LinkedHashMap<>();
/** count of ProxyMethod objects added to proxyMethods */
private int proxyMethodCount = 0;
/**
*** 411,421 ****
* specified name and for the given interfaces.
*
* A ProxyGenerator object contains the state for the ongoing
* generation of a particular proxy class.
*/
! private ProxyGenerator(String className, Class<?>[] interfaces, int accessFlags) {
this.className = className;
this.interfaces = interfaces;
this.accessFlags = accessFlags;
}
--- 410,420 ----
* specified name and for the given interfaces.
*
* A ProxyGenerator object contains the state for the ongoing
* generation of a particular proxy class.
*/
! ProxyGenerator_v49(String className, List<Class<?>> interfaces, int accessFlags) {
this.className = className;
this.interfaces = interfaces;
this.accessFlags = accessFlags;
}
*** 538,548 ****
dout.writeShort(cp.getClass(dotToSlash(className)));
// u2 super_class;
dout.writeShort(cp.getClass(superclassName));
// u2 interfaces_count;
! dout.writeShort(interfaces.length);
// u2 interfaces[interfaces_count];
for (Class<?> intf : interfaces) {
dout.writeShort(cp.getClass(
dotToSlash(intf.getName())));
}
--- 537,547 ----
dout.writeShort(cp.getClass(dotToSlash(className)));
// u2 super_class;
dout.writeShort(cp.getClass(superclassName));
// u2 interfaces_count;
! dout.writeShort(interfaces.size());
// u2 interfaces[interfaces_count];
for (Class<?> intf : interfaces) {
dout.writeShort(cp.getClass(
dotToSlash(intf.getName())));
}
< prev index next >