Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bnd-testing-maven-plugin fails with Java 24 #6370

Open
scordio opened this issue Nov 15, 2024 · 9 comments
Open

bnd-testing-maven-plugin fails with Java 24 #6370

scordio opened this issue Nov 15, 2024 · 9 comments

Comments

@scordio
Copy link

scordio commented Nov 15, 2024

In AssertJ, we use the bnd-testing-maven-plugin for OSGi integration tests, and the plugin started failing today when running on Java 24:

INFO] --- bnd-testing:7.0.0:testing (osgi-integration-testing) @ assertj-core-osgi ---
[INFO] Matching glob *
[INFO] Testing /home/runner/work/assertj/assertj/assertj-tests/assertj-integration-tests/assertj-core-osgi/target/verify.bndrun:
[INFO] Bnd inferred -runee: JavaSE-21
! Unexpected error in the run body: Setting a system-wide Policy object is not supported
java.lang.UnsupportedOperationException: Setting a system-wide Policy object is not supported
	at java.base/java.security.Policy.setPolicy(Policy.java:114)
	at aQute.launcher.Launcher.activate(Launcher.java:493)
	at aQute.launcher.Launcher.launch(Launcher.java:403)
	at aQute.launcher.Launcher.run(Launcher.java:185)
	at aQute.launcher.Launcher.main(Launcher.java:161)
	at aQute.launcher.pre.EmbeddedLauncher.executeWithRunPath(EmbeddedLauncher.java:170)
	at aQute.launcher.pre.EmbeddedLauncher.findAndExecute(EmbeddedLauncher.java:135)
	at aQute.launcher.pre.EmbeddedLauncher.main(EmbeddedLauncher.java:52)
java.lang.UnsupportedOperationException: Setting a system-wide Policy object is not supported
	at java.base/java.security.Policy.setPolicy(Policy.java:114)
	at aQute.launcher.Launcher.activate(Launcher.java:493)
	at aQute.launcher.Launcher.launch(Launcher.java:403)
	at aQute.launcher.Launcher.run(Launcher.java:185)
	at aQute.launcher.Launcher.main(Launcher.java:161)
	at aQute.launcher.pre.EmbeddedLauncher.executeWithRunPath(EmbeddedLauncher.java:170)
	at aQute.launcher.pre.EmbeddedLauncher.findAndExecute(EmbeddedLauncher.java:135)
	at aQute.launcher.pre.EmbeddedLauncher.main(EmbeddedLauncher.java:52)
[INFO] 127 Error(s)
[ERROR] Error   : Exit code remote process 127: /opt/hostedtoolcache/Java_jdkfile_jdk/24/x64/bin/java -cp /home/runner/work/assertj/assertj/assertj-tests/assertj-integration-tests/assertj-core-osgi/target/test/tmp/testing/verify/cnf/cache/7.0.0/bnd-cache/biz.aQute.launcher/biz.aQute.launcher.pre.jar -Dlauncher.properties=/home/runner/work/assertj/assertj/assertj-tests/assertj-integration-tests/assertj-core-osgi/target/test/tmp/testing/verify/generated/launch13560035249624281069.properties -ea -Dlauncher.runpath=/home/runner/.m2/repository/org/eclipse/platform/org.eclipse.osgi/3.21.0/org.eclipse.osgi-3.21.0.jar,/home/runner/work/assertj/assertj/assertj-tests/assertj-integration-tests/assertj-core-osgi/target/test/tmp/testing/verify/cnf/cache/7.0.0/bnd-cache/biz.aQute.launcher/biz.aQute.launcher-7.0.0.jar aQute.launcher.pre.EmbeddedLauncher

Source: https://github.com/assertj/assertj/actions/runs/11846157794/job/33013148936#step:4:8886

Do you know what the root cause could be?

@scordio scordio changed the title bnd-testing-maven-plugin failing with Java 24 bnd-testing-maven-plugin fails with Java 24 Nov 15, 2024
@stbischof
Copy link
Contributor

stbischof commented Nov 15, 2024

Code:

java.security.Policy.setPolicy(new AllPolicy());

I think this is related to:

https://openjdk.org/jeps/486

The fastest solution would be to some RunProperties ad describes in the jep. '-D.....'

https://github.com/assertj/assertj/blob/97cc0f866c31a76dc705fdec0d9bdcad1cd640b9/assertj-tests/assertj-integration-tests/assertj-core-osgi/verify.bndrun#L16

But we will have this in every use of the Launcher. So i hope @pkriens has better solution

@timothyjward this tests are there because of osgi-test

@scordio
Copy link
Author

scordio commented Nov 15, 2024

Thanks for the quick feedback, @stbischof!

The fastest solution would be to some RunProperties ad describes in the jep. '-D.....'

https://github.com/assertj/assertj/blob/97cc0f866c31a76dc705fdec0d9bdcad1cd640b9/assertj-tests/assertj-integration-tests/assertj-core-osgi/verify.bndrun#L16

Could you please elaborate on the workaround you have in mind? I didn't fully understand what you meant and couldn't figure it out by going through the JEP.

@chrisrueger
Copy link
Contributor

Can't just remove that line?

java.security.Policy.setPolicy(new AllPolicy());

bnd is officially on Java17 and Policy deprecated for removal.

image

@pkriens ?

@timothyjward
Copy link
Contributor

@timothyjward this tests are there because of osgi-test

It’s good that we have these tests, but in this case it’s very much the maven plugin that’s the issue. Everyone’s tests will be broken on Java 24.

Can't just remove that line?

I agree with @chrisrueger - we should also add Java 24 to the CI build matrix and see what else breaks.

@chrisrueger
Copy link
Contributor

I created #6371 which is currently building.

@timothyjward

I agree with @chrisrueger - we should also add Java 24 to the CI build matrix and see what else breaks.

Unfortunatelly Java 24 seems still early access and it didn't work with Github Actions (seems 23 is the latest). If anybody can tell me how to add it, I can do it.
In the meantime I added Java 23 in this PR, to see how at least that behaves.

@timothyjward
Copy link
Contributor

Unfortunatelly Java 24 seems still early access and it didn't work with Github Actions (seems 23 is the latest). If anybody can tell me how to add it, I can do it.

According to the docs it should be 24-ea

@stbischof
Copy link
Contributor

https://github.com/assertj/assertj/blob/3.x/.github%2Fworkflows%2Fcross-version.yml

@chrisrueger
Copy link
Contributor

chrisrueger commented Nov 15, 2024

According to the docs it should be 24-ea

Thanks. Looks like this worked and it is using Java 24-ea now.
Unfortunatelly now it fails later: https://github.com/bndtools/bnd/actions/runs/11859401489/job/33052249683?pr=6371

BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 68
> Unsupported class file major version 68

Maybe gradle is not Java 24 ready yet?

Hmm will look into it later.

@timothyjward
Copy link
Contributor

Maybe gradle is not Java 24 ready yet?

Certainly possible, but I’m sure that other parts of bnd (e.g. the analyzer) will need some tweaks too.

scordio added a commit to assertj/assertj that referenced this issue Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants