diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2006-07-18 17:51:04 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2006-07-18 17:51:04 +0000 |
commit | ae4b81c8204eec47ccd579ce0ae07e808b9a8b58 (patch) | |
tree | d5d12667542435896b69ac808eca92ff0bbdd6e1 /src/main/javassist | |
parent | f19b6003aee1f59e68fc685093721ca524f35e77 (diff) | |
download | javassist-ae4b81c8204eec47ccd579ce0ae07e808b9a8b58.tar.gz javassist-ae4b81c8204eec47ccd579ce0ae07e808b9a8b58.zip |
a correct fix of HIBERNATE-37 (ProxyFactory could not handle a bridge method). Please check other JBoss products using Javassist.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@302 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist')
-rw-r--r-- | src/main/javassist/bytecode/ClassFile.java | 18 | ||||
-rw-r--r-- | src/main/javassist/util/proxy/ProxyFactory.java | 4 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/main/javassist/bytecode/ClassFile.java b/src/main/javassist/bytecode/ClassFile.java index 831a9608..5e323000 100644 --- a/src/main/javassist/bytecode/ClassFile.java +++ b/src/main/javassist/bytecode/ClassFile.java @@ -525,7 +525,7 @@ public final class ClassFile { * Appends a method to the class. */ public void addMethod(MethodInfo minfo) throws CannotCompileException { - testExistingMethod(minfo.getName(), minfo.getDescriptor()); + testExistingMethod(minfo); methods.add(minfo); } @@ -533,18 +533,28 @@ public final class ClassFile { methods.add(minfo); } - private void testExistingMethod(String name, String descriptor) - throws CannotCompileException { + private void testExistingMethod(MethodInfo newMinfo) + throws CannotCompileException + { + String name = newMinfo.getName(); + String descriptor = newMinfo.getDescriptor(); ListIterator it = methods.listIterator(0); while (it.hasNext()) { MethodInfo minfo = (MethodInfo)it.next(); if (minfo.getName().equals(name) + && notBridgeMethod(minfo) && notBridgeMethod(newMinfo) && Descriptor.eqParamTypes(minfo.getDescriptor(), - descriptor)) + descriptor)) throw new CannotCompileException("duplicate method: " + name); } } + /* For a bridge method, see Sec. 15.12.4.5 of JLS 3rd Ed. + */ + private boolean notBridgeMethod(MethodInfo minfo) { + return (minfo.getAccessFlags() & AccessFlag.BRIDGE) == 0; + } + /** * Returns all the attributes. The returned <code>List</code> object * is shared with this object. If you add a new attribute to the list, diff --git a/src/main/javassist/util/proxy/ProxyFactory.java b/src/main/javassist/util/proxy/ProxyFactory.java index 19321e61..bf29e539 100644 --- a/src/main/javassist/util/proxy/ProxyFactory.java +++ b/src/main/javassist/util/proxy/ProxyFactory.java @@ -363,6 +363,8 @@ public class ProxyFactory { else { MethodInfo delegator = makeDelegator(meth, desc, cp, declClass, delegatorName); + // delegator is not a bridge method. See Sec. 15.12.4.5 of JLS 3rd Ed. + delegator.setAccessFlags(delegator.getAccessFlags() & ~AccessFlag.BRIDGE); cf.addMethod(delegator); } @@ -417,8 +419,6 @@ public class ProxyFactory { * @param mod the modifiers of the method. */ private static boolean isVisible(int mod, String from, Member meth) { - if ((mod & Modifier.VOLATILE) != 0) - return false; if ((mod & Modifier.PRIVATE) != 0) return false; else if ((mod & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) |