Skip to content
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

No respect for --release flag #1162

Closed
akurtakov opened this issue Jan 22, 2025 · 7 comments
Closed

No respect for --release flag #1162

akurtakov opened this issue Jan 22, 2025 · 7 comments

Comments

@akurtakov
Copy link

akurtakov commented Jan 22, 2025

The following java file in a project:

import java.util.Locale;

public class Test {

	public static void main(String[] args) {
		new Locale("bg");
	}

}

produces

Image but the project has Java -17 JVM (a real 17 JVM) but the deprecation warnings shouldn't be there with --release 17 .
Console usage of javac gives (warning on Java 21 but not on 17):`

akurtakov@localhost:~/work/jdt.ui/testa/src/testa$ javac Test.java -Xlint:deprecation --release=21
Test.java:6: warning: [deprecation] Locale(String) in Locale has been deprecated
		new Locale("bg");
		^
1 warning
akurtakov@localhost:~/work/jdt.ui/testa/src/testa$ javac Test.java -Xlint:deprecation --release=17
akurtakov@localhost:~/work/jdt.ui/testa/src/testa$ 
@mickaelistria
Copy link

Are you sure the project has the "release" setting enabled?

@akurtakov
Copy link
Author

Image

@akurtakov
Copy link
Author

Image

@mickaelistria
Copy link

JDT's CompilerOptions is enforcing OPTION_Release to "disabled". This has to be fixed.

@mickaelistria
Copy link

There are (at least) 2 issues:

  • one seems to be JDT not forwarding the value of the release option to AbstractImageBuilder (I've got a patch for it, that I'll push upstream when I confirm a full fix)
  • another issue is that the classloading is different with javac CLI vs our Javac integration: what we get with the right option in JDT is a different c.classfile for the class symbol of Locale. CLI one is an instanceof JDKPlatformManager$1 (expected) while the one with our Javac integration is a JavacFileManager returning a different object (not so correct).

@mickaelistria
Copy link

The JavacCompiler must be using JavacTool.getTask() to ensure proper arguments being passed.

@mickaelistria
Copy link

Should be fixed with #1168

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants