Skip to content

Commit 8deadfb

Browse files
authored
Bump the minimum Java version to Java 11 (elastic#40754)
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.
1 parent e10f779 commit 8deadfb

File tree

32 files changed

+129
-568
lines changed

32 files changed

+129
-568
lines changed

.ci/java-versions.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
# are 'java' or 'openjdk' followed by the major release number.
66

77
ES_BUILD_JAVA=openjdk12
8-
ES_RUNTIME_JAVA=java8
8+
ES_RUNTIME_JAVA=java11
99
GRADLE_TASK=build
1010

.ci/matrix-runtime-javas.yml

-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
# or 'openjdk' followed by the major release number.
77

88
ES_RUNTIME_JAVA:
9-
- java8
10-
- java8fips
119
- java11
1210
- java12
1311
- openjdk12
14-
- zulu8
1512
- zulu11
1613
- zulu12

Vagrantfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ def linux_common(config,
246246
touch /is_vagrant_vm # for consistency between linux and windows
247247
SHELL
248248

249+
config.vm.provision 'jdk-11', type: 'shell', inline: <<-SHELL
250+
curl -sSL https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz | tar xz -C /opt/
251+
SHELL
252+
249253
# This prevents leftovers from previous tests using the
250254
# same VM from messing up the current test
251255
config.vm.provision 'clean es installs in tmp', run: 'always', type: 'shell', inline: <<-SHELL
@@ -342,7 +346,7 @@ def sh_install_deps(config,
342346
}
343347
cat \<\<JAVA > /etc/profile.d/java_home.sh
344348
if [ -z "\\\$JAVA_HOME" ]; then
345-
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
349+
export JAVA_HOME=/opt/jdk-11.0.2
346350
fi
347351
export SYSTEM_JAVA_HOME=\\\$JAVA_HOME
348352
unset JAVA_HOME

buildSrc/build.gradle

+1-9
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ dependencies {
123123
compile 'com.perforce:p4java:2012.3.551082' // THIS IS SUPPOSED TO BE OPTIONAL IN THE FUTURE....
124124
compile 'org.apache.rat:apache-rat:0.11'
125125
compile "org.elasticsearch:jna:4.5.1"
126-
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
126+
compile 'com.github.jengelman.gradle.plugins:shadow:4.0.3'
127127
compile 'de.thetaphi:forbiddenapis:2.6'
128128
compile 'com.avast.gradle:gradle-docker-compose-plugin:0.8.12'
129129
testCompile "junit:junit:${props.getProperty('junit')}"
@@ -199,14 +199,6 @@ if (project != rootProject) {
199199
into localDownloads
200200
}
201201

202-
unitTest {
203-
// The test task is configured to runtimeJava version, but build-tools doesn't support all of them, so test
204-
// with compiler instead on the ones that are too old.
205-
if (project.runtimeJavaVersion <= JavaVersion.VERSION_1_10) {
206-
jvm = "${project.compilerJavaHome}/bin/java"
207-
}
208-
}
209-
210202
// This can't be an RandomizedTestingTask because we can't yet reference it
211203
task integTest(type: Test) {
212204
// integration test requires the local testing repo for example plugin builds

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

+2-15
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,7 @@ class BuildPlugin implements Plugin<Project> {
722722

723723
/** Adds compiler settings to the project */
724724
static void configureCompile(Project project) {
725-
if (project.compilerJavaVersion < JavaVersion.VERSION_1_10) {
726-
project.ext.compactProfile = 'compact3'
727-
} else {
728-
project.ext.compactProfile = 'full'
729-
}
725+
project.ext.compactProfile = 'full'
730726
project.afterEvaluate {
731727
project.tasks.withType(JavaCompile) {
732728
final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(it.targetCompatibility)
@@ -738,13 +734,6 @@ class BuildPlugin implements Plugin<Project> {
738734
options.fork = true
739735
options.forkOptions.javaHome = compilerJavaHomeFile
740736
}
741-
if (targetCompatibilityVersion == JavaVersion.VERSION_1_8) {
742-
// compile with compact 3 profile by default
743-
// NOTE: this is just a compile time check: does not replace testing with a compact3 JRE
744-
if (project.compactProfile != 'full') {
745-
options.compilerArgs << '-profile' << project.compactProfile
746-
}
747-
}
748737
/*
749738
* -path because gradle will send in paths that don't always exist.
750739
* -missing because we have tons of missing @returns and @param.
@@ -935,9 +924,7 @@ class BuildPlugin implements Plugin<Project> {
935924
File heapdumpDir = new File(project.buildDir, 'heapdump')
936925
heapdumpDir.mkdirs()
937926
jvmArg '-XX:HeapDumpPath=' + heapdumpDir
938-
if (project.runtimeJavaVersion >= JavaVersion.VERSION_1_9) {
939-
jvmArg '--illegal-access=warn'
940-
}
927+
jvmArg '--illegal-access=warn'
941928
argLine System.getProperty('tests.jvm.argline')
942929

943930
// we use './temp' since this is per JVM and tests are forbidden from writing to CWD

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

+1-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ class PrecommitTasks {
131131
ExportElasticsearchBuildResourcesTask buildResources = project.tasks.getByName('buildResources')
132132
project.tasks.withType(CheckForbiddenApis) {
133133
dependsOn(buildResources)
134-
targetCompatibility = project.runtimeJavaVersion >= JavaVersion.VERSION_1_9 ?
135-
project.runtimeJavaVersion.getMajorVersion() : project.runtimeJavaVersion
134+
targetCompatibility = project.runtimeJavaVersion.getMajorVersion()
136135
if (project.runtimeJavaVersion > JavaVersion.VERSION_11) {
137136
doLast {
138137
project.logger.info(

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class VagrantTestPlugin implements Plugin<Project> {
280280
else
281281
test_args=( "\$@" )
282282
fi
283-
java -cp "\$PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\${test_args[@]}"
283+
"\$SYSTEM_JAVA_HOME"/bin/java -cp "\$PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\${test_args[@]}"
284284
"""
285285
}
286286
Task createWindowsRunnerScript = project.tasks.create('createWindowsRunnerScript', FileContentsTask) {
@@ -294,7 +294,7 @@ class VagrantTestPlugin implements Plugin<Project> {
294294
} else {
295295
\$testArgs = \$args
296296
}
297-
java -cp "\$Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
297+
"\$Env:SYSTEM_JAVA_HOME"/bin/java -cp "\$Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
298298
exit \$LASTEXITCODE
299299
"""
300300
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.12
1+
12
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8
1+
11

distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersion.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
public class JavaVersion {
2727

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

3131
static List<Integer> parse(final String value) {
3232
if (!value.matches("^0*[0-9]+(\\.[0-9]+)*$")) {

distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersionChecker.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public static void main(final String[] args) {
4040
if (args.length != 0) {
4141
throw new IllegalArgumentException("expected zero arguments but was " + Arrays.toString(args));
4242
}
43-
if (JavaVersion.compare(JavaVersion.CURRENT, JavaVersion.JAVA_8) < 0) {
43+
if (JavaVersion.compare(JavaVersion.CURRENT, JavaVersion.JAVA_11) < 0) {
4444
final String message = String.format(
4545
Locale.ROOT,
46-
"the minimum required Java version is 8; your Java version from [%s] does not meet this requirement",
46+
"the minimum required Java version is 11; your Java version from [%s] does not meet this requirement",
4747
System.getProperty("java.home"));
4848
errPrintln(message);
4949
exit(1);

docs/Versions.asciidoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
:lucene_version: 8.0.0
55
:lucene_version_path: 8_0_0
66
:branch: master
7-
:jdk: 1.8.0_131
8-
:jdk_major: 8
7+
:jdk: 11.0.2
8+
:jdk_major: 11
99
:build_flavor: default
1010
:build_type: tar
1111

docs/reference/migration/migrate_8_0.asciidoc

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ coming[8.0.0]
1414
* <<breaking_80_analysis_changes>>
1515
* <<breaking_80_discovery_changes>>
1616
* <<breaking_80_mappings_changes>>
17+
* <<breaking_80_packaging_changes>>
1718
* <<breaking_80_snapshots_changes>>
1819
* <<breaking_80_security_changes>>
1920
* <<breaking_80_java_changes>>
@@ -42,6 +43,7 @@ Elasticsearch 7.x in order to be readable by Elasticsearch 8.x.
4243
include::migrate_8_0/analysis.asciidoc[]
4344
include::migrate_8_0/discovery.asciidoc[]
4445
include::migrate_8_0/mappings.asciidoc[]
46+
include::migrate_8_0/packaging.asciidoc[]
4547
include::migrate_8_0/snapshots.asciidoc[]
4648
include::migrate_8_0/security.asciidoc[]
4749
include::migrate_8_0/java.asciidoc[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[float]
2+
[[breaking_80_packaging_changes]]
3+
=== Packaging changes
4+
5+
[float]
6+
//tag::notable-breaking-changes[]
7+
==== Java 11 is required
8+
9+
Java 11 or higher is now required to run Elasticsearch and any of its command
10+
line tools.
11+
//end::notable-breaking-changes[]

libs/core/build.gradle

-43
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,6 @@ apply plugin: 'nebula.maven-scm'
2323

2424
archivesBaseName = 'elasticsearch-core'
2525

26-
// 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
27-
if (!isEclipse && !isIdea) {
28-
sourceSets {
29-
java9 {
30-
java {
31-
srcDirs = ['src/main/java9']
32-
}
33-
}
34-
}
35-
36-
configurations {
37-
java9Compile.extendsFrom(compile)
38-
}
39-
40-
dependencies {
41-
java9Compile sourceSets.main.output
42-
}
43-
44-
compileJava9Java {
45-
sourceCompatibility = 9
46-
targetCompatibility = 9
47-
}
48-
49-
forbiddenApisJava9 {
50-
if (project.runtimeJavaVersion < JavaVersion.VERSION_1_9) {
51-
targetCompatibility = JavaVersion.VERSION_1_9.getMajorVersion()
52-
}
53-
replaceSignatureFiles 'jdk-signatures'
54-
}
55-
56-
jar {
57-
metaInf {
58-
into 'versions/9'
59-
from sourceSets.java9.output
60-
}
61-
manifest.attributes('Multi-Release': 'true')
62-
}
63-
}
64-
6526
publishing {
6627
publications {
6728
nebula {
@@ -75,10 +36,6 @@ dependencies {
7536
testCompile "junit:junit:${versions.junit}"
7637
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
7738

78-
if (!isEclipse && !isIdea) {
79-
java9Compile sourceSets.main.output
80-
}
81-
8239
if (isEclipse == false || project.path == ":libs:core-tests") {
8340
testCompile("org.elasticsearch.test:framework:${version}") {
8441
exclude group: 'org.elasticsearch', module: 'elasticsearch-core'

libs/core/src/main/java/org/elasticsearch/core/internal/io/Streams.java

+9-17
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,30 @@
2222
import java.io.IOException;
2323
import java.io.InputStream;
2424
import java.io.OutputStream;
25-
import java.util.Objects;
2625

2726
/**
28-
* Simple utility methods for file and stream copying.
29-
* All copy methods use a block size of 4096 bytes,
30-
* and close all affected streams when done.
27+
* Simple utility methods for file and stream copying. All copy methods close all affected streams when done.
3128
* <p>
32-
* Mainly for use within the framework,
33-
* but also useful for application code.
29+
* Mainly for use within the framework, but also useful for application code.
3430
*/
3531
public class Streams {
3632

33+
private Streams() {
34+
35+
}
36+
3737
/**
38-
* Copy the contents of the given InputStream to the given OutputStream.
39-
* Closes both streams when done.
38+
* Copy the contents of the given InputStream to the given OutputStream. Closes both streams when done.
4039
*
4140
* @param in the stream to copy from
4241
* @param out the stream to copy to
4342
* @return the number of bytes copied
4443
* @throws IOException in case of I/O errors
4544
*/
4645
public static long copy(final InputStream in, final OutputStream out) throws IOException {
47-
Objects.requireNonNull(in, "No InputStream specified");
48-
Objects.requireNonNull(out, "No OutputStream specified");
49-
final byte[] buffer = new byte[8192];
5046
Exception err = null;
5147
try {
52-
long byteCount = 0;
53-
int bytesRead;
54-
while ((bytesRead = in.read(buffer)) != -1) {
55-
out.write(buffer, 0, bytesRead);
56-
byteCount += bytesRead;
57-
}
48+
final long byteCount = in.transferTo(out);
5849
out.flush();
5950
return byteCount;
6051
} catch (IOException | RuntimeException e) {
@@ -64,4 +55,5 @@ public static long copy(final InputStream in, final OutputStream out) throws IOE
6455
IOUtils.close(err, in, out);
6556
}
6657
}
58+
6759
}

libs/core/src/main/java9/org/elasticsearch/core/internal/io/Streams.java

-57
This file was deleted.

0 commit comments

Comments
 (0)