From: chibash Date: Tue, 4 Dec 2018 15:19:56 +0000 (+0900) Subject: fixes a bug reported in #228 X-Git-Tag: rel_3_24_1_ga~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a82e2d71bd3da248dab836f4e150ff08cc0e6915;p=javassist.git fixes a bug reported in #228 --- diff --git a/javassist.jar b/javassist.jar index a4781002..3099d18a 100644 Binary files a/javassist.jar and b/javassist.jar differ diff --git a/src/main/javassist/util/proxy/ProxyFactory.java b/src/main/javassist/util/proxy/ProxyFactory.java index 0c39a508..55f13059 100644 --- a/src/main/javassist/util/proxy/ProxyFactory.java +++ b/src/main/javassist/util/proxy/ProxyFactory.java @@ -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]; diff --git a/src/test/javassist/proxyfactory/ProxyFactoryTest.java b/src/test/javassist/proxyfactory/ProxyFactoryTest.java index 3189b568..43a96bb6 100644 --- a/src/test/javassist/proxyfactory/ProxyFactoryTest.java +++ b/src/test/javassist/proxyfactory/ProxyFactoryTest.java @@ -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); + } + }); + } }