{"action":"created","issue":{"url":"https://api.github.com/repos/jboss-javassist/javassist/issues/228","repository_url":"https://api.github.com/repos/jboss-javassist/javassist","labels_url":"https://api.github.com/repos/jboss-javassist/javassist/issues/228/labels{/name}","comments_url":"https://api.github.com/repos/jboss-javassist/javassist/issues/228/comments","events_url":"https://api.github.com/repos/jboss-javassist/javassist/issues/228/events","html_url":"https://github.com/jboss-javassist/javassist/issues/228","id":376675370,"node_id":"MDU6SXNzdWUzNzY2NzUzNzA=","number":228,"title":"Internal APIs stricter access issue on Java11","user":{"login":"NingZhang-Ericsson","id":41132584,"node_id":"MDQ6VXNlcjQxMTMyNTg0","avatar_url":"https://avatars3.githubusercontent.com/u/41132584?v=4","gravatar_id":"","url":"https://api.github.com/users/NingZhang-Ericsson","html_url":"https://github.com/NingZhang-Ericsson","followers_url":"https://api.github.com/users/NingZhang-Ericsson/followers","following_url":"https://api.github.com/users/NingZhang-Ericsson/following{/other_user}","gists_url":"https://api.github.com/users/NingZhang-Ericsson/gists{/gist_id}","starred_url":"https://api.github.com/users/NingZhang-Ericsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NingZhang-Ericsson/subscriptions","organizations_url":"https://api.github.com/users/NingZhang-Ericsson/orgs","repos_url":"https://api.github.com/users/NingZhang-Ericsson/repos","events_url":"https://api.github.com/users/NingZhang-Ericsson/events{/privacy}","received_events_url":"https://api.github.com/users/NingZhang-Ericsson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-11-02T05:33:31Z","updated_at":"2018-12-04T10:46:49Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"JDK11, javassist 3.24.0-GA\r\nUnit test:\r\n```\r\npublic void testJava11() throws Exception {\r\n    \tProxyFactory factory = new ProxyFactory();\r\n        factory.setSuperclass(HashMap.class);\r\n        \r\n        HashMap e = (HashMap)factory.create(null, null, new MethodHandler() {\r\n            @Override\r\n            public Object invoke(Object self, Method thisMethod,\r\n                    Method proceed, Object[] args) throws Throwable {\r\n                return proceed.invoke(self, args);\r\n            }\r\n        });\r\n    }\r\n```\r\nOutput:\r\n```\r\nWARNING: An illegal reflective access operation has occurred\r\nWARNING: Illegal reflective access using Lookup on javassist.util.proxy.DefineClassHelper (file:/C:/Opensource/javassist/target/classes/) to class java.util.HashMap\r\nWARNING: Please consider reporting this to the maintainers of javassist.util.proxy.DefineClassHelper\r\nWARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations\r\nWARNING: All illegal access operations will be denied in a future release\r\njava.lang.RuntimeException: Class not in same package as lookup class: java.util.HashMap has no permission to define the class\r\n\tat javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:614)\r\n\tat javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:587)\r\n\tat javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:523)\r\n\tat javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:449)\r\n\tat javassist.util.proxy.ProxyFactory.create(ProxyFactory.java:789)\r\n\tat javassist.util.proxy.ProxyFactory.create(ProxyFactory.java:774)\r\n\tat test.javassist.proxy.ProxySimpleTest.testJava11(ProxySimpleTest.java:372)\r\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:566)\r\n\tat junit.framework.TestCase.runTest(TestCase.java:176)\r\n\tat junit.framework.TestCase.runBare(TestCase.java:141)\r\n\tat junit.framework.TestResult$1.protect(TestResult.java:122)\r\n\tat junit.framework.TestResult.runProtected(TestResult.java:142)\r\n\tat junit.framework.TestResult.run(TestResult.java:125)\r\n\tat junit.framework.TestCase.run(TestCase.java:129)\r\n\tat junit.framework.TestSuite.runTest(TestSuite.java:252)\r\n\tat junit.framework.TestSuite.run(TestSuite.java:247)\r\n\tat org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)\r\n\tat org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)\r\n\tat org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)\r\nCaused by: javassist.CannotCompileException: Class not in same package as lookup class: java.util.HashMap has no permission to define the class\r\n\tat javassist.util.proxy.DefineClassHelper.toClass(DefineClassHelper.java:300)\r\n\tat javassist.util.proxy.DefineClassHelper$Java11.defineClass(DefineClassHelper.java:48)\r\n\tat javassist.util.proxy.DefineClassHelper.toClass(DefineClassHelper.java:263)\r\n\tat javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:136)\r\n\tat javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:603)\r\n\t... 25 more\r\n```\r\n\r\nIf change _HashMap_ class to a customized class, this issue will be gone.\r\nDoes this mean no way to proxy Java internal class on Java11? Any other way could be implemented in javassist as one alternative solution?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/jboss-javassist/javassist/issues/comments/444056554","html_url":"https://github.com/jboss-javassist/javassist/issues/228#issuecomment-444056554","issue_url":"https://api.github.com/repos/jboss-javassist/javassist/issues/228","id":444056554,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NDA1NjU1NA==","user":{"login":"chibash","id":4458811,"node_id":"MDQ6VXNlcjQ0NTg4MTE=","avatar_url":"https://avatars3.githubusercontent.com/u/4458811?v=4","gravatar_id":"","url":"https://api.github.com/users/chibash","html_url":"https://github.com/chibash","followers_url":"https://api.github.com/users/chibash/followers","following_url":"https://api.github.com/users/chibash/following{/other_user}","gists_url":"https://api.github.com/users/chibash/gists{/gist_id}","starred_url":"https://api.github.com/users/chibash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibash/subscriptions","organizations_url":"https://api.github.com/users/chibash/orgs","repos_url":"https://api.github.com/users/chibash/repos","events_url":"https://api.github.com/users/chibash/events{/privacy}","received_events_url":"https://api.github.com/users/chibash/received_events","type":"User","site_admin":false},"created_at":"2018-12-04T10:46:49Z","updated_at":"2018-12-04T10:46:49Z","author_association":"MEMBER","body":"@skybber Thanks for your suggestion!\r\n\r\n> We've fixed this issue in HotswapAgent using ClassLoader.define(..) preferentially\r\n\r\nDo you mean java.lang.ClassLoader#defineClass(..)?  There seems to be no #define(..).\r\nI expect ClassLoader#defineClass() will cause a WARNING message.  Is this correct?\r\nA reason to use Lookup#defineClass was to supress this message."}}
{"actor":{"display_login":"chibash"}}