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

JPMS: sun libraries aren't available #332

Open
xenoterracide opened this issue Aug 10, 2024 · 2 comments
Open

JPMS: sun libraries aren't available #332

xenoterracide opened this issue Aug 10, 2024 · 2 comments

Comments

@xenoterracide
Copy link

xenoterracide commented Aug 10, 2024

sun classes aren't supposed to be available anymore. If you're using a module-info they definitely aren't available. I tested 3.4 as well.

ava.lang.AssertionError: EqualsVerifier found a problem in class com.xenoterracide.jpa.fixtures.FooAggregate.
-> java.lang.ClassNotFoundException: sun.reflect.ReflectionFactory

For more information, go to: https://www.jqno.nl/equalsverifier/errormessages
(EqualsVerifier null, JDK 21.0.2 on Linux)
	at [email protected]/nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.verify(SingleTypeEqualsVerifierApi.java:351)
	at spring.app.commons.jpa.test/com.xenoterracide.jpa.test.AbstractSplatTest.abstractAggregateEquality(AbstractSplatTest.java:45)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: org.objenesis.ObjenesisException: java.lang.ClassNotFoundException: sun.reflect.ReflectionFactory
	at [email protected]/org.objenesis.instantiator.sun.SunReflectionFactoryHelper.getReflectionFactoryClass(SunReflectionFactoryHelper.java:57)
	at [email protected]/org.objenesis.instantiator.sun.SunReflectionFactoryHelper.newConstructorForSerialization(SunReflectionFactoryHelper.java:37)
	at [email protected]/org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.<init>(SunReflectionFactoryInstantiator.java:41)
	at [email protected]/org.objenesis.strategy.StdInstantiatorStrategy.newInstantiatorOf(StdInstantiatorStrategy.java:68)
	at [email protected]/org.objenesis.ObjenesisBase.getInstantiatorOf(ObjenesisBase.java:94)
	at [email protected]/org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)
	at [email protected]/nl.jqno.equalsverifier.internal.reflection.Instantiator.instantiate(Instantiator.java:69)
	at [email protected]/nl.jqno.equalsverifier.internal.reflection.ClassAccessor.buildObjectAccessor(ClassAccessor.java:335)
	at [email protected]/nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedAccessor(ClassAccessor.java:225)
	at [email protected]/nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedAccessor(ClassAccessor.java:210)
	at [email protected]/nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedObject(ClassAccessor.java:186)
	at [email protected]/nl.jqno.equalsverifier.internal.util.Configuration.ensureUnequalExamples(Configuration.java:219)
	at [email protected]/nl.jqno.equalsverifier.internal.util.Configuration.build(Configuration.java:114)
	at [email protected]/nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.buildConfig(SingleTypeEqualsVerifierApi.java:424)
	at [email protected]/nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.performVerification(SingleTypeEqualsVerifierApi.java:410)
	at [email protected]/nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.verify(SingleTypeEqualsVerifierApi.java:347)
	... 4 more
Caused by: java.lang.ClassNotFoundException: sun.reflect.ReflectionFactory
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:421)
	at java.base/java.lang.Class.forName(Class.java:412)
	at [email protected]/org.objenesis.instantiator.sun.SunReflectionFactoryHelper.getReflectionFactoryClass(SunReflectionFactoryHelper.java:54)
	... 19 more
Reusing configuration cache.

> Task :jpa:dependencyInsight
org.objenesis:objenesis:3.3
  Variant runtime:
    | Attribute Name                 | Provided     | Requested    |
    |--------------------------------|--------------|--------------|
    | org.gradle.status              | release      |              |
    | org.gradle.category            | library      | library      |
    | org.gradle.libraryelements     | jar          | jar          |
    | org.gradle.usage               | java-runtime | java-runtime |
    | org.gradle.dependency.bundling |              | external     |
    | org.gradle.jvm.environment     |              | standard-jvm |
    | org.gradle.jvm.version         |              | 21           |
   Selection reasons:
      - By constraint: dependency was locked to version '3.3'
      - By ancestor

org.objenesis:objenesis:{strictly 3.3} -> 3.3
\--- project :jpa
     \--- project :jpa (*)

org.objenesis:objenesis:3.3
\--- nl.jqno.equalsverifier:equalsverifier:3.16.1
     \--- project :jpa (requested nl.jqno.equalsverifier:equalsverifier:3.+)
          \--- project :jpa (*)

(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation.

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 667ms
1 actionable task: 1 executed
Configuration cache entry reused.
@xenoterracide xenoterracide changed the title accessing sun libraries incorrectly JPMS: sun libraries aren't available Aug 10, 2024
@jqno
Copy link

jqno commented Oct 2, 2024

You need to add requires jdk.unsupported; to your module-info.java.

See this question on stackoverflow for details.

@xenoterracide
Copy link
Author

xenoterracide commented Oct 2, 2024

interesting, I didn't know jdk.unsupported was a thing. Good to know. I think I may also have seen something about actually being able to require sun.something but I still don't think it's a good idea and that this code should be migrated away from...

In the mean time I've been creating gradle JvmTestSuite's my main test always has a module-info to be on the module-path. If need be I create a whitebox test suite that runs on the classpath.

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

2 participants