Skip to content

Commit

Permalink
[CALCITE-5737] Support JDK 21 and JDK 22
Browse files Browse the repository at this point in the history
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
  • Loading branch information
snuyanzin committed May 26, 2024
1 parent 4def070 commit 09c0ef1
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildcache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
76 changes: 68 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -220,20 +254,46 @@ 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
steps:
- 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
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/apache/calcite/runtime/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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;
Expand All @@ -35,7 +35,7 @@ private 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(
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/apache/calcite/util/Sources.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static Source fromCharSource(CharSource source) {

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);
}
Expand Down Expand Up @@ -222,7 +222,7 @@ private static URL fileToUrl(File file) {
// 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);
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/calcite/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
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;
Expand Down Expand Up @@ -654,7 +655,7 @@ public static URL toURL(File file) throws MalformedURLException {
}
}
path = "file://" + path;
return new URL(path);
return URI.create(path).toURL();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions site/_docs/howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -77,7 +78,7 @@ protected SplunkDriver() {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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;
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/config/forbidden-apis/signatures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 09c0ef1

Please sign in to comment.