@@ -63,6 +63,31 @@ public final class JVMCIVersionCheck {
6363 */
6464 private static final int JAVA_MIN_RELEASE = 21 ;
6565
66+ /**
67+ * Convenience factory for the current version scheme that only uses the JDK version and the
68+ * JVMCI build number.
69+ */
70+ public static Version createLabsJDKVersion (String jdkVersionString , int jvmciBuild ) {
71+ return new Version (jdkVersionString , jvmciBuild );
72+ }
73+
74+ /**
75+ * Convenience factory for the current version scheme that only uses the JDK version
76+ * <em>without</em> a JVMCI build number. This is used when running on a plain OpenJDK, not a
77+ * custom LabsJDK build.
78+ */
79+ public static Version createOpenJDKVersion (String jdkVersionString ) {
80+ return new Version (jdkVersionString );
81+ }
82+
83+ /**
84+ * Legacy factory for versions without JDK version. This force sets {@link Version#jdkVersion}
85+ * to {@code 21}. While this is not entirely correct, it works for our purposes.
86+ */
87+ public static Version createLegacyVersion (int jvmciMajor , int jvmciMinor , int jvmciBuild ) {
88+ return new Version (jvmciMajor , jvmciMinor , jvmciBuild );
89+ }
90+
6691 public static class Version {
6792 private final Runtime .Version jdkVersion ;
6893 private final int jvmciMajor ;
@@ -79,12 +104,12 @@ static Version parse(String vmVersion) {
79104 assert m .group (4 ) == null : "if jvmciMajor is null jvmciMinor must also be null" ;
80105 String jdkVersion = m .group (1 );
81106 int jvmciBuild = Integer .parseInt (m .group (5 ));
82- return new Version (jdkVersion , jvmciBuild );
107+ return createLabsJDKVersion (jdkVersion , jvmciBuild );
83108 } else {
84109 int jvmciMajor = Integer .parseInt (m .group (3 ));
85110 int jvmciMinor = Integer .parseInt (m .group (4 ));
86111 int jvmciBuild = Integer .parseInt (m .group (5 ));
87- return new Version (jvmciMajor , jvmciMinor , jvmciBuild );
112+ return createLegacyVersion (jvmciMajor , jvmciMinor , jvmciBuild );
88113 }
89114
90115 } catch (NumberFormatException e ) {
@@ -93,7 +118,7 @@ static Version parse(String vmVersion) {
93118 } else {
94119 try {
95120 // assume OpenJDK version
96- return new Version (stripVersion (vmVersion ));
121+ return createOpenJDKVersion (stripVersion (vmVersion ));
97122 } catch (IllegalArgumentException e ) {
98123 // ignore
99124 }
@@ -114,28 +139,15 @@ private static String stripVersion(String versionString) {
114139 return sb .toString ();
115140 }
116141
117- /**
118- * Convenience constructor for the current version scheme that only uses the JDK version and
119- * the JVMCI build number.
120- */
121- public Version (String jdkVersionString , int jvmciBuild ) {
142+ private Version (String jdkVersionString , int jvmciBuild ) {
122143 this (jdkVersionString , NA , NA , jvmciBuild , false , false );
123144 }
124145
125- /**
126- * Convenience constructor for the current version scheme that only uses the JDK version
127- * <em>without</em> a JVMCI build number. This is used when running on a plain OpenJDK, not
128- * a custom LabsJDK build.
129- */
130- public Version (String jdkVersionString ) {
146+ private Version (String jdkVersionString ) {
131147 this (jdkVersionString , NA , NA , NA , false , true );
132148 }
133149
134- /**
135- * Legacy construction for versions without JDK version. This force sets {@link #jdkVersion}
136- * to {@code 21}. While this is not entirely correct, it works for our purposes.
137- */
138- public Version (int jvmciMajor , int jvmciMinor , int jvmciBuild ) {
150+ private Version (int jvmciMajor , int jvmciMinor , int jvmciBuild ) {
139151 this ("21" , jvmciMajor , jvmciMinor , jvmciBuild , true , false );
140152 }
141153
0 commit comments