Skip to content

Commit

Permalink
Make JUnit5Runner usable with Early Access builds (#194)
Browse files Browse the repository at this point in the history
Fixes this crash:
```
Exception in thread "main" java.lang.NumberFormatException: For input string: "21-ea"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
	at java.base/java.lang.Integer.parseInt(Integer.java:661)
	at java.base/java.lang.Integer.parseInt(Integer.java:777)
	at com.github.bazel_contrib.contrib_rules_jvm.junit5.JUnit5Runner.getSystemExitToggle(JUnit5Runner.java:57)
	at com.github.bazel_contrib.contrib_rules_jvm.junit5.JUnit5Runner.main(JUnit5Runner.java:24)
```
  • Loading branch information
fmeum authored Aug 14, 2023
1 parent e46bb11 commit 3efcf76
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public static void main(String[] args) {
private static SystemExitToggle getSystemExitToggle() {
// In Java 8 and lower, the first part of the version is a 1.
// In Java 9 and higher, the first part of the version is the feature version.
int featureVersion = Integer.parseInt(System.getProperty("java.version").split("\\.")[0]);
// Major versions of early Access builds have an "-ea" suffix.
int featureVersion = Integer.parseInt(System.getProperty("java.version").split("[.-]")[0]);
if (featureVersion == 1) {
featureVersion = 8;
}
Expand Down

0 comments on commit 3efcf76

Please sign in to comment.