]> source.dussan.org Git - javassist.git/commitdiff
fixes another bug (supporting jdk.*) reported in #228
authorchibash <chiba@javassist.org>
Thu, 6 Dec 2018 02:01:55 +0000 (11:01 +0900)
committerchibash <chiba@javassist.org>
Thu, 6 Dec 2018 02:01:55 +0000 (11:01 +0900)
Readme.html
javassist.jar
src/main/javassist/util/proxy/ProxyFactory.java
src/test/javassist/proxyfactory/ProxyFactoryTest.java

index b89b5b95087420ff45bb1c6b03ea7a2d2f959fa3..2321c42f8f803078b175fa995ffc693f653b6e58 100644 (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>
index 3099d18ac33d29a2ecb87f688f5e9c6674070fa1..359b9fe50d2ce70c7e93b8e5565114daea872ecc 100644 (file)
Binary files a/javassist.jar and b/javassist.jar differ
index 55f13059ff0998683abd3378b0d8bcf4c113c00f..ae368b2a8f1e5f34dc75d4d3bd37828824ec621b 100644 (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);
     }
index 43a96bb6ab9ec0755e891b46198d440065f7fb33..c69acc9dc75f31b8c9ff3aa05fb6311ab5118254 100644 (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);
+            }
+        });
+    }
 }