From 32c3fbccac055b3fc878f53dfb385d00d6789c7d Mon Sep 17 00:00:00 2001
From: Sven Gothel
- * Implies {@link #isJavaSE()} and {@link #JAVA_6}. + * Implies {@link #JAVA_6} and {@link #isJavaSE()} *
** Since JRE 9, the version string has dropped the major release number, @@ -109,6 +87,22 @@ public abstract class PlatformPropsImpl { */ public static final boolean JAVA_9; + /** + * True only if being compatible w/ language level 17, e.g. JRE 17 (LTS). + *
+ * Implies {@link #JAVA_9}, {@link #JAVA_6} and {@link #isJavaSE()} + *
+ */ + public static final boolean JAVA_17; + + /** + * True only if being compatible w/ language level 21, e.g. JRE 21 (LTS). + *+ * Implies {@link #JAVA_17}, {@link #JAVA_9}, {@link #JAVA_6} and {@link #isJavaSE()} + *
+ */ + public static final boolean JAVA_21; + public static final String NEWLINE; public static final boolean LITTLE_ENDIAN; @@ -126,11 +120,6 @@ public abstract class PlatformPropsImpl { public static final boolean useDynamicLibraries; static { - Version16 = new VersionNumber(1, 6, 0); - Version17 = new VersionNumber(1, 7, 0); - Version18 = new VersionNumber(1, 8, 0); - Version9 = new VersionNumber(9, 0, 0); - // We don't seem to need an AccessController.doPrivileged() block // here as these system properties are visible even to unsigned Applets. final boolean isAndroid = AndroidVersion.isAvailable; // also triggers it's static initialization @@ -158,9 +147,41 @@ public abstract class PlatformPropsImpl { JAVA_VM_NAME = System.getProperty("java.vm.name"); JAVA_RUNTIME_NAME = getJavaRuntimeNameImpl(); JAVA_SE = initIsJavaSE(); - JAVA_9 = JAVA_SE && JAVA_VERSION_NUMBER.compareTo(Version9) >= 0; - JAVA_6 = JAVA_SE && ( isAndroid || JAVA_9 || JAVA_VERSION_NUMBER.compareTo(Version16) >= 0 ) ; - + if( JAVA_SE ) { + if( JAVA_VERSION_NUMBER.compareTo(new VersionNumber(21, 0, 0)) >= 0 ) { + JAVA_21 = true; + JAVA_17 = true; + JAVA_9 = true; + JAVA_6 = true; + } else if( JAVA_VERSION_NUMBER.compareTo(new VersionNumber(17, 0, 0)) >= 0 ) { + JAVA_21 = false; + JAVA_17 = true; + JAVA_9 = true; + JAVA_6 = true; + } else if( JAVA_VERSION_NUMBER.compareTo(new VersionNumber(9, 0, 0)) >= 0 ) { + JAVA_21 = false; + JAVA_17 = false; + JAVA_9 = true; + JAVA_6 = true; + } else if( isAndroid || JAVA_VERSION_NUMBER.compareTo(new VersionNumber(1, 6, 0)) >= 0 ) { + JAVA_21 = false; + JAVA_17 = false; + JAVA_9 = false; + JAVA_6 = true; + } else { + // we probably don't support anything below 1.6 + JAVA_21 = false; + JAVA_17 = false; + JAVA_9 = false; + JAVA_6 = false; + } + } else { + // we probably don't support anything below 1.6 or non JavaSE + JAVA_21 = false; + JAVA_17 = false; + JAVA_9 = false; + JAVA_6 = false; + } NEWLINE = System.getProperty("line.separator"); OS = System.getProperty("os.name"); -- cgit v1.2.3