]> source.dussan.org Git - javassist.git/commitdiff
fixes a bug reported in #228
authorchibash <chiba@javassist.org>
Tue, 4 Dec 2018 15:19:56 +0000 (00:19 +0900)
committerchibash <chiba@javassist.org>
Tue, 4 Dec 2018 15:19:56 +0000 (00:19 +0900)
javassist.jar
src/main/javassist/util/proxy/ProxyFactory.java
src/test/javassist/proxyfactory/ProxyFactoryTest.java

index a478100287e7ddae924a22ddb401a439c3fea45a..3099d18ac33d29a2ecb87f688f5e9c6674070fa1 100644 (file)
Binary files a/javassist.jar and b/javassist.jar differ
index 0c39a508ce9a88d7eb091539780769824f2e8807..55f13059ff0998683abd3378b0d8bcf4c113c00f 100644 (file)
@@ -622,7 +622,9 @@ public class ProxyFactory {
      * {@code java.lang.invoke.MethodHandles.Lookup}.
      */
     private Class<?> getClassInTheSamePackage() {
-        if (superClass != null && superClass != OBJECT_TYPE)
+        if (basename.startsWith("javassist.util.proxy."))       // maybe the super class is java.*
+            return this.getClass();
+        else if (superClass != null && superClass != OBJECT_TYPE)
             return superClass;
         else if (interfaces != null && interfaces.length > 0)
             return interfaces[0];
index 3189b568250e7b541bddb39c262338dda46cc100..43a96bb6ab9ec0755e891b46198d440065f7fb33 100644 (file)
@@ -128,4 +128,16 @@ public class ProxyFactoryTest extends TestCase {
     public static class TestDefaultC2 extends TestDefaultC {
         public int baz() { return super.foo(); }
     }
+
+    public void testJava11() throws Exception {
+        ProxyFactory factory = new ProxyFactory();
+        factory.setSuperclass(java.util.HashMap.class);
+        java.util.HashMap e = (java.util.HashMap)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);
+            }
+        });
+    }
 }