-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
fix(#1156): illegal reflective access on java 9 #1180
Conversation
Thank you, @loicmathieu ! But, this is not the right fix.
The real cause is the call to |
Hello, Yes, my patch is not a correction of the issue but a workaround that works on my use case, when you only use mybatis on your own object with not private method (why is a setter or a getter private anyway), there is no issue as the setAccessible Method is not used. I don't use mapper annotation, and apparently the illegall access warnings on BaseTest are due to the mapper annotation processing, I didn't have time to check this now. But if you launch the test with --illegal-access=warn with and without the patch you should see that the fixe corrected some warnings. The netty way is to don't do setAccessible (this method should not have been used on the first place) on java 9 and allow to force it via a system property. This solution will break existing applications on Java 9 and they will be able to optin via a system property to works again. I agree that a more complete solution should be implemented, anyway, my fix will improve the situation as it will fix the issue in some cases (maybe a majority of cases) and it will also improve starting performance a little as it will avoid some reflection calls. Regards, Loïc |
Well, the change itself is good as an optimization, but I'm not comfortable with treating this as a workaround for the warnings. |
Hello, |
Thank you, @loicmathieu ! |
As a side effect, this might reduce the chance of 'illegal reflective access' warnings on Java 9. mybatis#1156
Hi,
This pull request allow to workaround the java 9 illegal access warning generated by mybatis.
When mybatis search for existing methods on objects, it goes to the object hierarchy including the top java.lang.Object class.
As there is no point to go to the java.lang.Object class as it didn't contains any getter/setter, a trivial workaround is to skip this class.
I tested this approach and with this patch there is no more illegall access warning on Java 9.
Regards,
Loïc
#1156