Skip to content

Commit

Permalink
Bump the minimum Java version to Java 11 (elastic#40754)
Browse files Browse the repository at this point in the history
With the 8.0.0 release of Elasticsearch we will bump the minimum
required Java to Java 11. This commit puts this into effect on the
master branch.
  • Loading branch information
jasontedor authored Apr 7, 2019
1 parent e10f779 commit 8deadfb
Show file tree
Hide file tree
Showing 32 changed files with 129 additions and 568 deletions.
2 changes: 1 addition & 1 deletion .ci/java-versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# are 'java' or 'openjdk' followed by the major release number.

ES_BUILD_JAVA=openjdk12
ES_RUNTIME_JAVA=java8
ES_RUNTIME_JAVA=java11
GRADLE_TASK=build

3 changes: 0 additions & 3 deletions .ci/matrix-runtime-javas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
# or 'openjdk' followed by the major release number.

ES_RUNTIME_JAVA:
- java8
- java8fips
- java11
- java12
- openjdk12
- zulu8
- zulu11
- zulu12
6 changes: 5 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ def linux_common(config,
touch /is_vagrant_vm # for consistency between linux and windows
SHELL

config.vm.provision 'jdk-11', type: 'shell', inline: <<-SHELL
curl -sSL https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz | tar xz -C /opt/
SHELL

# This prevents leftovers from previous tests using the
# same VM from messing up the current test
config.vm.provision 'clean es installs in tmp', run: 'always', type: 'shell', inline: <<-SHELL
Expand Down Expand Up @@ -342,7 +346,7 @@ def sh_install_deps(config,
}
cat \<\<JAVA > /etc/profile.d/java_home.sh
if [ -z "\\\$JAVA_HOME" ]; then
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
export JAVA_HOME=/opt/jdk-11.0.2
fi
export SYSTEM_JAVA_HOME=\\\$JAVA_HOME
unset JAVA_HOME
Expand Down
10 changes: 1 addition & 9 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ dependencies {
compile 'com.perforce:p4java:2012.3.551082' // THIS IS SUPPOSED TO BE OPTIONAL IN THE FUTURE....
compile 'org.apache.rat:apache-rat:0.11'
compile "org.elasticsearch:jna:4.5.1"
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
compile 'com.github.jengelman.gradle.plugins:shadow:4.0.3'
compile 'de.thetaphi:forbiddenapis:2.6'
compile 'com.avast.gradle:gradle-docker-compose-plugin:0.8.12'
testCompile "junit:junit:${props.getProperty('junit')}"
Expand Down Expand Up @@ -199,14 +199,6 @@ if (project != rootProject) {
into localDownloads
}

unitTest {
// The test task is configured to runtimeJava version, but build-tools doesn't support all of them, so test
// with compiler instead on the ones that are too old.
if (project.runtimeJavaVersion <= JavaVersion.VERSION_1_10) {
jvm = "${project.compilerJavaHome}/bin/java"
}
}

// This can't be an RandomizedTestingTask because we can't yet reference it
task integTest(type: Test) {
// integration test requires the local testing repo for example plugin builds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,7 @@ class BuildPlugin implements Plugin<Project> {

/** Adds compiler settings to the project */
static void configureCompile(Project project) {
if (project.compilerJavaVersion < JavaVersion.VERSION_1_10) {
project.ext.compactProfile = 'compact3'
} else {
project.ext.compactProfile = 'full'
}
project.ext.compactProfile = 'full'
project.afterEvaluate {
project.tasks.withType(JavaCompile) {
final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(it.targetCompatibility)
Expand All @@ -738,13 +734,6 @@ class BuildPlugin implements Plugin<Project> {
options.fork = true
options.forkOptions.javaHome = compilerJavaHomeFile
}
if (targetCompatibilityVersion == JavaVersion.VERSION_1_8) {
// compile with compact 3 profile by default
// NOTE: this is just a compile time check: does not replace testing with a compact3 JRE
if (project.compactProfile != 'full') {
options.compilerArgs << '-profile' << project.compactProfile
}
}
/*
* -path because gradle will send in paths that don't always exist.
* -missing because we have tons of missing @returns and @param.
Expand Down Expand Up @@ -935,9 +924,7 @@ class BuildPlugin implements Plugin<Project> {
File heapdumpDir = new File(project.buildDir, 'heapdump')
heapdumpDir.mkdirs()
jvmArg '-XX:HeapDumpPath=' + heapdumpDir
if (project.runtimeJavaVersion >= JavaVersion.VERSION_1_9) {
jvmArg '--illegal-access=warn'
}
jvmArg '--illegal-access=warn'
argLine System.getProperty('tests.jvm.argline')

// we use './temp' since this is per JVM and tests are forbidden from writing to CWD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ class PrecommitTasks {
ExportElasticsearchBuildResourcesTask buildResources = project.tasks.getByName('buildResources')
project.tasks.withType(CheckForbiddenApis) {
dependsOn(buildResources)
targetCompatibility = project.runtimeJavaVersion >= JavaVersion.VERSION_1_9 ?
project.runtimeJavaVersion.getMajorVersion() : project.runtimeJavaVersion
targetCompatibility = project.runtimeJavaVersion.getMajorVersion()
if (project.runtimeJavaVersion > JavaVersion.VERSION_11) {
doLast {
project.logger.info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class VagrantTestPlugin implements Plugin<Project> {
else
test_args=( "\$@" )
fi
java -cp "\$PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\${test_args[@]}"
"\$SYSTEM_JAVA_HOME"/bin/java -cp "\$PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\${test_args[@]}"
"""
}
Task createWindowsRunnerScript = project.tasks.create('createWindowsRunnerScript', FileContentsTask) {
Expand All @@ -294,7 +294,7 @@ class VagrantTestPlugin implements Plugin<Project> {
} else {
\$testArgs = \$args
}
java -cp "\$Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
"\$Env:SYSTEM_JAVA_HOME"/bin/java -cp "\$Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
exit \$LASTEXITCODE
"""
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/resources/minimumCompilerVersion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12
12
2 changes: 1 addition & 1 deletion buildSrc/src/main/resources/minimumRuntimeVersion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8
11
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class JavaVersion {

public static final List<Integer> CURRENT = parse(System.getProperty("java.specification.version"));
public static final List<Integer> JAVA_8 = parse("1.8");
public static final List<Integer> JAVA_11 = parse("11");

static List<Integer> parse(final String value) {
if (!value.matches("^0*[0-9]+(\\.[0-9]+)*$")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public static void main(final String[] args) {
if (args.length != 0) {
throw new IllegalArgumentException("expected zero arguments but was " + Arrays.toString(args));
}
if (JavaVersion.compare(JavaVersion.CURRENT, JavaVersion.JAVA_8) < 0) {
if (JavaVersion.compare(JavaVersion.CURRENT, JavaVersion.JAVA_11) < 0) {
final String message = String.format(
Locale.ROOT,
"the minimum required Java version is 8; your Java version from [%s] does not meet this requirement",
"the minimum required Java version is 11; your Java version from [%s] does not meet this requirement",
System.getProperty("java.home"));
errPrintln(message);
exit(1);
Expand Down
4 changes: 2 additions & 2 deletions docs/Versions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
:lucene_version: 8.0.0
:lucene_version_path: 8_0_0
:branch: master
:jdk: 1.8.0_131
:jdk_major: 8
:jdk: 11.0.2
:jdk_major: 11
:build_flavor: default
:build_type: tar

Expand Down
2 changes: 2 additions & 0 deletions docs/reference/migration/migrate_8_0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ coming[8.0.0]
* <<breaking_80_analysis_changes>>
* <<breaking_80_discovery_changes>>
* <<breaking_80_mappings_changes>>
* <<breaking_80_packaging_changes>>
* <<breaking_80_snapshots_changes>>
* <<breaking_80_security_changes>>
* <<breaking_80_java_changes>>
Expand Down Expand Up @@ -42,6 +43,7 @@ Elasticsearch 7.x in order to be readable by Elasticsearch 8.x.
include::migrate_8_0/analysis.asciidoc[]
include::migrate_8_0/discovery.asciidoc[]
include::migrate_8_0/mappings.asciidoc[]
include::migrate_8_0/packaging.asciidoc[]
include::migrate_8_0/snapshots.asciidoc[]
include::migrate_8_0/security.asciidoc[]
include::migrate_8_0/java.asciidoc[]
11 changes: 11 additions & 0 deletions docs/reference/migration/migrate_8_0/packaging.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[float]
[[breaking_80_packaging_changes]]
=== Packaging changes

[float]
//tag::notable-breaking-changes[]
==== Java 11 is required

Java 11 or higher is now required to run Elasticsearch and any of its command
line tools.
//end::notable-breaking-changes[]
43 changes: 0 additions & 43 deletions libs/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,6 @@ apply plugin: 'nebula.maven-scm'

archivesBaseName = 'elasticsearch-core'

// we want to keep the JDKs in our IDEs set to JDK 8 until minimum JDK is bumped to 9 so we do not include this source set in our IDEs
if (!isEclipse && !isIdea) {
sourceSets {
java9 {
java {
srcDirs = ['src/main/java9']
}
}
}

configurations {
java9Compile.extendsFrom(compile)
}

dependencies {
java9Compile sourceSets.main.output
}

compileJava9Java {
sourceCompatibility = 9
targetCompatibility = 9
}

forbiddenApisJava9 {
if (project.runtimeJavaVersion < JavaVersion.VERSION_1_9) {
targetCompatibility = JavaVersion.VERSION_1_9.getMajorVersion()
}
replaceSignatureFiles 'jdk-signatures'
}

jar {
metaInf {
into 'versions/9'
from sourceSets.java9.output
}
manifest.attributes('Multi-Release': 'true')
}
}

publishing {
publications {
nebula {
Expand All @@ -75,10 +36,6 @@ dependencies {
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"

if (!isEclipse && !isIdea) {
java9Compile sourceSets.main.output
}

if (isEclipse == false || project.path == ":libs:core-tests") {
testCompile("org.elasticsearch.test:framework:${version}") {
exclude group: 'org.elasticsearch', module: 'elasticsearch-core'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,30 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Objects;

/**
* Simple utility methods for file and stream copying.
* All copy methods use a block size of 4096 bytes,
* and close all affected streams when done.
* Simple utility methods for file and stream copying. All copy methods close all affected streams when done.
* <p>
* Mainly for use within the framework,
* but also useful for application code.
* Mainly for use within the framework, but also useful for application code.
*/
public class Streams {

private Streams() {

}

/**
* Copy the contents of the given InputStream to the given OutputStream.
* Closes both streams when done.
* Copy the contents of the given InputStream to the given OutputStream. Closes both streams when done.
*
* @param in the stream to copy from
* @param out the stream to copy to
* @return the number of bytes copied
* @throws IOException in case of I/O errors
*/
public static long copy(final InputStream in, final OutputStream out) throws IOException {
Objects.requireNonNull(in, "No InputStream specified");
Objects.requireNonNull(out, "No OutputStream specified");
final byte[] buffer = new byte[8192];
Exception err = null;
try {
long byteCount = 0;
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
byteCount += bytesRead;
}
final long byteCount = in.transferTo(out);
out.flush();
return byteCount;
} catch (IOException | RuntimeException e) {
Expand All @@ -64,4 +55,5 @@ public static long copy(final InputStream in, final OutputStream out) throws IOE
IOUtils.close(err, in, out);
}
}

}

This file was deleted.

Loading

0 comments on commit 8deadfb

Please sign in to comment.