Configure Guice classloading for Java 21+ compatibilit#3595
Open
rpx99 wants to merge 1 commit intoeclipse-jdtls:mainfrom
Open
Configure Guice classloading for Java 21+ compatibilit#3595rpx99 wants to merge 1 commit intoeclipse-jdtls:mainfrom
rpx99 wants to merge 1 commit intoeclipse-jdtls:mainfrom
Conversation
Contributor
|
Can one of the admins verify this patch? |
fbricon
requested changes
Nov 14, 2025
Contributor
fbricon
left a comment
There was a problem hiding this comment.
You should also add that flag to the org.eclipse.jdt.ls.product/*.product files:
<launcherArgs>
<vmArgs>-Dguice_custom_class_loading=CHILD
</vmArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac>
</launcherArgs>Also, you'll have to sign the Eclipse ECA before we can accept your contribution.
Comment on lines
+47
to
+50
| ### Java 21+ Compatibility | ||
|
|
||
| When running on Java 21 or later, the JVM argument `-Dguice_custom_class_loading=CHILD` is configured to avoid deprecated `sun.misc.Unsafe` usage in the embedded Guice dependency injection framework. This prevents warning messages about terminally deprecated methods and ensures compatibility with future Java versions. This flag is automatically included in all launch configurations and test executions. | ||
|
|
| @@ -0,0 +1,189 @@ | |||
| # Guice Upgrade Analyse für eclipse.jdt.ls - Java 21+ Kompatibilität | |||
d4482a5 to
4a62b38
Compare
Add -Dguice_custom_class_loading=CHILD to avoid sun.misc.Unsafe warnings on Java 21+. This prevents "terminally deprecated method" warnings from Guice 5.1.0's HiddenClassDefiner. Changes: - Add flag to Eclipse launch configurations (3 files) - Add flag to product definitions (languageServer, syntaxServer) - Add flag to tycho-surefire test configuration Based on Maven fix: apache/maven#10992 Resolves sun.misc.Unsafe::staticFieldBase deprecation warnings
4a62b38 to
2b4c6b0
Compare
Author
|
@fbricon Hi Fred, many thanks for comments. Think i fixed that. But, i am Not willing to sign something. Either take it or leave it. Sorry. |
Contributor
|
Unfortunately, signing the ECA is a requirement to contribute to Eclipse projects. Maybe taking a look at https://www.eclipse.org/legal/eca/faq/ will help you make an informed decision. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Configures Guice to use
CHILDclassloading mode via-Dguice_custom_class_loading=CHILDJVM argument to avoidsun.misc.Unsafedeprecation warnings on Java 21+.Problem
Guice 5.1.0 (embedded via M2E 2.9.1 → Maven 3.9.11) uses the terminally deprecated
sun.misc.Unsafe::staticFieldBasemethod, which triggers warnings on Java 21+ and will be removed in future Java versions.Solution
This PR implements the same fix that Maven applied in apache/maven#10992:
CHILDclassloader instead of the defaultBRIDGEmodesun.misc.Unsafecalls while maintaining full functionalityChanges
✅ Eclipse Launch Configurations:
launch/jdt.ls.socket-stream.launchlaunch/jdt.ls.remote.server.launchlaunch/jdt.ls.socket-stream.syntaxserver.launch✅ Test Configuration:
org.eclipse.jdt.ls.tests/pom.xml- Added flag to tycho-surefire argLine✅ Documentation:
README.md- Added Java 21+ compatibility sectionGUICE_UPGRADE_ANALYSIS.md- Comprehensive analysis of upgrade optionsTesting
Why Not Upgrade Guice?
See
GUICE_UPGRADE_ANALYSIS.mdfor detailed analysis:References
Impact
✅ No breaking changes
✅ Eliminates warnings on Java 21+
✅ Future-proofs for Java 26+