mocobeta commented on code in PR #941:
URL: https://github.com/apache/lucene/pull/941#discussion_r887623243


##########
buildSrc/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java:
##########
@@ -55,9 +64,18 @@ public static void main(String[] args) {
   }
 
   public static void checkVersion() {
-    int major = Runtime.getRuntime().version().feature();
-    if (major != 17) {
-      throw new IllegalStateException("java version be exactly 17, your 
version: " + major);
+    Runtime.Version version = Runtime.version();
+    int feature = version.feature();
+    int interim = version.interim();
+    int update = version.update();
+    // Version.toString() can return arbitrary version string depending on 
vendors.
+    // Reformat as "$FEATURE.$INTERIM.$UPDATE"
+    final String runtimeVersionString = String.format("%d.%d.%d", feature, 
interim, update);

Review Comment:
   I first tried to just print `Runtime.Version.toString()`, then found some 
distributions can omit minor/patch versions in their version string (I guess 
because the minor/patch version is `0`). 
   ```
   # Corretto 17.0.0 ommits minor/patch version  
   $ java --version
   openjdk 17 2021-09-14 LTS
   OpenJDK Runtime Environment Corretto-17.0.0.35.1 (build 17+35-LTS)
   OpenJDK 64-Bit Server VM Corretto-17.0.0.35.1 (build 17+35-LTS, mixed mode, 
sharing)
   
   jshell> Runtime.getRuntime().version().toString()
   $3 ==> "17+35-LTS"  // looks ambiguous to me.
   ```
   
   Yet I have no strong opinion on this, I'll revert the reformatting code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to