From 1a08849b59cd13c5aa9fd6575e76a028b03b94d1 Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Thu, 12 Oct 2023 20:23:25 +0200 Subject: [PATCH] Set the minimum Java version to 11. Deprecate an enumeration value used for identifying the Java 8 environment. --- CONTRIBUTING.md | 8 ++++---- .../jvm/src/main/kotlin/build-logic.java.gradle.kts | 2 +- docs/content/development/_index.md | 2 +- packaging/rpm/postgresql-jdbc.spec.tpl | 2 +- pgjdbc/build.gradle.kts | 3 ++- pgjdbc/reduced-pom.xml | 4 ++-- .../main/checkstyle/pgjdbc-eclipse-java-google-style.xml | 6 +++--- .../src/main/java/org/postgresql/core/JavaVersion.java | 9 ++++++--- .../java/org/postgresql/test/core/JavaVersionTest.java | 4 ---- settings.gradle.kts | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3b03eca20a..03c9642e84 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -158,7 +158,7 @@ For fields that have already been checked against null, use `@RequiresNonNull`. or `org.postgresql.util.internal.Nullness.castNonNull(T, String)`. * You can configure postfix completion in IntelliJ IDEA via `Preferences -> Editor -> General -> Postfix Completion` -key: `cnn`, applicable element type: `non-primitive`, `org.postgresql.util.internal.Nullness.castNonNull($EXPR$)`. +key: `cnn`, applicable element type: `non-primitive`, `org.postgresql.util.internal.Nullness.castNonNull($EXPR$)`. * The Checker Framework comes with an annotated JDK, however, there might be invalid annotations. In that cases, stub files can be placed to `/config/checkerframework` to override the annotations. @@ -182,7 +182,7 @@ This is explained in the [Java Language Specification](https://docs.oracle.com/j @Nullable String[] x; // array: nullable, elements: nullable - @Nullable String @Nullable [] x; + @Nullable String @Nullable [] x; // arrays: nullable, elements: nullable // x: non-nullable @@ -308,8 +308,8 @@ https://guides.github.com/introduction/flow/. Remember to test proposed PgJDBC patches when running against older PostgreSQL versions where possible, not just against the PostgreSQL you use yourself. -You also need to test your changes with older JDKs. PgJDBC must support JDK8 -("Java 1.8") and newer. +You also need to test your changes with older JDKs. PgJDBC must support JDK11 +("Java 11") and newer. You can get old JDK versions from the [Oracle Java Archive](http://www.oracle.com/technetwork/java/archive-139210.html). diff --git a/build-logic/jvm/src/main/kotlin/build-logic.java.gradle.kts b/build-logic/jvm/src/main/kotlin/build-logic.java.gradle.kts index 901e91de02..fff7297c10 100644 --- a/build-logic/jvm/src/main/kotlin/build-logic.java.gradle.kts +++ b/build-logic/jvm/src/main/kotlin/build-logic.java.gradle.kts @@ -72,7 +72,7 @@ tasks.configureEach { addBooleanOption("Xdoclint:all,-missing", true) // javadoc: error - The code being documented uses modules but the packages // defined in https://docs.oracle.com/javase/9/docs/api/ are in the unnamed module - source = "1.8" + source = "11" docEncoding = "UTF-8" charSet = "UTF-8" encoding = "UTF-8" diff --git a/docs/content/development/_index.md b/docs/content/development/_index.md index 1bbf4e7e4e..7690185dbf 100644 --- a/docs/content/development/_index.md +++ b/docs/content/development/_index.md @@ -12,7 +12,7 @@ The PostgreSQL JDBC driver has some unique properties that you should be aware o The following tools are required to build and test the driver: -* [Java 8 Standard Edition Development Kit](https://java.oracle.com) At least JDK 1.8 +* [Java 8 Standard Edition Development Kit](https://java.oracle.com) At least JDK 11 * [Gradle](https://gradle.org) At least 7.5 * [Git SCM](https://git-scm.com) * [A PostgreSQL instance](https://www.postgresql.org) to run the tests. diff --git a/packaging/rpm/postgresql-jdbc.spec.tpl b/packaging/rpm/postgresql-jdbc.spec.tpl index 5385e98aa1..7d9055af5e 100644 --- a/packaging/rpm/postgresql-jdbc.spec.tpl +++ b/packaging/rpm/postgresql-jdbc.spec.tpl @@ -58,7 +58,7 @@ Source0: https://repo1.maven.org/maven2/org/postgresql/postgresql/%{version}/pos Provides: pgjdbc = %version-%release BuildArch: noarch -BuildRequires: java-devel >= 1.8 +BuildRequires: java-devel >= 11 BuildRequires: maven-local BuildRequires: maven-plugin-bundle BuildRequires: classloader-leak-test-framework diff --git a/pgjdbc/build.gradle.kts b/pgjdbc/build.gradle.kts index 71810b296f..ff369e4af1 100644 --- a/pgjdbc/build.gradle.kts +++ b/pgjdbc/build.gradle.kts @@ -172,6 +172,7 @@ val generateGettextSources by tasks.registering { } tasks.compileJava { + options.release = 11 if (enableGettext) { dependsOn(generateGettextSources) } else { @@ -248,7 +249,7 @@ val osgiJar by tasks.registering(Bundle::class) { Bundle-SymbolicName: org.postgresql.jdbc Bundle-Name: PostgreSQL JDBC Driver Bundle-Copyright: Copyright (c) 2003-2020, PostgreSQL Global Development Group - Require-Capability: osgi.ee;filter:="(&(|(osgi.ee=J2SE)(osgi.ee=JavaSE))(version>=1.8))" + Require-Capability: osgi.ee;filter:="(&(|(osgi.ee=J2SE)(osgi.ee=JavaSE))(version>=11))" Provide-Capability: osgi.service;effective:=active;objectClass=org.osgi.service.jdbc.DataSourceFactory;osgi.jdbc.driver.class=org.postgresql.Driver;osgi.jdbc.driver.name=PostgreSQL JDBC Driver """ ) diff --git a/pgjdbc/reduced-pom.xml b/pgjdbc/reduced-pom.xml index 8b8a775265..10bace0703 100644 --- a/pgjdbc/reduced-pom.xml +++ b/pgjdbc/reduced-pom.xml @@ -27,8 +27,8 @@ - - 1.8 + + 11 UTF-8 ${encoding} ${encoding} diff --git a/pgjdbc/src/main/checkstyle/pgjdbc-eclipse-java-google-style.xml b/pgjdbc/src/main/checkstyle/pgjdbc-eclipse-java-google-style.xml index 958104da54..ce57cdfeb8 100644 --- a/pgjdbc/src/main/checkstyle/pgjdbc-eclipse-java-google-style.xml +++ b/pgjdbc/src/main/checkstyle/pgjdbc-eclipse-java-google-style.xml @@ -163,7 +163,7 @@ - + @@ -184,7 +184,7 @@ - + @@ -252,7 +252,7 @@ - + diff --git a/pgjdbc/src/main/java/org/postgresql/core/JavaVersion.java b/pgjdbc/src/main/java/org/postgresql/core/JavaVersion.java index 43d52cc2b9..db92dc2ce8 100644 --- a/pgjdbc/src/main/java/org/postgresql/core/JavaVersion.java +++ b/pgjdbc/src/main/java/org/postgresql/core/JavaVersion.java @@ -7,7 +7,13 @@ public enum JavaVersion { // Note: order is important, + + /** + * @deprecated Java 1.8 is not supported anymore. + */ + @Deprecated v1_8, + other; private static final JavaVersion RUNTIME_VERSION = from(System.getProperty("java.version")); @@ -29,9 +35,6 @@ public static JavaVersion getRuntimeVersion() { * @return JavaVersion enum */ public static JavaVersion from(String version) { - if (version.startsWith("1.8")) { - return v1_8; - } return other; } } diff --git a/pgjdbc/src/test/java/org/postgresql/test/core/JavaVersionTest.java b/pgjdbc/src/test/java/org/postgresql/test/core/JavaVersionTest.java index ebac017a08..a2aac28299 100644 --- a/pgjdbc/src/test/java/org/postgresql/test/core/JavaVersionTest.java +++ b/pgjdbc/src/test/java/org/postgresql/test/core/JavaVersionTest.java @@ -7,7 +7,6 @@ import org.postgresql.core.JavaVersion; -import org.junit.Assert; import org.junit.Test; public class JavaVersionTest { @@ -17,8 +16,5 @@ public void testGetRuntimeVersion() { String msg = "java.version = " + currentVersion + ", JavaVersion.getRuntimeVersion() = " + JavaVersion.getRuntimeVersion(); System.out.println(msg); - if (currentVersion.startsWith("1.8")) { - Assert.assertEquals(msg, JavaVersion.v1_8, JavaVersion.getRuntimeVersion()); - } } } diff --git a/settings.gradle.kts b/settings.gradle.kts index c74f15cc5d..e23f1335b8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,7 +17,7 @@ pluginManagement { id("com.github.vlsi.stage-vote-release") version "1.86" id("org.nosphere.gradle.github.actions") version "1.3.2" id("me.champeau.jmh") version "0.7.1" - kotlin("jvm") version "1.8.21" + kotlin("jvm") version "11" } }