i888 Use correct java compiler for JUnit tests#895
i888 Use correct java compiler for JUnit tests#895johnbrvc wants to merge 2 commits intopc2ccs:developfrom
Conversation
|
Tested with jdk17 as first in my PATH (and only java in my PATH), generated a |
|
btw, standard location on MacOS is for the jdk to be under along with the amazon-corretto one |
This comment was marked as resolved.
This comment was marked as resolved.
Changed so it actually runs "javac -version" on every javac or javac.exe on the JAVA_HOME/bin and PATH until it finds one that matches instead of just looking for the version in the folder string. |
This comment was marked as resolved.
This comment was marked as resolved.
Since Eclipse 4.17 (2020-09), Java 11 is the default JDK that ships with Eclipse. Previously, it was Java 8 (1.8). This PR attempts to track down the correct JDK to use for compiling the JUnit test programs. The JDK must match the currently running JVM in order to qualify. A search of the JAVA_HOME/bin and folders on the PATH environment variable are checked for the presence of the corresponding JDK (javac[.exe]). The code only checks for the presence of the java version string in the folder name. It could be expanded to actually attempt to run "javac -version" in each folder, but that shouldn't be necessary.
In order to track down the correct JDK to use for building java applications as part of a JUnit, we try each folder of: JAVA_HOME/bin, and PATH components until we find one that matches the JRE.
50fbeff to
c02d82e
Compare
Description of what the PR does
Since Eclipse 4.17 (2020-09), Java 11 (or newer) is the default JDK that ships with Eclipse. Previously, it was Java 8 (1.8). This PR attempts to track down the correct JDK to use for compiling the JUnit test programs. The JDK must match the currently running JVM in order to qualify. A search of the
JAVA_HOME/binand folders on thePATHenvironment variable are checked for the presence of the corresponding JDK (javac[.exe]). The code only checks for the presence of the Java version string in the folder name. It could be expanded to actually attempt to run "javac -version" in each folder, but that shouldn't be necessary, and is highly inefficient.The reason for this PR is that the JUnits requiring compiles were using Eclipse's JDK (Version >11), but attempting to execute the produced class files using JRE 1.8. This lead to the errors described in #888.
Issue which the PR addresses
Fixed #888
Environment in which the PR was developed (OS,IDE, Java version, etc.)
Windows 11
Eclipse 2021-12, with JVM org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.1.v20211116-1657
JDK 1.8.0_351
Precise steps for testing the PR (i.e., how to demonstrate that it works correctly)
Run all JUnits. They should pass now. Previously, the ones in #888 (ExecuteTest, among others) did not pass.