[jboss-cvs] javassist/src/main/javassist/util/proxy ...
Shigeru Chiba
chiba at is.titech.ac.jp
Tue Oct 31 21:45:05 EST 2006
User: chiba
Date: 06/10/31 21:45:05
Modified: src/main/javassist/util/proxy ProxyFactory.java
FactoryHelper.java
Log:
fixed JIRA JASSIST-28?
Revision Changes Path
1.17 +5 -2 javassist/src/main/javassist/util/proxy/ProxyFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ProxyFactory.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/util/proxy/ProxyFactory.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- ProxyFactory.java 29 Oct 2006 23:33:15 -0000 1.16
+++ ProxyFactory.java 1 Nov 2006 02:45:05 -0000 1.17
@@ -309,6 +309,10 @@
private static int counter = 0;
+ private static synchronized String makeProxyName(String classname) {
+ return classname + "_$$_javassist_" + counter++;
+ }
+
private ClassFile make() throws CannotCompileException {
String superName, classname;
if (interfaces == null)
@@ -328,8 +332,7 @@
if (Modifier.isFinal(superClass.getModifiers()))
throw new CannotCompileException(superName + " is final");
- // generate a proxy name.
- classname = classname + "_$$_javassist_" + counter++;
+ classname = makeProxyName(classname);
if (classname.startsWith("java."))
classname = "org.javassist.tmp." + classname;
1.5 +13 -5 javassist/src/main/javassist/util/proxy/FactoryHelper.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FactoryHelper.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/util/proxy/FactoryHelper.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- FactoryHelper.java 14 Aug 2006 14:48:47 -0000 1.4
+++ FactoryHelper.java 1 Nov 2006 02:45:05 -0000 1.5
@@ -15,6 +15,7 @@
package javassist.util.proxy;
+import java.lang.reflect.Method;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
@@ -142,7 +143,7 @@
{
try {
byte[] b = toBytecode(cf);
- java.lang.reflect.Method method;
+ Method method;
Object[] args;
if (domain == null) {
method = defineClass1;
@@ -155,10 +156,7 @@
new Integer(b.length), domain };
}
- method.setAccessible(true);
- Class clazz = (Class)method.invoke(loader, args);
- method.setAccessible(false);
- return clazz;
+ return toClass2(method, loader, args);
}
catch (RuntimeException e) {
throw e;
@@ -171,6 +169,16 @@
}
}
+ private static synchronized Class toClass2(Method method,
+ ClassLoader loader, Object[] args)
+ throws Exception
+ {
+ method.setAccessible(true);
+ Class clazz = (Class)method.invoke(loader, args);
+ method.setAccessible(false);
+ return clazz;
+ }
+
private static byte[] toBytecode(ClassFile cf) throws IOException {
ByteArrayOutputStream barray = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(barray);
More information about the jboss-cvs-commits
mailing list