Skip to content

Fix the illegal lookupClass issue when using MethodHandles.Lookup on JDK 8 #594

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

Merged
merged 4 commits into from
Apr 9, 2025

Conversation

zhelenskiy
Copy link
Contributor

@zhelenskiy zhelenskiy commented Mar 29, 2025

The issue was caused by the fact that MethodHandles.lookup, needed for custom handling of invoke-dynamic cannot be called from certain locations. In the case of Java > 8, the only limitation is java.lang.invoke, which is fine. While in Java 8 it also includes all Java stdlib packages. So the workaround was to call a private constructor of MethodHandles privately with reflection.

The issue was reproducible on one of the tests from Kotlin compiler repository.

@zhelenskiy zhelenskiy requested a review from eupp March 29, 2025 05:11
@zhelenskiy zhelenskiy self-assigned this Mar 29, 2025
@zhelenskiy zhelenskiy changed the title Fix first issue found launching Trace debugger on Kotlin Project, enhance debugging and logging tooling Fix the first issue found while launching Trace debugger on Kotlin Project, also enhance debugging and logging tooling Mar 29, 2025
@ndkoval
Copy link
Collaborator

ndkoval commented Apr 1, 2025

@zhelenskiy, please update the PR title and description to indicate what this PR fixes.

@ndkoval
Copy link
Collaborator

ndkoval commented Apr 1, 2025

@zhelenskiy, please also add an integration test for the issue.

@zhelenskiy
Copy link
Contributor Author

@zhelenskiy, please also add an integration test for the issue.

The integration test for this issue is considered too complex, so we decided not to include it, as it would require too much effort. It would be possible to include the whole Kotlin project once it would start working completely fine.

@eupp eupp changed the title Fix the first issue found while launching Trace debugger on Kotlin Project, also enhance debugging and logging tooling Fix the first issue found while launching Trace debugger on Kotlin Project Apr 2, 2025
@eupp eupp changed the title Fix the first issue found while launching Trace debugger on Kotlin Project Fix the illegal lookupClass issue when using MethodHandles.Lookup on JDK 8 Apr 3, 2025
@zhelenskiy zhelenskiy force-pushed the custom-lookup branch 2 times, most recently from 395ed1c to ba589f3 Compare April 7, 2025 15:15
@zhelenskiy zhelenskiy requested a review from eupp April 7, 2025 15:31
@eupp eupp merged commit dacf5d9 into develop Apr 9, 2025
20 checks passed
@eupp eupp deleted the custom-lookup branch April 9, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants