Repository: quarkusio/quarkus
Issue: "Using Java versions older than 11 ... " complaint with Java 17 Early Access build

I see `[WARNING] [io.quarkus.deployment.QuarkusAugmentor] Using Java versions older than 11 to build Quarkus applications is deprecated and will be disallowed in a future release!` complaint when using Java 17 Early Access build

Code for version check probably doesn't handle `-ea` suffix in Early Access Java build version, e.g. `17-ea`.

Changed files:
core/runtime/src/test/java/io/quarkus/runtime/util/JavaVersionUtilTest.java, core/runtime/src/main/java/io/quarkus/runtime/util/JavaVersionUtil.java

diff --git a/core/runtime/src/main/java/io/quarkus/runtime/util/JavaVersionUtil.java b/core/runtime/src/main/java/io/quarkus/runtime/util/JavaVersionUtil.java
index 4236031c1d2..74d7d0c31ea 100644
--- a/core/runtime/src/main/java/io/quarkus/runtime/util/JavaVersionUtil.java
+++ b/core/runtime/src/main/java/io/quarkus/runtime/util/JavaVersionUtil.java
@@ -5,7 +5,7 @@
 
 public class JavaVersionUtil {
 
-    private static final Pattern PATTERN = Pattern.compile("(?:1\\\\.)?(\\\\d+)(?:\\\\..*)?");
+    private static final Pattern PATTERN = Pattern.compile("(?:1\\\\.)?(\\\\d+)");
 
     private static boolean IS_JAVA_11_OR_NEWER;
     private static boolean IS_JAVA_13_OR_NEWER;
@@ -16,7 +16,7 @@ public class JavaVersionUtil {
 
     // visible for testing
     static void performChecks() {
-        Matcher matcher = PATTERN.matcher(System.getProperty("java.version", ""));
+        Matcher matcher = PATTERN.matcher(System.getProperty("java.specification.version", ""));
         if (matcher.matches()) {
             int first = Integer.parseInt(matcher.group(1));
             IS_JAVA_11_OR_NEWER = (first >= 11);
diff --git a/core/runtime/src/test/java/io/quarkus/runtime/util/JavaVersionUtilTest.java b/core/runtime/src/test/java/io/quarkus/runtime/util/JavaVersionUtilTest.java
index 0e47d6b54a2..d2300aa1483 100644
--- a/core/runtime/src/test/java/io/quarkus/runtime/util/JavaVersionUtilTest.java
+++ b/core/runtime/src/test/java/io/quarkus/runtime/util/JavaVersionUtilTest.java
@@ -7,11 +7,11 @@
 
 class JavaVersionUtilTest {
 
-    private static final String JAVA_VERSION = "java.version";
+    private static final String JAVA_SPECIFICATION_VERSION = "java.specification.version";
 
     @Test
     void testJava8() {
-        testWithVersion("1.8.0_242", () -> {
+        testWithVersion("1.8", () -> {
             assertFalse(JavaVersionUtil.isJava11OrHigher());
             assertFalse(JavaVersionUtil.isJava13OrHigher());
         });
@@ -19,7 +19,7 @@ void testJava8() {
 
     @Test
     void testJava11() {
-        testWithVersion("11.0.7", () -> {
+        testWithVersion("11", () -> {
             assertTrue(JavaVersionUtil.isJava11OrHigher());
             assertFalse(JavaVersionUtil.isJava13OrHigher());
         });
@@ -27,20 +27,36 @@ void testJava11() {
 
     @Test
     void testJava14() {
-        testWithVersion("14.0.1", () -> {
+        testWithVersion("14", () -> {
             assertTrue(JavaVersionUtil.isJava11OrHigher());
             assertTrue(JavaVersionUtil.isJava13OrHigher());
         });
     }
 
-    private void testWithVersion(String javaVersion, Runnable test) {
-        String previous = System.getProperty(JAVA_VERSION);
-        System.setProperty(JAVA_VERSION, javaVersion);
+    @Test
+    void testJava17() {
+        testWithVersion("17", () -> {
+            assertTrue(JavaVersionUtil.isJava11OrHigher());
+            assertTrue(JavaVersionUtil.isJava13OrHigher());
+        });
+    }
+
+    @Test
+    void testJava21() {
+        testWithVersion("21", () -> {
+            assertTrue(JavaVersionUtil.isJava11OrHigher());
+            assertTrue(JavaVersionUtil.isJava13OrHigher());
+        });
+    }
+
+    private void testWithVersion(String javaSpecificationVersion, Runnable test) {
+        String previous = System.getProperty(JAVA_SPECIFICATION_VERSION);
+        System.setProperty(JAVA_SPECIFICATION_VERSION, javaSpecificationVersion);
         JavaVersionUtil.performChecks();
         try {
             test.run();
         } finally {
-            System.setProperty(JAVA_VERSION, previous);
+            System.setProperty(JAVA_SPECIFICATION_VERSION, previous);
             JavaVersionUtil.performChecks();
         }