Browse Source

fixed JASSIST-127

git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@588 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
tags/rel_3_17_1_ga
chiba 12 years ago
parent
commit
76a1cba9c4

+ 6
- 1
Readme.html View File

@@ -281,10 +281,15 @@ see javassist.Dump.

<h2>Changes</h2>

<p>-version 3.16
<ul>
<li>JIRA JASSIST-127
</ul>

<p>-version 3.15 on July 8, 2011
<ul>
<li>The license was changed to MPL/LGPL/Apache triple.
<li>JIRA JASSIST-138 was fixed.
<li>JIRA JASSIST-138 and 142 were fixed.
</ul>

<p>-version 3.14 on October 5, 2010

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

@@ -912,7 +912,7 @@ public class ProxyFactory {
int mod = meth.getModifiers();
if (testBit(signature, index)) {
override(className, meth, prefix, index,
keyToDesc(key), cf, cp);
keyToDesc(key, meth), cf, cp);
}
index++;
}
@@ -1013,27 +1013,34 @@ public class ProxyFactory {

private static HashMap getMethods(Class superClass, Class[] interfaceTypes) {
HashMap hash = new HashMap();
HashSet set = new HashSet();
for (int i = 0; i < interfaceTypes.length; i++)
getMethods(hash, interfaceTypes[i]);
getMethods(hash, interfaceTypes[i], set);

getMethods(hash, superClass);
getMethods(hash, superClass, set);
return hash;
}

private static void getMethods(HashMap hash, Class clazz) {
private static void getMethods(HashMap hash, Class clazz, Set visitedClasses) {
// This both speeds up scanning by avoiding duplicate interfaces and is needed to
// ensure that superinterfaces are always scanned before subinterfaces.
if (!visitedClasses.add(clazz))
return;

Class[] ifs = clazz.getInterfaces();
for (int i = 0; i < ifs.length; i++)
getMethods(hash, ifs[i]);
getMethods(hash, ifs[i], visitedClasses);

Class parent = clazz.getSuperclass();
if (parent != null)
getMethods(hash, parent);
getMethods(hash, parent, visitedClasses);

Method[] methods = SecurityActions.getDeclaredMethods(clazz);
for (int i = 0; i < methods.length; i++)
if (!Modifier.isPrivate(methods[i].getModifiers())) {
Method m = methods[i];
String key = m.getName() + ':' + RuntimeSupport.makeDescriptor(m);
// JIRA JASSIST-127 (covariant return types).
String key = m.getName() + ':' + RuntimeSupport.makeDescriptor(m.getParameterTypes(), null);
// JIRA JASSIST-85
// put the method to the cache, retrieve previous definition (if any)
Method oldMethod = (Method)hash.put(key, methods[i]);
@@ -1048,8 +1055,9 @@ public class ProxyFactory {
}
}

private static String keyToDesc(String key) {
return key.substring(key.indexOf(':') + 1);
private static String keyToDesc(String key, Method m) {
String params = key.substring(key.indexOf(':') + 1);
return RuntimeSupport.makeDescriptor(params, m.getReturnType());
}

private static MethodInfo makeConstructor(String thisClassName, Constructor cons,

+ 14
- 0
src/main/javassist/util/proxy/RuntimeSupport.java View File

@@ -155,6 +155,20 @@ public class RuntimeSupport {
makeDesc(sbuf, params[i]);

sbuf.append(')');
if (retType != null)
makeDesc(sbuf, retType);

return sbuf.toString();
}

/**
* Makes a descriptor for a given method.
*
* @param params the descriptor of parameter types.
* @param retType return type.
*/
public static String makeDescriptor(String params, Class retType) {
StringBuffer sbuf = new StringBuffer(params);
makeDesc(sbuf, retType);
return sbuf.toString();
}

Loading…
Cancel
Save