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

mck pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 86604f5038 Prepare for JDK17 experimental support
86604f5038 is described below

commit 86604f50388d7e2cec68196fcf5f82a334e68ae2
Author: Mick Semb Wever <[email protected]>
AuthorDate: Sat Jan 21 12:46:56 2023 +0100

    Prepare for JDK17 experimental support
    
    Removes the use of CASSANDRA_USE_JDK11 and introduces the build.xml 
properties `java.default` and `java.supported`.
    
     patch by Mick Semb Wever; reviewed by Ekaterina Dimitrova for 
CASSANDRA-18179
---
 CHANGES.txt                                        |   1 +
 build.xml                                          | 116 ++++++--------------
 .../cassandra/pages/getting_started/java11.adoc    | 118 +++------------------
 pylib/cassandra-cqlsh-tests.sh                     |  13 +--
 .../apache/cassandra/anttasks/JdkProperties.java   |  33 ++++++
 5 files changed, 84 insertions(+), 197 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 793c1ab1fd..f36442097d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.2
+ * Prepare for JDK17 experimental support (CASSANDRA-18179)
  * Remove Scripted UDFs internals; hooks to be added later in CASSANDRA-17281 
(CASSANDRA-18252)
  * Update JNA to 5.13.0 (CASSANDRA-18050)
  * Make virtual tables decide if they implicitly enable ALLOW FILTERING 
(CASSANDRA-18238)
diff --git a/build.xml b/build.xml
index 06b83c08de..d9206e98e0 100644
--- a/build.xml
+++ b/build.xml
@@ -37,6 +37,15 @@
     <property name="scm.developerConnection" 
value="scm:https://gitbox.apache.org/repos/asf/cassandra.git"/>
     <property name="scm.url" 
value="https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree"/>
 
+    <!-- JDKs supported.
+        All releases are built with the default JDK.
+        Builds with non-default JDKs are considered experimental and for 
development and testing purposes.
+        When building, javac's source and target flags are set to the jdk 
used, so lower JDKs are not supported at runtime.
+        The use of both CASSANDRA_USE_JDK11 and use-jdk11 is deprecated.
+    -->
+    <property name="java.default" value="1.8" />
+    <property name="java.supported" value="1.8,11,17" />
+
     <!-- directory details -->
     <property name="basedir" value="."/>
     <property name="build.src" value="${basedir}/src"/>
@@ -156,21 +165,16 @@
                 <javac srcdir="test/anttasks" destdir="${test.classes}" 
includeantruntime="true"/>
                 <taskdef name="KeepBriefBrief" 
classname="org.apache.cassandra.anttasks.KeepBriefBrief" 
classpath="${test.classes}"/>
                 <KeepBriefBrief property="cassandra.keepBriefBrief"/>
+                <taskdef name="JdkProperties" 
classname="org.apache.cassandra.anttasks.JdkProperties" 
classpath="${test.classes}"/>
+                <JdkProperties/>
         </sequential>
     </macrodef>
 
-    <condition property="java.version.8">
-        <equals arg1="${ant.java.version}" arg2="1.8"/>
-    </condition>
-    <condition property="java.version.11">
-      <!-- This includes every JDK other than 8; so JDK 9 is flagged as JDK 
11, and JDK 17 is as well... at the moment this is desired behavior
-      and may be relooked at once JDK 8 support is dropped -->
-        <not><isset property="java.version.8"/></not>
-    </condition>
-    <fail message="Unsupported JDK version used: 
${ant.java.version}"><condition><not><or>
-        <isset property="java.version.8"/>
-        <isset property="java.version.11"/>
-    </or></not></condition></fail>
+    <fail message="Unsupported JDK version used: ${ant.java.version}">
+        <condition><not><contains string="${java.supported}" 
substring="${ant.java.version}"/></not></condition>
+    </fail>
+    <condition property="is.java.default"><equals arg1="${ant.java.version}" 
arg2="${java.default}"/></condition>
+    <echo unless:true="${is.java.default}" message="Non default JDK version 
used: ${ant.java.version}"/>
 
     <condition property="arch_x86">
       <equals arg1="${os.arch}" arg2="x86" />
@@ -262,17 +266,6 @@
         </not>
     </condition>
 
-    <condition property="build.java.11">
-        <istrue value="${use.jdk11}"/>
-    </condition>
-
-    <condition property="source.version" value="8" else="11">
-        <equals arg1="${java.version.8}" arg2="true"/>
-    </condition>
-    <condition property="target.version" value="8" else="11">
-        <equals arg1="${java.version.8}" arg2="true"/>
-    </condition>
-
     <!--
          Add all the dependencies.
     -->
@@ -314,57 +307,10 @@
     </sequential>
   </macrodef>
 
-    <target name="validate-build-conf">
-        <condition property="use-jdk11">
-            <or>
-                <isset property="build.java.11"/>
-                <istrue value="${env.CASSANDRA_USE_JDK11}"/>
-            </or>
-        </condition>
-        <fail message="Inconsistent JDK11 options set">
-            <condition>
-                    <and>
-                        <istrue value="${env.CASSANDRA_USE_JDK11}"/>
-                        <isset property="use.jdk11"/>
-                        <not>
-                            <istrue value="${use.jdk11}"/>
-                        </not>
-                    </and>
-            </condition>
-                </fail>
-        <fail message="Inconsistent JDK11 options set">
-            <condition>
-                    <and>
-                        <isset property="env.CASSANDRA_USE_JDK11"/>
-                        <not>
-                            <istrue value="${env.CASSANDRA_USE_JDK11}"/>
-                        </not>
-                        <istrue value="${use.jdk11}"/>
-                    </and>
-            </condition>
-        </fail>
-        <fail message="-Duse.jdk11=true or $CASSANDRA_USE_JDK11=true cannot be 
set when building from java 8">
-            <condition>
-                <not><or>
-                    <not><isset property="java.version.8"/></not>
-                    <not><isset property="use-jdk11"/></not>
-                </or></not>
-            </condition>
-        </fail>
-        <fail message="-Duse.jdk11=true or $CASSANDRA_USE_JDK11=true must be 
set when building from java 11">
-            <condition>
-                <not><or>
-                    <isset property="java.version.8"/>
-                    <isset property="use-jdk11"/>
-                </or></not>
-            </condition>
-        </fail>
-    </target>
-
     <!--
         Setup the output directories.
     -->
-    <target name="init" depends="validate-build-conf">
+    <target name="init" >
         <fail unless="is.source.artifact"
             message="Not a source artifact, stopping here." />
         <mkdir dir="${build.classes.main}"/>
@@ -492,11 +438,11 @@
 
     <target name="_build_java">
         <!-- Note: we cannot use javac's 'release' option, as that does not 
allow accessing sun.misc.Unsafe nor
-        Nashorn's ClassFilter class as any javac modules option is invalid for 
relase 8. -->
-        <echo message="Compiling for Java ${target.version}..."/>
+        Nashorn's ClassFilter class as any javac modules option is invalid for 
release 8. -->
+        <echo message="Compiling for Java ${ant.java.version}..."/>
         <javac
                debug="true" debuglevel="${debuglevel}" encoding="utf-8"
-               destdir="${build.classes.main}" includeantruntime="false" 
source="${source.version}" target="${target.version}">
+               destdir="${build.classes.main}" includeantruntime="false" 
source="${ant.java.version}" target="${ant.java.version}">
             <src path="${build.src.java}"/>
             <src path="${build.src.gen-java}"/>
             <compilerarg value="-XDignore.symbol.file"/>
@@ -528,7 +474,7 @@
 
     <target name="stress-build-test" depends="stress-build" 
description="Compile stress tests">
         <javac debug="true" debuglevel="${debuglevel}" 
destdir="${stress.test.classes}"
-               source="${source.version}" target="${target.version}"
+               source="${ant.java.version}" target="${ant.java.version}"
                includeantruntime="false" encoding="utf-8">
             <classpath>
                 <path refid="cassandra.classpath.test"/>
@@ -545,7 +491,7 @@
     <target name="_stress_build">
        <mkdir dir="${stress.build.classes}" />
         <javac compiler="modern" debug="true" debuglevel="${debuglevel}"
-               source="${source.version}" target="${target.version}"
+               source="${ant.java.version}" target="${ant.java.version}"
                encoding="utf-8" destdir="${stress.build.classes}" 
includeantruntime="true">
             <src path="${stress.build.src}" />
             <classpath>
@@ -586,7 +532,7 @@
 
     <target name="fqltool-build-test" depends="fqltool-build" 
description="Compile fqltool tests">
         <javac debug="true" debuglevel="${debuglevel}" 
destdir="${fqltool.test.classes}"
-               source="${source.version}" target="${target.version}"
+               source="${ant.java.version}" target="${ant.java.version}"
                includeantruntime="false" encoding="utf-8">
             <classpath>
                 <path refid="cassandra.classpath.test"/>
@@ -603,7 +549,7 @@
     <target name="_fqltool_build">
        <mkdir dir="${fqltool.build.classes}" />
         <javac compiler="modern" debug="true" debuglevel="${debuglevel}"
-               source="${source.version}" target="${target.version}"
+               source="${ant.java.version}" target="${ant.java.version}"
                encoding="utf-8" destdir="${fqltool.build.classes}" 
includeantruntime="true">
             <src path="${fqltool.build.src}" />
             <classpath>
@@ -640,7 +586,7 @@
     <target name="_simulator-asm_build">
        <mkdir dir="${simulator-asm.build.classes}" />
         <javac compiler="modern" debug="true" debuglevel="${debuglevel}"
-               source="${source.version}" target="${target.version}"
+               source="${ant.java.version}" target="${ant.java.version}"
                encoding="utf-8" destdir="${simulator-asm.build.classes}" 
includeantruntime="true">
             <src path="${simulator-asm.build.src}" />
             <classpath>
@@ -657,7 +603,7 @@
     <target name="_simulator-bootstrap_build">
        <mkdir dir="${simulator-bootstrap.build.classes}" />
         <javac compiler="modern" debug="true" debuglevel="${debuglevel}"
-               source="${source.version}" target="${target.version}"
+               source="${ant.java.version}" target="${ant.java.version}"
                encoding="utf-8" destdir="${simulator-bootstrap.build.classes}" 
includeantruntime="true">
             <src path="${simulator-bootstrap.build.src}" />
             <classpath>
@@ -1011,8 +957,8 @@
      debuglevel="${debuglevel}"
      destdir="${test.classes}"
      includeantruntime="true"
-     source="${source.version}"
-     target="${target.version}"
+     source="${ant.java.version}"
+     target="${ant.java.version}"
      encoding="utf-8">
      <classpath>
         <path refid="cassandra.classpath.test"/>
@@ -1129,7 +1075,7 @@
         <jvmarg value="-Dcassandra.test.sstableformatdevelopment=true"/>
         <!-- The first time SecureRandom initializes can be slow if it blocks 
on /dev/random -->
         <jvmarg value="-Djava.security.egd=file:/dev/urandom" />
-        <jvmarg value="-Dcassandra.testtag=@{testtag}"/>
+        <jvmarg value="-Dcassandra.testtag=@{testtag}.jdk${ant.java.version}"/>
         <jvmarg value="-Dcassandra.keepBriefBrief=${cassandra.keepBriefBrief}" 
/>
         <jvmarg value="-Dcassandra.strict.runtime.checks=true" />
         <jvmarg 
value="-Dcassandra.reads.thresholds.coordinator.defensive_checks_enabled=true" 
/> <!-- enable defensive checks -->
@@ -1923,9 +1869,9 @@
            failonerror="true"
             maxmemory="512m">
             <arg value="-source"/>
-           <arg value="${source.version}" />
+           <arg value="${java.default}" />
            <arg value="-target"/>
-           <arg value="${target.version}" />
+           <arg value="${ant.java.version}" />
            <arg value="-d" />
             <arg value="none" />
            <arg value="-proc:none" />
diff --git a/doc/modules/cassandra/pages/getting_started/java11.adoc 
b/doc/modules/cassandra/pages/getting_started/java11.adoc
index a61a57faf9..ded5c2eab1 100644
--- a/doc/modules/cassandra/pages/getting_started/java11.adoc
+++ b/doc/modules/cassandra/pages/getting_started/java11.adoc
@@ -26,11 +26,15 @@ Table 1 : Support Matrix for Java
 |===
 | |Java 8 (Run) |Java 11 (Run)
 |Java 8 (Build) |Supported |Supported
-|Java 11(Build) |Not Supported |Supported
+|Java 11(Build) |Not Supported |Experimental
 |===
 
-Essentially Apache 4.0 source code built with Java 11 cannot be run with
-Java 8. Next, we shall discuss using each of Java 8 and 11 to build and
+Apache 4.0 source code built with Java 11 cannot be run with
+Java 8.
+
+All binary releases are built with Java 8.
+
+Next, we shall discuss using each of Java 8 and 11 to build and
 run Apache Cassandra 4.0.
 
 == Using Java 8 to Build
@@ -42,18 +46,10 @@ RedHat Linux the command is as follows:
 $ sudo yum install java-1.8.0-openjdk-devel
 ....
 
-Set `JAVA_HOME` and `JRE_HOME` environment variables in the shell bash
-script. First, open the bash script:
-
-....
-$ sudo vi ~/.bashrc
-....
-
-Set the environment variables including the `PATH`.
+Set the environment variables `JAVA_HOME` and `PATH`.
 
 ....
 $ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
-$ export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk/jre
 $ export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
 ....
 
@@ -68,7 +64,7 @@ If Cassandra is already running stop Cassandra with the 
following
 command.
 
 ....
-[ec2-user@ip-172-30-3-146 bin]$ ./nodetool stopdaemon
+$ ./nodetool stopdaemon
 ....
 
 Build the source code from the `cassandra` directory, which has the
@@ -143,53 +139,19 @@ and install Java 11 on RedHat Linux run the following 
command.
 $ yum install java-11-openjdk-devel
 ....
 
-Set the environment variables in the bash script for Java 11. The first
-command is to open the bash script.
+Set the environment variables `JAVA_HOME` and `PATH`.
 
 ....
-$ sudo vi ~/.bashrc 
 $ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
-$ export JRE_HOME=/usr/lib/jvm/java-11-openjdk/jre
 $ export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
 ....
 
-To build source code with Java 11 one of the following two options must
-be used.
-
-____
-[arabic]
-. {blank}
-+
-Include Apache Ant command-line option `-Duse.jdk=11` as follows:::
-....
-$ ant -Duse.jdk=11
-....
-. {blank}
-+
-Set environment variable `CASSANDRA_USE_JDK11` to `true`:::
-....
-$ export CASSANDRA_USE_JDK11=true
-....
-____
-
-As an example, set the environment variable `CASSANDRA_USE_JDK11` to
-`true`.
-
-....
-[ec2-user@ip-172-30-3-146 cassandra]$ export CASSANDRA_USE_JDK11=true
-[ec2-user@ip-172-30-3-146 cassandra]$ ant
-Buildfile: /home/ec2-user/cassandra/build.xml
-....
-
-Or, set the command-line option.
-
-....
-[ec2-user@ip-172-30-3-146 cassandra]$ ant -Duse.jdk11=true
-....
-
-The build output should include the following.
+The build output should now include the following.
 
 ....
+[echo] Non default JDK version used: 11
+...
+...
 _build_java:
     [echo] Compiling for Java 11
 ...
@@ -215,36 +177,20 @@ jar:
 
 BUILD SUCCESSFUL
 Total time: 1 minute 3 seconds
-[ec2-user@ip-172-30-3-146 cassandra]$ 
 ....
 
 == Common Issues
 
-One of the two options mentioned must be used to compile with JDK 11 or
-the build fails and the following error message is output.
-
-....
-[ec2-user@ip-172-30-3-146 cassandra]$ ant
-Buildfile: /home/ec2-user/cassandra/build.xml
-validate-build-conf:
-
-BUILD FAILED
-/home/ec2-user/cassandra/build.xml:293: -Duse.jdk11=true or 
$CASSANDRA_USE_JDK11=true must 
-be set when building from java 11
-Total time: 1 second
-[ec2-user@ip-172-30-3-146 cassandra]$ 
-....
-
 The Java 11 built Apache Cassandra 4.0 source code may be run with Java
 11 only. If a Java 11 built code is run with Java 8 the following error
 message gets output.
 
 ....
-[root@localhost ~]# ssh -i cassandra.pem 
[email protected]
+# ssh -i cassandra.pem [email protected]
 Last login: Wed Jul 31 20:47:26 2019 from 75.155.255.51
-[ec2-user@ip-172-30-3-146 ~]$ echo $JAVA_HOME
+$ echo $JAVA_HOME
 /usr/lib/jvm/java-1.8.0-openjdk
-[ec2-user@ip-172-30-3-146 ~]$ cassandra 
+$ cassandra 
 ...
 ...
 Error: A JNI error has occurred, please check your installation and try again
@@ -258,33 +204,3 @@ class file versions up to 52.0
 ...
 ....
 
-The `CASSANDRA_USE_JDK11` variable or the command-line option
-`-Duse.jdk11` cannot be used to build with Java 8. To demonstrate set
-`JAVA_HOME` to version 8.
-
-....
-[root@localhost ~]# ssh -i cassandra.pem 
[email protected]
-Last login: Wed Jul 31 21:41:50 2019 from 75.155.255.51
-[ec2-user@ip-172-30-3-146 ~]$ echo $JAVA_HOME
-/usr/lib/jvm/java-1.8.0-openjdk
-....
-
-Set the `CASSANDRA_USE_JDK11=true` or command-line option
-`-Duse.jdk11=true`. Subsequently, run Apache Ant to start the build. The
-build fails with error message listed.
-
-....
-[ec2-user@ip-172-30-3-146 ~]$ cd 
-cassandra
-[ec2-user@ip-172-30-3-146 cassandra]$ export CASSANDRA_USE_JDK11=true
-[ec2-user@ip-172-30-3-146 cassandra]$ ant 
-Buildfile: /home/ec2-user/cassandra/build.xml
-
-validate-build-conf:
-
-BUILD FAILED
-/home/ec2-user/cassandra/build.xml:285: -Duse.jdk11=true or 
$CASSANDRA_USE_JDK11=true cannot 
-be set when building from java 8
-
-Total time: 0 seconds
-....
diff --git a/pylib/cassandra-cqlsh-tests.sh b/pylib/cassandra-cqlsh-tests.sh
index 4db07cf61b..f6b1f21654 100755
--- a/pylib/cassandra-cqlsh-tests.sh
+++ b/pylib/cassandra-cqlsh-tests.sh
@@ -41,18 +41,9 @@ export CCM_HEAP_NEWSIZE="200M"
 export CCM_CONFIG_DIR=${WORKSPACE}/.ccm
 export NUM_TOKENS="16"
 export CASSANDRA_DIR=${WORKSPACE}
-export TESTSUITE_NAME="cqlshlib.${PYTHON_VERSION}"
 
-if [ -z "$CASSANDRA_USE_JDK11" ]; then
-    export CASSANDRA_USE_JDK11=false
-fi
-
-if [ "$CASSANDRA_USE_JDK11" = true ] ; then
-    TESTSUITE_NAME="${TESTSUITE_NAME}.jdk11"
-else
-    TESTSUITE_NAME="${TESTSUITE_NAME}.jdk8"
-    unset JAVA11_HOME
-fi
+java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | awk 
-F. '{print $1}')
+export TESTSUITE_NAME="cqlshlib.${PYTHON_VERSION}.jdk${java_version}"
 
 ant -buildfile ${CASSANDRA_DIR}/build.xml realclean
 # Loop to prevent failure due to maven-ant-tasks not downloading a jar..
diff --git a/test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java 
b/test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java
new file mode 100644
index 0000000000..59aba5e464
--- /dev/null
+++ b/test/anttasks/org/apache/cassandra/anttasks/JdkProperties.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.anttasks;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+public class JdkProperties extends Task
+{
+
+    public void execute()
+    {
+        Project project = getProject();
+        project.setNewProperty("java.version." + 
project.getProperty("ant.java.version"), "true");
+        project.setNewProperty("use-jdk" + 
project.getProperty("ant.java.version"), "true");
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to