Skip to content

Commit f2b8c4f

Browse files
sgammonGoogle Java Core Libraries
authored andcommitted
Make build and tests work with Java 21, and enable CI for them.
The main changes is that tests need `-Djava.security.manager=allow`. Fixes and closes #7065 Helps with #6790 Fixes #6245 (at least the remaining parts that we actually care about) Fixes #7087 Signed-off-by: Sam Gammon <[email protected]> RELNOTES=n/a PiperOrigin-RevId: 615151162
1 parent c6e91c4 commit f2b8c4f

File tree

3 files changed

+50
-10
lines changed

3 files changed

+50
-10
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ jobs:
2020
strategy:
2121
matrix:
2222
os: [ ubuntu-latest ]
23-
java: [ 8, 11, 17 ]
23+
java: [ 8, 11, 17, 21 ]
2424
root-pom: [ 'pom.xml', 'android/pom.xml' ]
2525
include:
2626
- os: windows-latest
27-
java: 17
27+
java: 21
2828
root-pom: pom.xml
2929
runs-on: ${{ matrix.os }}
3030
env:
@@ -68,11 +68,10 @@ jobs:
6868
steps:
6969
- name: 'Check out repository'
7070
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
71-
- name: 'Set up JDK 11'
71+
- name: 'Set up JDK 21'
7272
uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0
73-
7473
with:
75-
java-version: 11
74+
java-version: 21
7675
distribution: 'zulu'
7776
server-id: sonatype-nexus-snapshots
7877
server-username: CI_DEPLOY_USERNAME
@@ -94,11 +93,10 @@ jobs:
9493
steps:
9594
- name: 'Check out repository'
9695
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
97-
- name: 'Set up JDK 11'
96+
- name: 'Set up JDK 21'
9897
uses: actions/setup-java@9704b39bf258b59bc04b50fa2dd55e9ed76b47a8 # v4.1.0
99-
10098
with:
101-
java-version: 11
99+
java-version: 21
102100
distribution: 'zulu'
103101
cache: 'maven'
104102
- name: 'Generate latest docs'

android/pom.xml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<project.build.outputTimestamp>2024-01-02T00:00:00Z</project.build.outputTimestamp>
2626
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2727
<test.add.opens></test.add.opens>
28+
<test.add.args></test.add.args>
2829
<module.status>integration</module.status>
2930
<variant.jvmEnvironment>android</variant.jvmEnvironment>
3031
<variant.jvmEnvironmentVariantName>android</variant.jvmEnvironmentVariantName>
@@ -176,6 +177,13 @@
176177
<groupId>org.codehaus.mojo</groupId>
177178
<artifactId>animal-sniffer-maven-plugin</artifactId>
178179
<version>1.23</version>
180+
<dependencies>
181+
<dependency>
182+
<groupId>org.ow2.asm</groupId>
183+
<artifactId>asm</artifactId>
184+
<version>9.6</version>
185+
</dependency>
186+
</dependencies>
179187
<configuration>
180188
<annotations>com.google.common.base.IgnoreJRERequirement,com.google.common.collect.IgnoreJRERequirement,com.google.common.hash.IgnoreJRERequirement,com.google.common.io.IgnoreJRERequirement,com.google.common.reflect.IgnoreJRERequirement,com.google.common.testing.IgnoreJRERequirement</annotations>
181189
<checkTestClasses>true</checkTestClasses>
@@ -253,7 +261,7 @@
253261
<runOrder>alphabetical</runOrder>
254262
<!-- Set max heap for tests. -->
255263
<!-- Catch dependencies on the default locale by setting it to hi-IN. -->
256-
<argLine>-Xmx1536M -Duser.language=hi -Duser.country=IN ${test.add.opens}</argLine>
264+
<argLine>-Xmx1536M -Duser.language=hi -Duser.country=IN ${test.add.args} ${test.add.opens}</argLine>
257265
</configuration>
258266
</plugin>
259267
<plugin>
@@ -462,5 +470,18 @@
462470
</plugins>
463471
</build>
464472
</profile>
473+
<profile>
474+
<id>javac-for-jvm18plus</id>
475+
<activation>
476+
<!--
477+
In order to build and run the tests against JDK 18+, we need to pass java.security.manager=allow, to make
478+
the deprecated 'java.lang.SecurityManager' available for use.
479+
-->
480+
<jdk>[18,]</jdk>
481+
</activation>
482+
<properties>
483+
<test.add.args>-Djava.security.manager=allow</test.add.args>
484+
</properties>
485+
</profile>
465486
</profiles>
466487
</project>

pom.xml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<project.build.outputTimestamp>2024-01-02T00:00:00Z</project.build.outputTimestamp>
2626
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2727
<test.add.opens></test.add.opens>
28+
<test.add.args></test.add.args>
2829
<module.status>integration</module.status>
2930
<variant.jvmEnvironment>standard-jvm</variant.jvmEnvironment>
3031
<variant.jvmEnvironmentVariantName>jre</variant.jvmEnvironmentVariantName>
@@ -177,6 +178,13 @@
177178
<groupId>org.codehaus.mojo</groupId>
178179
<artifactId>animal-sniffer-maven-plugin</artifactId>
179180
<version>1.23</version>
181+
<dependencies>
182+
<dependency>
183+
<groupId>org.ow2.asm</groupId>
184+
<artifactId>asm</artifactId>
185+
<version>9.6</version>
186+
</dependency>
187+
</dependencies>
180188
<configuration>
181189
<annotations>com.google.common.base.IgnoreJRERequirement,com.google.common.collect.IgnoreJRERequirement,com.google.common.hash.IgnoreJRERequirement,com.google.common.io.IgnoreJRERequirement,com.google.common.reflect.IgnoreJRERequirement,com.google.common.testing.IgnoreJRERequirement</annotations>
182190
<checkTestClasses>true</checkTestClasses>
@@ -248,7 +256,7 @@
248256
<runOrder>alphabetical</runOrder>
249257
<!-- Set max heap for tests. -->
250258
<!-- Catch dependencies on the default locale by setting it to hi-IN. -->
251-
<argLine>-Xmx1536M -Duser.language=hi -Duser.country=IN ${test.add.opens}</argLine>
259+
<argLine>-Xmx1536M -Duser.language=hi -Duser.country=IN ${test.add.args} ${test.add.opens}</argLine>
252260
</configuration>
253261
</plugin>
254262
<plugin>
@@ -457,5 +465,18 @@
457465
</plugins>
458466
</build>
459467
</profile>
468+
<profile>
469+
<id>javac-for-jvm18plus</id>
470+
<activation>
471+
<!--
472+
In order to build and run the tests against JDK 18+, we need to pass java.security.manager=allow, to make
473+
the deprecated 'java.lang.SecurityManager' available for use.
474+
-->
475+
<jdk>[18,]</jdk>
476+
</activation>
477+
<properties>
478+
<test.add.args>-Djava.security.manager=allow</test.add.args>
479+
</properties>
480+
</profile>
460481
</profiles>
461482
</project>

0 commit comments

Comments
 (0)