This is an automated email from the ASF dual-hosted git repository.

snuyanzin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 09c0ef1c15 [CALCITE-5737] Support JDK 21 and JDK 22
09c0ef1c15 is described below

commit 09c0ef1c1565962e98b9b93cf69b8cc35ba80044
Author: Sergey Nuyanzin <snuyan...@confluent.io>
AuthorDate: Sun May 19 17:16:11 2024 +0200

    [CALCITE-5737] Support JDK 21 and JDK 22
    
    Update dependencies
    asm from 7.2 to 9.6
    byte-buddy from 1.9.3 to 1.14.15
    forbiddenapis from 3.5.1 to 3.7
    mockito from 2.23.4 to 3.12.4
---
 .github/workflows/buildcache.yml                   |  2 +-
 .github/workflows/main.yml                         | 76 +++++++++++++++++++---
 build.gradle.kts                                   |  3 +
 .../java/org/apache/calcite/runtime/HttpUtils.java |  4 +-
 .../main/java/org/apache/calcite/util/Sources.java |  4 +-
 .../main/java/org/apache/calcite/util/Util.java    |  3 +-
 gradle.properties                                  |  8 +--
 site/_docs/howto.md                                |  4 +-
 .../calcite/adapter/splunk/SplunkDriver.java       |  3 +-
 .../splunk/search/SplunkConnectionImpl.java        |  3 +-
 src/main/config/forbidden-apis/signatures.txt      |  8 +++
 11 files changed, 96 insertions(+), 22 deletions(-)

diff --git a/.github/workflows/buildcache.yml b/.github/workflows/buildcache.yml
index bb5d7b4736..419588304f 100644
--- a/.github/workflows/buildcache.yml
+++ b/.github/workflows/buildcache.yml
@@ -34,7 +34,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [ubuntu, macos, windows]
-        jdk: [8, 11, 17]
+        jdk: [8, 11, 17, 21]
 
     name: '${{ matrix.os }}, ${{ matrix.jdk }} seed build cache'
     runs-on: ${{ matrix.os }}-latest
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index fb932aac89..c380a56c4e 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -115,6 +115,40 @@ jobs:
           echo sqlsh
           call sqlsh.bat -o headers "select count(*) commits, author from 
(select substring(author, 1, position(' <' in author)-1) author from 
git_commits) group by author order by count(*) desc, author limit 20"
 
+  windows-jdk21:
+    if: github.event.action != 'labeled'
+    name: 'Windows (JDK 21)'
+    runs-on: windows-latest
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          fetch-depth: 50
+      - name: 'Set up JDK 21'
+        uses: actions/setup-java@v2
+        with:
+          java-version: 21
+          distribution: 'zulu'
+      - uses: burrunan/gradle-cache-action@v1
+        name: Test
+        env:
+          S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ 
secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
+          S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
+          GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }}
+        with:
+          job-id: jdk${{ matrix.jdk }}
+          remote-build-cache-proxy-enabled: false
+          arguments: --scan --no-parallel --no-daemon build
+      - name: 'sqlline and sqllsh'
+        shell: cmd
+        run: |
+          call sqlline.bat -e '!quit'
+          echo.
+          echo Sqlline example/csv
+          call example/csv/sqlline.bat --verbose -u 
jdbc:calcite:model=example/csv/src/test/resources/model.json -n admin -p admin 
-f example/csv/src/test/resources/smoke_test.sql
+          echo.
+          echo sqlsh
+          call sqlsh.bat -o headers "select count(*) commits, author from 
(select substring(author, 1, position(' <' in author)-1) author from 
git_commits) group by author order by count(*) desc, author limit 20"
+
   linux-jdk8-oldest-guava-tz:
     if: github.event.action != 'labeled'
     name: 'Linux (JDK 8), oldest Guava, America/New_York Timezone'
@@ -220,9 +254,35 @@ jobs:
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ 
env.GUAVA }} build
 
-  linux-jdk19: # latest JDK version supported by ForbiddenAPIs plugin, keep 
this updated (see https://jdk.java.net/)
+  linux-jdk121:  # LTS JDK version, don't remove until EOL
+    if: github.event.action != 'labeled'
+    name: 'Linux (JDK 21)'
+    runs-on: ubuntu-latest
+    env:
+      GUAVA: '21.0' # oldest Guava
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          fetch-depth: 50
+      - name: 'Set up JDK 21'
+        uses: actions/setup-java@v2
+        with:
+          java-version: 21
+          distribution: 'zulu'
+      - uses: burrunan/gradle-cache-action@v1
+        name: Test
+        env:
+          S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ 
secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
+          S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
+          GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }}
+        with:
+          job-id: jdk${{ matrix.jdk }}
+          remote-build-cache-proxy-enabled: false
+          arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ 
env.GUAVA }} build
+
+  linux-jdk22: # latest JDK version supported by ForbiddenAPIs plugin, keep 
this updated (see https://jdk.java.net/)
     if: github.event.action != 'labeled'
-    name: 'Linux (JDK 19)'
+    name: 'Linux (JDK 22)'
     runs-on: ubuntu-latest
     env:
       GUAVA: '21.0' # oldest Guava
@@ -230,10 +290,10 @@ jobs:
       - uses: actions/checkout@v3
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 19'
+      - name: 'Set up JDK 22'
         uses: actions/setup-java@v2
         with:
-          java-version: 19
+          java-version: 22
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -293,16 +353,16 @@ jobs:
 
   mac:
     if: github.event.action != 'labeled'
-    name: 'macOS (JDK 19)'
+    name: 'macOS (JDK 21)'
     runs-on: macos-latest
     steps:
       - uses: actions/checkout@v3
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 19'
+      - name: 'Set up JDK 21'
         uses: actions/setup-java@v2
         with:
-          java-version: 19
+          java-version: 21
           distribution: 'zulu'
       - uses: burrunan/gradle-cache-action@v1
         name: Test
@@ -311,7 +371,7 @@ jobs:
           S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
           GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }}
         with:
-          job-id: jdk19
+          job-id: jdk21
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon build javadoc
       - name: 'sqlline and sqllsh'
diff --git a/build.gradle.kts b/build.gradle.kts
index 60d340ac34..be829ddbb6 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -811,6 +811,9 @@ allprojects {
                 inputs.property("java.vm.version", 
System.getProperty("java.vm.version"))
                 options.encoding = "UTF-8"
                 options.compilerArgs.add("-Xlint:deprecation")
+                // JDK 1.8 is deprecated 
https://bugs.openjdk.org/browse/JDK-8173605
+                // and now it requires -Xlint:-options to mute warnings about 
its deprecation
+                options.compilerArgs.add("-Xlint:-options")
                 if (werror) {
                     options.compilerArgs.add("-Werror")
                 }
diff --git a/core/src/main/java/org/apache/calcite/runtime/HttpUtils.java 
b/core/src/main/java/org/apache/calcite/runtime/HttpUtils.java
index 9191dc1a3a..23c4130de3 100644
--- a/core/src/main/java/org/apache/calcite/runtime/HttpUtils.java
+++ b/core/src/main/java/org/apache/calcite/runtime/HttpUtils.java
@@ -22,7 +22,7 @@ import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.net.HttpURLConnection;
-import java.net.URL;
+import java.net.URI;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.util.Map;
@@ -35,7 +35,7 @@ public class HttpUtils {
 
   public static HttpURLConnection getURLConnection(String url)
       throws IOException {
-    return (HttpURLConnection) new URL(url).openConnection();
+    return (HttpURLConnection) URI.create(url).toURL().openConnection();
   }
 
   public static void appendURLEncodedArgs(
diff --git a/core/src/main/java/org/apache/calcite/util/Sources.java 
b/core/src/main/java/org/apache/calcite/util/Sources.java
index d184650556..7cf91db5e9 100644
--- a/core/src/main/java/org/apache/calcite/util/Sources.java
+++ b/core/src/main/java/org/apache/calcite/util/Sources.java
@@ -82,7 +82,7 @@ public abstract class Sources {
 
   public static Source url(String url) {
     try {
-      return of(new URL(url));
+      return of(URI.create(url).toURL());
     } catch (MalformedURLException | IllegalArgumentException e) {
       throw new RuntimeException("Malformed URL: '" + url + "'", e);
     }
@@ -222,7 +222,7 @@ public abstract class Sources {
           // That is why java.net.URLEncoder.encode(java.lang.String, 
java.lang.String) is not
           // suitable because it replaces " " with "+".
           String encodedPath = new URI(null, null, filePath, 
null).getRawPath();
-          return new URL("file", null, 0, encodedPath);
+          return URI.create("file:" + encodedPath).toURL();
         } catch (MalformedURLException | URISyntaxException e) {
           throw new IllegalArgumentException("Unable to create URL for file " 
+ filePath, e);
         }
diff --git a/core/src/main/java/org/apache/calcite/util/Util.java 
b/core/src/main/java/org/apache/calcite/util/Util.java
index 0674009f7f..e08f8f5b75 100644
--- a/core/src/main/java/org/apache/calcite/util/Util.java
+++ b/core/src/main/java/org/apache/calcite/util/Util.java
@@ -69,6 +69,7 @@ import java.lang.reflect.Array;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
@@ -654,7 +655,7 @@ public class Util {
       }
     }
     path = "file://" + path;
-    return new URL(path);
+    return URI.create(path).toURL();
   }
 
   /**
diff --git a/gradle.properties b/gradle.properties
index e43da37095..49eb254a70 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -50,7 +50,7 @@ com.github.johnrengelman.shadow.version=5.1.0
 com.github.spotbugs.version=2.0.0
 com.github.vlsi.vlsi-release-plugins.version=1.90
 com.google.protobuf.version=0.8.10
-de.thetaphi.forbiddenapis.version=3.5.1
+de.thetaphi.forbiddenapis.version=3.7
 jacoco.version=0.8.12
 kotlin.version=1.9.22
 net.ltgt.errorprone.version=1.3.0
@@ -85,8 +85,8 @@ aggdesigner-algorithm.version=6.0
 apiguardian-api.version=1.1.2
 arrow-gandiva.version=15.0.0
 arrow.version=15.0.0
-asm.version=7.2
-byte-buddy.version=1.9.3
+asm.version=9.6
+byte-buddy.version=1.14.15
 cassandra-all.version=4.1.3
 cassandra-java-driver-core.version=4.17.0
 cassandra-unit.version=4.3.1.0
@@ -143,7 +143,7 @@ junit5.version=5.9.1
 kafka-clients.version=2.1.1
 kerby.version=1.1.1
 log4j2.version=2.17.1
-mockito.version=2.23.4
+mockito.version=3.12.4
 mongodb-driver-sync.version=4.10.2
 # 1.43.0 is the last version with Java 8 support
 mongo-java-server.version=1.43.0
diff --git a/site/_docs/howto.md b/site/_docs/howto.md
index 9304c153f6..02f8e7c12f 100644
--- a/site/_docs/howto.md
+++ b/site/_docs/howto.md
@@ -31,7 +31,7 @@ adapters.
 
 ## Building from a source distribution
 
-Prerequisite is Java (JDK 8, 11, 17 or 19)
+Prerequisite is Java (JDK 8, 11, 17, 21 or 22)
 and Gradle (version 8.7) on your path.
 
 Unpack the source distribution `.tar.gz` file,
@@ -51,7 +51,7 @@ tests  (but you should use the `gradle` command rather than
 ## Building from Git
 
 Prerequisites are git
-and Java (JDK 8, 11, 17 or 19) on your path.
+and Java (JDK 8, 11, 17, 21 or 22) on your path.
 
 Create a local copy of the GitHub repository,
 `cd` to its root directory,
diff --git 
a/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkDriver.java 
b/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkDriver.java
index 13b37abe16..7f9a5f07f8 100644
--- a/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkDriver.java
+++ b/splunk/src/main/java/org/apache/calcite/adapter/splunk/SplunkDriver.java
@@ -24,6 +24,7 @@ import org.apache.calcite.jdbc.CalciteConnection;
 import org.apache.calcite.linq4j.Enumerator;
 import org.apache.calcite.schema.SchemaPlus;
 
+import java.net.URI;
 import java.net.URL;
 import java.sql.Connection;
 import java.sql.SQLException;
@@ -77,7 +78,7 @@ public class SplunkDriver extends 
org.apache.calcite.jdbc.Driver {
           throw new IllegalArgumentException(
               "Must specify 'password' property");
         }
-        URL url2 = new URL(url1);
+        URL url2 = URI.create(url1).toURL();
         splunkConnection = new SplunkConnectionImpl(url2, user, password);
       }
     } catch (Exception e) {
diff --git 
a/splunk/src/main/java/org/apache/calcite/adapter/splunk/search/SplunkConnectionImpl.java
 
b/splunk/src/main/java/org/apache/calcite/adapter/splunk/search/SplunkConnectionImpl.java
index 9dcc92f5b2..d6414ee7e0 100644
--- 
a/splunk/src/main/java/org/apache/calcite/adapter/splunk/search/SplunkConnectionImpl.java
+++ 
b/splunk/src/main/java/org/apache/calcite/adapter/splunk/search/SplunkConnectionImpl.java
@@ -35,6 +35,7 @@ import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
@@ -68,7 +69,7 @@ public class SplunkConnectionImpl implements SplunkConnection 
{
 
   public SplunkConnectionImpl(String url, String username, String password)
       throws MalformedURLException {
-    this(new URL(url), username, password);
+    this(URI.create(url).toURL(), username, password);
   }
 
   public SplunkConnectionImpl(URL url, String username, String password) {
diff --git a/src/main/config/forbidden-apis/signatures.txt 
b/src/main/config/forbidden-apis/signatures.txt
index 98d477ed4c..8ff151b6f9 100644
--- a/src/main/config/forbidden-apis/signatures.txt
+++ b/src/main/config/forbidden-apis/signatures.txt
@@ -109,3 +109,11 @@ org.hamcrest.Matcher#matches(java.lang.Object)
 java.util.Locale#<init>(java.lang.String)
 java.util.Locale#<init>(java.lang.String,java.lang.String)
 java.util.Locale#<init>(java.lang.String,java.lang.String,java.lang.String)
+
+@defaultMessage Use "java.net.URI.toURL"
+java.net.URL#<init>(java.lang.String)
+java.net.URL#<init>(java.net.URL, java.lang.String)
+java.net.URL#<init>(java.net.URL, java.lang.String, java.net.URLStreamHandler)
+java.net.URL#<init>(java.lang.String, java.lang.String, int, java.lang.String)
+java.net.URL#<init>(java.lang.String, java.lang.String, java.lang.String)
+java.net.URL#<init>(java.lang.String, java.lang.String, int, java.lang.String, 
java.net.URLStreamHandler)

Reply via email to