Open jukzi opened 6 months ago
@jukzi Have you tried setting this in "Execution Environments" in the Java Preferences where the compatible JREs are listed?
When i set JavaSE-17 Execution Environment to JDK21, the error is gone. But that feels only like a workaround.
That was the only purpose of allowing to set up the preferred JRE.
I understand it is compiled against JDK 21, but executed with JDK 17 by default
Given your screenshot I think this is a bug. If the JDK to compile is higher than the JDK selected by the project it must use the --target
option an not use any later constructs, this Bug is probably suffering from the same behavior:
When having both JDK 17 and JDK 21 configured in the IDE (and jdk 21 as default JRE) and launching a test case for a BREEE 17 project (Run As..), then it it fails
![image](https://github.com/eclipse-jdt/eclipse.jdt.debug/assets/51790620/83a064b0-3afc-4786-9257-d6f060f97713)
I understand it is compiled against JDK 21, but executed with JDK 17 by default![image](https://github.com/eclipse-jdt/eclipse.jdt.debug/assets/51790620/8bdd4f3a-f25b-4cc4-b885-16dc89c13415)
workaround: open the Launch configuration "Main" tab -> JDK 21 is automaically(!) selected:![image](https://github.com/eclipse-jdt/eclipse.jdt.debug/assets/51790620/b410a245-b3b2-4b0c-bf7d-08d154d7aa10)
There after "run" launches with 21 and test runs fine.
To my understanding the launchconfiguration should use JDK 21 even without using the configuration dialog