Browse Source

fixes another bug (supporting jdk.*) reported in #228

tags/rel_3_24_1_ga
chibash 5 years ago
parent
commit
9cfa81cce0

+ 7
- 1
Readme.html View File

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

<h2>Changes</h2>

<p>-version 3.25
<ul>
<li>GitHub Issue #228</li>
<ul>
</p>

<p>-version 3.24 on November 1, 2018
<ul>
<li>Java 11 supports.</li>
<li>Java 11 supports.</li>
<li>JIRA JASSIST-267.</li>
<li>Github PR #218.</li>
</ul>

BIN
javassist.jar View File


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

@@ -622,7 +622,7 @@ public class ProxyFactory {
* {@code java.lang.invoke.MethodHandles.Lookup}.
*/
private Class<?> getClassInTheSamePackage() {
if (basename.startsWith("javassist.util.proxy.")) // maybe the super class is java.*
if (basename.startsWith(packageForJavaBase)) // maybe the super class is java.*
return this.getClass();
else if (superClass != null && superClass != OBJECT_TYPE)
return superClass;
@@ -921,10 +921,15 @@ public class ProxyFactory {
if (Modifier.isFinal(superClass.getModifiers()))
throw new RuntimeException(superName + " is final");

if (basename.startsWith("java.") || onlyPublicMethods)
basename = "javassist.util.proxy." + basename.replace('.', '_');
// Since java.base module is not opened, its proxy class should be
// in a different (open) module. Otherwise, it could not be created
// by reflection.
if (basename.startsWith("java.") || basename.startsWith("jdk.") || onlyPublicMethods)
basename = packageForJavaBase + basename.replace('.', '_');
}

private static final String packageForJavaBase = "javassist.util.proxy.";

private void allocateClassName() {
classname = makeProxyName(basename);
}

+ 12
- 0
src/test/javassist/proxyfactory/ProxyFactoryTest.java View File

@@ -140,4 +140,16 @@ public class ProxyFactoryTest extends TestCase {
}
});
}

public void testJava11jdk() throws Exception {
ProxyFactory factory = new ProxyFactory();
factory.setSuperclass(jdk.javadoc.doclet.StandardDoclet.class);
jdk.javadoc.doclet.StandardDoclet e = (jdk.javadoc.doclet.StandardDoclet)factory.create(null, null, new MethodHandler() {
@Override
public Object invoke(Object self, Method thisMethod,
Method proceed, Object[] args) throws Throwable {
return proceed.invoke(self, args);
}
});
}
}

Loading…
Cancel
Save