aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2008-09-18 17:32:08 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2008-09-18 17:32:08 +0000
commited449159883226a0f4627422768439f8589f00cf (patch)
tree47fd985f87ceec43f7b2baa8fa80f1b7486de717
parent1144f6066cc6433d2e9b6655302bedaa681ecbe8 (diff)
downloadjavassist-ed449159883226a0f4627422768439f8589f00cf.tar.gz
javassist-ed449159883226a0f4627422768439f8589f00cf.zip
for fixing JASSIST-66
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@458 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r--src/main/javassist/util/proxy/ProxyFactory.java33
-rw-r--r--src/main/javassist/util/proxy/RuntimeSupport.java20
2 files changed, 48 insertions, 5 deletions
diff --git a/src/main/javassist/util/proxy/ProxyFactory.java b/src/main/javassist/util/proxy/ProxyFactory.java
index 5d0c70f8..8d96cd2a 100644
--- a/src/main/javassist/util/proxy/ProxyFactory.java
+++ b/src/main/javassist/util/proxy/ProxyFactory.java
@@ -827,7 +827,7 @@ public class ProxyFactory {
/*
* if (methods[index * 2] == null) {
* methods[index * 2]
- * = RuntimeSupport.findMethod(this, <overridden name>, <desc>);
+ * = RuntimeSupport.findSuperMethod(this, <overridden name>, <desc>);
* methods[index * 2 + 1]
* = RuntimeSupport.findMethod(this, <delegator name>, <desc>);
* or = null // the original method is abstract.
@@ -840,7 +840,10 @@ public class ProxyFactory {
int arrayVar = args + 1;
code.addGetstatic(thisClassName, HOLDER, HOLDER_TYPE);
code.addAstore(arrayVar);
- code.addAload(arrayVar);
+
+ callFind2Methods(code, meth.getName(), delegatorName, origIndex, desc, arrayVar);
+
+ /* code.addAload(arrayVar);
code.addIconst(origIndex);
code.addOpcode(Opcode.AALOAD);
code.addOpcode(Opcode.IFNONNULL);
@@ -851,7 +854,8 @@ public class ProxyFactory {
callFindMethod(code, "findMethod", arrayVar, delIndex, delegatorName, desc);
int pc2 = code.currentPc();
- code.write16bit(pc, pc2 - pc + 1);
+ code.write16bit(pc, pc2 - pc + 1);*/
+
code.addAload(0);
code.addGetfield(thisClassName, HANDLER, HANDLER_TYPE);
code.addAload(0);
@@ -874,10 +878,10 @@ public class ProxyFactory {
CodeAttribute ca = code.toCodeAttribute();
forwarder.setCodeAttribute(ca);
- StackMapTable.Writer writer = new StackMapTable.Writer(32);
+ /*StackMapTable.Writer writer = new StackMapTable.Writer(32);
writer.appendFrame(pc2, new int[] { StackMapTable.OBJECT },
new int[] { cp.addClassInfo(HOLDER_TYPE) });
- ca.setAttribute(writer.toStackMapTable(cp));
+ ca.setAttribute(writer.toStackMapTable(cp));*/
return forwarder;
}
@@ -1010,6 +1014,25 @@ public class ProxyFactory {
code.addOpcode(Opcode.AASTORE);
}
+ private static void callFind2Methods(Bytecode code, String superMethod, String thisMethod,
+ int index, String desc, int arrayVar) {
+ String findClass = RuntimeSupport.class.getName();
+ String findDesc
+ = "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/reflect/Method;)V";
+
+ code.addAload(0);
+ code.addLdc(superMethod);
+ if (thisMethod == null)
+ code.addOpcode(Opcode.ACONST_NULL);
+ else
+ code.addLdc(thisMethod);
+
+ code.addIconst(index);
+ code.addLdc(desc);
+ code.addAload(arrayVar);
+ code.addInvokestatic(findClass, "find2Methods", findDesc);
+ }
+
private static void addUnwrapper(Bytecode code, Class type) {
if (type.isPrimitive()) {
if (type == Void.TYPE)
diff --git a/src/main/javassist/util/proxy/RuntimeSupport.java b/src/main/javassist/util/proxy/RuntimeSupport.java
index f647fce5..79251a9c 100644
--- a/src/main/javassist/util/proxy/RuntimeSupport.java
+++ b/src/main/javassist/util/proxy/RuntimeSupport.java
@@ -39,6 +39,26 @@ public class RuntimeSupport {
};
/**
+ * Finds two methods specified by the parameters and stores them
+ * into the given array.
+ *
+ * @throws RuntimeException if the methods are not found.
+ * @see javassist.util.proxy.ProxyFactory
+ */
+ public static void find2Methods(Object self, String superMethod,
+ String thisMethod, int index,
+ String desc, java.lang.reflect.Method[] methods)
+ {
+ synchronized (methods) {
+ if (methods[index] == null) {
+ methods[index + 1] = thisMethod == null ? null
+ : findMethod(self, thisMethod, desc);
+ methods[index] = findSuperMethod(self, superMethod, desc);
+ }
+ }
+ }
+
+ /**
* Finds a method with the given name and descriptor.
* It searches only the class of self.
*