-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workaround for different treatment of default methods for java 8 and …
…java 11
- Loading branch information
Showing
3 changed files
with
59 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.tensorics.core.util; | ||
|
||
/** | ||
* Contains utility methods related to java versions | ||
*/ | ||
public final class JavaVersions { | ||
|
||
private JavaVersions() { | ||
throw new UnsupportedOperationException("only static methods"); | ||
} | ||
|
||
/** | ||
* Determines if the actual running jvm is at least java 11 | ||
* | ||
* @return true if it is java 11 or higher, false otherwise | ||
*/ | ||
public static boolean isAtLeastJava11() { | ||
return "11".compareTo(System.getProperty("java.version")) <= 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.tensorics.core.util; | ||
|
||
import org.junit.Test; | ||
|
||
public class JavaVersionsTries { | ||
|
||
@Test | ||
public void testJavaVersion() { | ||
System.out.println(System.getProperty("java.version")); | ||
System.out.println("11".compareTo("1.8") <= 0); | ||
System.out.println("11".compareTo("11") <= 0); | ||
System.out.println("11".compareTo("12") <= 0); | ||
System.out.println(JavaVersions.isAtLeastJava11()); | ||
} | ||
|
||
} |