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

Native Image building fails with JUnit Platform 5.9.0 #300

Closed
melix opened this issue Sep 15, 2022 · 9 comments · Fixed by #308
Closed

Native Image building fails with JUnit Platform 5.9.0 #300

melix opened this issue Sep 15, 2022 · 9 comments · Fixed by #308
Assignees
Labels
bug Something isn't working junit-support Related to JUnit Support project
Milestone

Comments

@melix
Copy link
Collaborator

melix commented Sep 15, 2022

Building a Micronaut application which uses JUnit Platform 5.9.0 will fail with the following error:

Error: java.util.concurrent.ExecutionException: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of org.junit.platform.reporting.open.xml.OpenTestReportGeneratingListener are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use --trace-object-instantiation=org.junit.platform.reporting.open.xml.OpenTestReportGeneratingListener.

A hotfix was deployed in Micronaut Test: https://github.com/micronaut-projects/micronaut-test/pull/618/files#diff-020ea83d544d7fe86f8cc9bdbcf3eba4bd2d37bb3ed842d10eae76b4bf9a3c6e

But a "real" fix needs to be implemented in JUnitPlatformFeature.

@melix melix added the bug Something isn't working label Sep 15, 2022
@melix melix added this to the 0.9.14 milestone Sep 15, 2022
@sbrannen
Copy link
Collaborator

Is this due to OpenTestReportGeneratingListener.NAMESPACE_REGISTRY being a static final field?

If so, we (the JUnit team) could instantiate the NamespaceRegistry lazily (on demand).

In addition, OpenTestReportGeneratingListener is an optional listener and has to be manually enabled by setting the junit.platform.reporting.open.xml.enabled property to true. So I wonder what is enabling that. Maybe recent versions of Gradle automatically enable that?

/cc @marcphilipp

@marcphilipp
Copy link

@melix @gradinac Should we fix this in JUnit 5.9.1 as suggested by Sam?

@sbrannen
Copy link
Collaborator

In addition, OpenTestReportGeneratingListener is an optional listener and has to be manually enabled by setting the junit.platform.reporting.open.xml.enabled property to true. So I wonder what is enabling that. Maybe recent versions of Gradle automatically enable that?

Never mind: I'd forgotten that OpenTestReportGeneratingListener will always be loaded due to the ServiceLoader mechanism. It's only "optional" in the sense that it's a no-op if it's not explicitly enabled.

@sbrannen
Copy link
Collaborator

This will be addressed in JUnit 5.9.1:

@sbrannen
Copy link
Collaborator

sbrannen commented Sep 17, 2022

@melix and @gradinac, when are you planning on upgrading to JUnit 5.9.x?

I see you're still on 5.8.1. So you could upgrade to 5.8.2 in the interim if you're not planning on upgrading to 5.9.0 (or the soon-to-be-released 5.9.1).

@melix
Copy link
Collaborator Author

melix commented Sep 17, 2022

Micronaut itself already has upgraded to 5.9.0

@sbrannen
Copy link
Collaborator

Sorry, I was unclear. I meant Native Build Tools when I said "you".

In other words, I'm asking when you plan to upgrade NBT to JUnit 5.9.x.

@sbrannen
Copy link
Collaborator

But a "real" fix needs to be implemented in JUnitPlatformFeature.

If you choose to add a fix for JUnit 5.9.0, that should go in PlatformConfigProvider.

@sbrannen
Copy link
Collaborator

To fix this bug, add "org.junit.platform.reporting.open.xml.OpenTestReportGeneratingListener" to the buildTimeInitializedClasses string array in org.graalvm.junit.platform.config.platform.PlatformConfigProvider.onLoad(NativeImageConfiguration).

I have tested this with the following combinations.


Native Build Tools 0.9.13

✅ NBT 0.9.13 :: JUnit 5.8.1
✅ NBT 0.9.13 :: JUnit 5.8.2
❌ NBT 0.9.13 :: JUnit 5.9.0
✅ NBT 0.9.13 :: JUnit 5.9.1-SNAPSHOT


Native Build Tools 0.9.14-SNAPSHOT -- without fix

✅ NBT 0.9.14-SNAPSHOT :: JUnit 5.8.1
✅ NBT 0.9.14-SNAPSHOT :: JUnit 5.8.2
❌ NBT 0.9.14-SNAPSHOT :: JUnit 5.9.0
✅ NBT 0.9.14-SNAPSHOT :: JUnit 5.9.1-SNAPSHOT


Native Build Tools 0.9.14-SNAPSHOT -- with fix

✅ NBT 0.9.14-SNAPSHOT :: JUnit 5.8.1
✅ NBT 0.9.14-SNAPSHOT :: JUnit 5.8.2
✅ NBT 0.9.14-SNAPSHOT :: JUnit 5.9.0
✅ NBT 0.9.14-SNAPSHOT :: JUnit 5.9.1-SNAPSHOT


@sbrannen sbrannen reopened this Sep 18, 2022
@sbrannen sbrannen added the junit-support Related to JUnit Support project label Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working junit-support Related to JUnit Support project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants