Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -550,45 +550,33 @@ private static long versionStringToMajorMinor(String version) throws CompilerExc
// Accept, but cut off trailing ".0", as ECJ/ACJ explicitly support versions like 5.0, 8.0, 11.0
.replaceFirst("[.]0$", "");

switch (version) {
// Java 1.6 as a default source/target seems to make sense. Maven Compiler should set its own default
// anyway, so this probably never needs to be used. But not having a default feels bad, too.
case "":
return ClassFileConstants.JDK1_6;
case "1":
return ClassFileConstants.JDK1_1;
case "2":
return ClassFileConstants.JDK1_2;
case "3":
return ClassFileConstants.JDK1_3;
case "4":
return ClassFileConstants.JDK1_4;
case "5":
return ClassFileConstants.JDK1_5;
case "6":
return ClassFileConstants.JDK1_6;
case "7":
return ClassFileConstants.JDK1_7;
case "8":
return ClassFileConstants.JDK1_8;
case "9":
return ClassFileConstants.JDK9;
case "10":
return ClassFileConstants.JDK10;
case "11":
return ClassFileConstants.JDK11;
case "12":
return ClassFileConstants.JDK12;
case "13":
return ClassFileConstants.JDK13;
case "14":
return ClassFileConstants.JDK14;
case "15":
return ClassFileConstants.JDK15;
case "16":
return ClassFileConstants.JDK16;
}
throw new CompilerException("Unknown Java source/target version number: " + version);
return switch (version) {
// Java 1.6 as a default source/target seems to make sense. Maven Compiler should set its own default
// anyway, so this probably never needs to be used. But not having a default feels bad, too.
case "" -> ClassFileConstants.JDK1_6;
case "1" -> ClassFileConstants.JDK1_1;
case "2" -> ClassFileConstants.JDK1_2;
case "3" -> ClassFileConstants.JDK1_3;
case "4" -> ClassFileConstants.JDK1_4;
case "5" -> ClassFileConstants.JDK1_5;
case "6" -> ClassFileConstants.JDK1_6;
case "7" -> ClassFileConstants.JDK1_7;
case "8" -> ClassFileConstants.JDK1_8;
case "9" -> ClassFileConstants.JDK9;
case "10" -> ClassFileConstants.JDK10;
case "11" -> ClassFileConstants.JDK11;
case "12" -> ClassFileConstants.JDK12;
case "13" -> ClassFileConstants.JDK13;
case "14" -> ClassFileConstants.JDK14;
case "15" -> ClassFileConstants.JDK15;
case "16" -> ClassFileConstants.JDK16;
case "17" -> ClassFileConstants.JDK17;
case "18" -> ClassFileConstants.JDK18;
case "19" -> ClassFileConstants.JDK19;
case "20" -> ClassFileConstants.JDK20;
case "21" -> ClassFileConstants.JDK21;
default -> throw new CompilerException("Unknown Java source/target version number: " + version);
};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ protected int expectedWarnings() {
@Override
protected Collection<String> expectedOutputFiles() {
String javaVersion = getJavaVersion();
if (javaVersion.contains("9.0")
|| javaVersion.contains("11")
if (javaVersion.contains("11")
|| javaVersion.contains("17")
|| javaVersion.contains("21")
|| javaVersion.contains("24")) {
|| javaVersion.contains("25")) {
return Arrays.asList(
"org/codehaus/foo/Deprecation.class",
"org/codehaus/foo/ExternalDeps.class",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected Collection<String> expectedOutputFiles() {
|| javaVersion.contains("11")
|| javaVersion.contains("17")
|| javaVersion.contains("21")
|| javaVersion.contains("24")) {
|| javaVersion.contains("25")) {
return Arrays.asList(
"org/codehaus/foo/Deprecation.class",
"org/codehaus/foo/ExternalDeps.class",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected Collection<String> expectedOutputFiles() {
|| javaVersion.contains("11")
|| javaVersion.contains("17")
|| javaVersion.contains("21")
|| javaVersion.contains("24")) {
|| javaVersion.contains("25")) {
return Arrays.asList(
"org/codehaus/foo/Deprecation.class",
"org/codehaus/foo/ExternalDeps.class",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ protected int expectedWarnings() {
String javaVersion = getJavaVersion();
if (javaVersion.startsWith("1.8")) {
return 1;
} else if (javaVersion.contains("18")
|| javaVersion.contains("19")
|| javaVersion.contains("20")
|| javaVersion.contains("21")
|| javaVersion.contains("22")
|| javaVersion.contains("23")
|| javaVersion.contains("24")) {
} else if (javaVersion.contains("21") || javaVersion.contains("25")) {
return 5;
}
return 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected int expectedErrors() {
if (javaVersion.contains("11")
|| javaVersion.contains("17")
|| javaVersion.contains("21")
|| javaVersion.contains("24")) {
|| javaVersion.contains("25")) {
return 5;
}
// javac output changed for misspelled modifiers starting in 1.6...they now generate 2 errors per occurrence,
Expand All @@ -77,19 +77,10 @@ protected int expectedErrors() {
@Override
protected int expectedWarnings() {
String javaVersion = getJavaVersion();
if (javaVersion.contains("9.0")
|| javaVersion.contains("11")
|| javaVersion.contains("14")
|| javaVersion.contains("15")
|| javaVersion.contains("16")
if (javaVersion.contains("11")
|| javaVersion.contains("17")
|| javaVersion.contains("18")
|| javaVersion.contains("19")
|| javaVersion.contains("20")
|| javaVersion.contains("21")
|| javaVersion.contains("22")
|| javaVersion.contains("23")
|| javaVersion.contains("24")) {
|| javaVersion.contains("25")) {
return 1;
}
if (javaVersion.contains("1.8")) {
Expand Down Expand Up @@ -134,6 +125,8 @@ public String getTargetVersion() {
return "23";
} else if (javaVersion.contains("24")) {
return "24";
} else if (javaVersion.contains("25")) {
return "25";
}
return super.getTargetVersion();
}
Expand Down Expand Up @@ -167,26 +160,19 @@ public String getSourceVersion() {
return "23";
} else if (javaVersion.contains("24")) {
return "24";
} else if (javaVersion.contains("25")) {
return "25";
}
return super.getTargetVersion();
}

@Override
protected Collection<String> expectedOutputFiles() {
String javaVersion = getJavaVersion();
if (javaVersion.contains("9.0")
|| javaVersion.contains("11")
|| javaVersion.contains("14")
|| javaVersion.contains("15")
|| javaVersion.contains("16")
if (javaVersion.contains("11")
|| javaVersion.contains("17")
|| javaVersion.contains("18")
|| javaVersion.contains("19")
|| javaVersion.contains("20")
|| javaVersion.contains("21")
|| javaVersion.contains("22")
|| javaVersion.contains("23")
|| javaVersion.contains("24")) {
|| javaVersion.contains("25")) {
return Arrays.asList(
"org/codehaus/foo/Deprecation.class",
"org/codehaus/foo/ExternalDeps.class",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class JavaxToolsCompilerTest extends AbstractJavacCompilerTest {
@Override
protected int expectedWarnings() {
String javaVersion = getJavaVersion();
if (javaVersion.contains("21") || javaVersion.contains("24")) {
if (javaVersion.contains("21") || javaVersion.contains("25")) {
return 1;
} else {
return super.expectedWarnings();
Expand Down
Loading