New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal APIs stricter access issue on Java11 #228
Comments
Hi, we have the same problem in the HotswapAgent. It's not able to make proxy on jdk classes. I did some description of it there: |
We've fixed this issue in HotswapAgent using ClassLoader.define(..) preferentially before using MethodHandles.Lookup().define, if ClassLoader.define(..) is accessible. It solved our problem with proxying JDK classes. |
@skybber Nice fix! skybber/HotswapAgent@faa8af8 |
@skybber Thanks for your suggestion!
Do you mean java.lang.ClassLoader#defineClass(..)? There seems to be no #define(..). |
@chibash : you are right. I mean - defineClass(). It is protected by default, but it can be tested if the operation is allowed, just before the defineClassMethod.setAccessible(true);. The drawback of Lookup#defineClass is the impossibility to define proxy of JDK classes. In our case it throws javassist.proxy.proxyObject ClassNotFoundException. |
Thank you. I suppose a good fix is to explicitly pass a Lookup object to ProxyFactory#create(). |
I've fixed the bug in a different way I mentioned above since it was a sort of Javassist bug. |
It works well for me. 👍 Great thanks! @chibash |
Looks better, but in my case the proxied class name starts with |
If I modify the line in ProxyFactory to:
it works. I didn't study the code too much... But is there any other solution how to fix it without enumerate any other possible package in which it could have the same problem? |
@skybber your fix is correct. I committed it. |
jdk.internal.URLClassPath, HotswapAgent use proxy to patch URLClassLoader. |
Close the issue. Wait for next release. |
@skybber there is no class named Can you really make a proxy by Javassist for
This statement throws a runtime exception. |
Yes, we're using modified JVM, that allows enhanced redefinition https://github.com/TravaOpenJDK/trava-jdk-11-dcevm , it makes some exports for some jdk modules for bytecode instrumentation. |
I see. I was wondering whether the fix really solved your problem. |
We also encountered this bug, and using snapshot version from master fixes the problem. Are there any plans to release 3.24.1-GA with this fix? |
What about releasing by the upcoming holiday season? |
We'd really would like release as soon as possible, because this prevents us from upgrading to JDK 11. |
I've made the 3.24.1 release. It will be uploaded to maven soon. |
JDK11, javassist 3.24.0-GA
Unit test:
Output:
If change HashMap class to a customized class, this issue will be gone.
Does this mean no way to proxy Java internal class on Java11? Any other way could be implemented in javassist as one alternative solution?
The text was updated successfully, but these errors were encountered: