-
-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
(Note that this is a follow-up to issue #160. I suspect it's also the underlying problem for #332.)
Despite the fix made for #160, I'm still unable to use Objenesis when it's running on the modulepath.
I'm not sure what I'm doing wrong, or how I can work around this.
I get this exception:
Exception in thread "main" org.objenesis.ObjenesisException: java.lang.ClassNotFoundException: sun.reflect.ReflectionFactory
at org.objenesis@3.4/org.objenesis.instantiator.sun.SunReflectionFactoryHelper.getReflectionFactoryClass(SunReflectionFactoryHelper.java:57)
at org.objenesis@3.4/org.objenesis.instantiator.sun.SunReflectionFactoryHelper.newConstructorForSerialization(SunReflectionFactoryHelper.java:37)
at org.objenesis@3.4/org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.<init>(SunReflectionFactoryInstantiator.java:41)
at org.objenesis@3.4/org.objenesis.strategy.StdInstantiatorStrategy.newInstantiatorOf(StdInstantiatorStrategy.java:61)
at org.objenesis@3.4/org.objenesis.ObjenesisBase.getInstantiatorOf(ObjenesisBase.java:94)
at org.objenesis@3.4/org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)
at objenesisreproducer/org.example.domain.Reproducer.main(Reproducer.java:8)
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 org.objenesis@3.4/org.objenesis.instantiator.sun.SunReflectionFactoryHelper.getReflectionFactoryClass(SunReflectionFactoryHelper.java:54)
... 6 more
I've uploaded a complete reproducer here: https://github.com/jqno/objenesis-module-issue
Note: it needs to be run from within IntelliJ. I was unable to reproduce it with Maven.
The full code is also below:
Reproducer.java:
package org.example.domain;
import org.objenesis.*;
public class Reproducer {
public static void main(String[] args) {
Objenesis objenesis = new ObjenesisStd();
objenesis.newInstance(Reproducer.class);
}
}module-info.java:
module objenesisreproducer {
opens org.example.domain;
requires org.objenesis;
}pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>objenesis-issue-160</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.release>17</maven.compiler.release>
</properties>
<dependencies>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
</project>Metadata
Metadata
Assignees
Labels
No labels