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

Illegal reflective access warning when running on java 11 #32

Open
honzasmuk opened this issue May 6, 2019 · 7 comments
Open

Illegal reflective access warning when running on java 11 #32

honzasmuk opened this issue May 6, 2019 · 7 comments

Comments

@honzasmuk
Copy link

When running on java 11 i get warning:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.shazam.shazamcrest.CyclicReferenceDetector (file:/.../.m2/repository/com/shazam/shazamcrest/0.11/shazamcrest-0.11.jar) to field java.time.OffsetDateTime.serialVersionUID
WARNING: Please consider reporting this to the maintainers of com.shazam.shazamcrest.CyclicReferenceDetector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Usage is as simple as this:

assertThat(actual, Matchers.sameBeanAs(expected))

Is there any way how to remove this warning? Thanks a lot.

@stephen-smith
Copy link

Causing a surefire test failure (and build failure) for me, even though the message says warning:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project REDACTED: There are test failures.
% less target/surefire-reports/2019-06-17T11-34-59_540.dumpstream
# Created on 2019-06-17T11:34:59.541
WARNING: An illegal reflective access operation has occurred

# Created on 2019-06-17T11:34:59.541
WARNING: Illegal reflective access by com.shazam.shazamcrest.CyclicReferenceDetector (file:/home/bss/.m2/repository/com/shazam/shazamcrest/0.11/shazamcrest-0.11.jar) to field java.lang.Number.serialVersionUID

# Created on 2019-06-17T11:34:59.541
WARNING: Please consider reporting this to the maintainers of com.shazam.shazamcrest.CyclicReferenceDetector

# Created on 2019-06-17T11:34:59.541
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

# Created on 2019-06-17T11:34:59.541
WARNING: All illegal access operations will be denied in a future release

@tbohnen
Copy link

tbohnen commented Jun 26, 2019

Causing a surefire test failure (and build failure) for me, even though the message says warning:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project REDACTED: There are test failures.
% less target/surefire-reports/2019-06-17T11-34-59_540.dumpstream
# Created on 2019-06-17T11:34:59.541
WARNING: An illegal reflective access operation has occurred

# Created on 2019-06-17T11:34:59.541
WARNING: Illegal reflective access by com.shazam.shazamcrest.CyclicReferenceDetector (file:/home/bss/.m2/repository/com/shazam/shazamcrest/0.11/shazamcrest-0.11.jar) to field java.lang.Number.serialVersionUID

# Created on 2019-06-17T11:34:59.541
WARNING: Please consider reporting this to the maintainers of com.shazam.shazamcrest.CyclicReferenceDetector

# Created on 2019-06-17T11:34:59.541
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

# Created on 2019-06-17T11:34:59.541
WARNING: All illegal access operations will be denied in a future release

@stephen-smith Could you get a workaround for this failing your tests? I see there are a couple of jvm options to disable it.

@stephen-smith
Copy link

@tbohnen Nope; I did not find a work around. Hoping this project updates to be Java 11 compatible before we are asked to do so.

@gkfirst8
Copy link

gkfirst8 commented Nov 3, 2022

This nice little project was and currently still is valuable to me. I have not bumped into an alternative yet. So I hope it will survive the move to Java 17 shortly. Any news on this matter?

@roloreaper
Copy link

Is this still an issue

@gkfirst8
Copy link

This currently breaks on the getClassesWithCircularReferences. If only we could turn it of... I could survive this as my objects are not that complicated ;-)

@gkfirst8
Copy link

I came up on a temporarily fix by adding "--add-opens" to surefire:

<plugin>
	<artifactId>maven-surefire-plugin</artifactId>
	<version>${surefire-plugin.version}</version>
	<configuration>
		<argLine>
			--add-opens java.base/java.time=ALL-UNNAMED
			--add-opens java.base/java.math=ALL-UNNAMED
			--add-opens java.base/java.time=ALL-UNNAMED
			--add-opens java.base/java.lang.reflect=ALL-UNNAMED
		</argLine>
		<systemPropertyVariables>
			<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
			<maven.home>${maven.home}</maven.home>
		</systemPropertyVariables>
	</configuration>
</plugin>

Hope this is useful to others too. But I hope a nice clean-gson-solution will be found. Maybe in project approvalcrest as that still have a maintainer? (Does this project have one?)

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

5 participants