Closed jarthana closed 1 month ago
There could be more to this. I see that the UI may have a hand in this as well (via Bug 542579). Assigning to @noopur2507
Can you provide step-by-step instructions on how to reproduce it on UI?
Steps:
Workspace default JRE
enablePreviewFeatures=enabled
Execution Environment
and JavaSE-23
enablePreviewFeatures
has been reset to disabled
.Between steps 5 and 6, if we go to the project's Java Compiler page after just clicking Apply on the Java Build Path page, then clicking Apply and Close preserves the preview state i.e. it stays enabled.
I see that when selecting an EE, the settings from EE are being applied.
See BuildPathSupport.getEEOptions(IExecutionEnvironment ee) where the IExecutionEnvironment.getComplianceOptions() is returning disabled for preview features in JavaSE-23 EE and the same is being set at line 422.
Is it correct to get preview features as disabled via JavaSE-23 EE profile?
I see two code locations basically implementing the same logic: when setting compliance > 10 initially disable preview features:
org.eclipse.jdt.core.JavaCore.setComplianceOptions(String, Map)
org.eclipse.jdt.internal.launching.environments.ExecutionEnvironment.getJavaProfileProperties(Bundle, String)
To change the behavior resulting from BuildPathSupport.getEEOptions()
both locations would need to be changed.
Generally it's good to disable previews when switching the EE as you can't carry over preview from one compliance to another. Only when switching from a JRE 23 to JavaSE-23 the flag could possibly be preserved, but that may not be the most frequent operation. I wouldn't give much priority to keeping the preview flag in this one specific scenario.
Thanks, Stephan.
I am closing this issue based on the above comment.
This was originally reported on #2939. The issue was that the default module import of java.base was not happening. It turned out to be caused by the preview flag being disabled when the project build path is set with a JavaSE-23 rather than a specific JDK 23. I nailed this down to the preview flag being reset to false when request is coming from the build path config page. The code in question is in org.eclipse.jdt.core.JavaCore.setComplianceOptions(String, Map), line number 6436 and was introduce by commit (664939cf47c16a86089a9b3db66881fc786ac539).
@noopur2507 I am not sure it's a good idea to reset this to false. May be OK when the compliance is not latest, but not otherwise. I will alter this code. Let me know if you still think we should reset this.