From f7543857669ad5fff98d61a75a4f04d848ef4820 Mon Sep 17 00:00:00 2001 From: chibash Date: Fri, 7 Aug 2015 00:48:03 +0900 Subject: fixed JASSIST-244 --- src/test/test/javassist/proxy/ProxySimpleTest.java | 41 ++++++++++++++++++++++ src/test/testproxy/ProxyTester.java | 4 +-- 2 files changed, 43 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/test/javassist/proxy/ProxySimpleTest.java b/src/test/test/javassist/proxy/ProxySimpleTest.java index cab62397..f37e7b8c 100644 --- a/src/test/test/javassist/proxy/ProxySimpleTest.java +++ b/src/test/test/javassist/proxy/ProxySimpleTest.java @@ -99,4 +99,45 @@ public class ProxySimpleTest extends TestCase { public static class WriteReplace2 implements Serializable { public Object writeReplace(int i) { return new Integer(i); } } + + String value244; + + public void testJIRA244() throws Exception { + ProxyFactory factory = new ProxyFactory(); + factory.setSuperclass(Extended244.class); + Extended244 e = (Extended244)factory.create(null, null, new MethodHandler() { + @Override + public Object invoke(Object self, Method thisMethod, + Method proceed, Object[] args) throws Throwable { + value244 += thisMethod.getDeclaringClass().getName(); + return proceed.invoke(self); + } + }); + + value244 = ""; + assertEquals("base", e.base()); + System.out.println(value244); + assertEquals(Extended244.class.getName(), value244); + + value244 = ""; + assertEquals("ext", e.extended()); + System.out.println(value244); + assertEquals(Extended244.class.getName(), value244); + + value244 = ""; + assertEquals("base2ext2", e.base2()); + System.out.println(value244); + assertEquals(Extended244.class.getName(), value244); + } + + // if Base244 is private, then Extended244 has a bridge method for base(). + private static abstract class Base244 { + public String base() { return "base"; } + public String base2() { return "base2"; } + } + + public static class Extended244 extends Base244 { + public String extended() { return "ext"; } + public String base2() { return super.base2() + "ext2"; } + } } diff --git a/src/test/testproxy/ProxyTester.java b/src/test/testproxy/ProxyTester.java index 6d5559b6..e06848f8 100644 --- a/src/test/testproxy/ProxyTester.java +++ b/src/test/testproxy/ProxyTester.java @@ -399,7 +399,7 @@ public class ProxyTester extends TestCase { public static void testJIRA189() throws Exception { Class persistentClass = Target189.PublishedArticle.class; ProxyFactory factory = new ProxyFactory(); - factory.writeDirectory = "."; + // factory.writeDirectory = "."; factory.setUseCache(false); factory.setSuperclass(persistentClass); factory.setInterfaces(new Class[] { Target189.TestProxy.class }); @@ -417,7 +417,7 @@ public class ProxyTester extends TestCase { public void testJIRA127() throws Exception { ProxyFactory proxyFactory = new ProxyFactory(); - proxyFactory.writeDirectory = "."; + // proxyFactory.writeDirectory = "."; proxyFactory.setInterfaces(new Class[]{ Target127.Sub.class }); Target127.Sub proxy = (Target127.Sub)proxyFactory.create(new Class[0], new Object[0], new MethodHandler() { public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { -- cgit v1.2.3