Browse Source

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
tags/rel_3_17_1_ga
chiba 18 years ago
parent
commit
ae4b81c820

+ 7
- 4
Readme.html View File

@@ -283,6 +283,9 @@ see javassist.Dump.

<p>-version 3.3
<ul>
<li>CtClass#getAvailableAnnotations() etc. have been implemented.
<li>A bug related to a way of dealing with a bridge method was fixed
(<a href="http://jira.jboss.com/jira/browse/HIBERNATE-37">HIBERNATE-37</a>).
<li>javassist.scopedpool package was added.
</ul>

@@ -298,11 +301,11 @@ see javassist.Dump.
<ul>
<li>A bug of replace(String,ExprEditor) in javassist.expr.Expr has been fixed.
<li>Updated ProxyFactory getClassLoader to choose the javassit class loader
when the proxy superclass has a null class loader (a jdk/endorsed class).
<a href='http://jira.jboss.com/jira/browse/JASSIST-18'>JASSIST-18</a>
when the proxy superclass has a null class loader (a jdk/endorsed class)
(<a href='http://jira.jboss.com/jira/browse/JASSIST-18'>JASSIST-18</a>).
<li>Updated the throws clause of the javassist.util.proxy.MethodHandler
to be Throwable rather than Exception.
<a href='http://jira.jboss.com/jira/browse/JASSIST-16'>JASSIST-16</a>
to be Throwable rather than Exception
(<a href='http://jira.jboss.com/jira/browse/JASSIST-16'>JASSIST-16</a>).
</ul>

<p>- version 3.2.0.CR1 on March 18, 2006

+ 14
- 4
src/main/javassist/bytecode/ClassFile.java View File

@@ -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,

+ 2
- 2
src/main/javassist/util/proxy/ProxyFactory.java View File

@@ -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)

Loading…
Cancel
Save