-
-
Notifications
You must be signed in to change notification settings - Fork 97
Class not found error when using Objenesis in a Java 9 module #160
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
Comments
I get the same error in my application, using Java 11: org.objenesis.ObjenesisException: java.lang.ClassNotFoundException: sun.reflect.ReflectionFactory Any fixes? Here's the stack: |
I think this was fixed by adding |
Unfortunately, I'm still seeing the error. Here's how I reproduce: Person.java: package org.example.domain;
import org.objenesis.*;
public class Person {
public static void main(String[] args) {
Objenesis objenesis = new ObjenesisStd();
objenesis.getInstantiatorOf(Person.class);
}
} module-info.java: module user {
requires org.objenesis;
opens org.example.domain;
} 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.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
</project> |
This issue came up while investigating jqno/equalsverifier#746.
To summarise, using Objenesis in a Java 9 module results in
ClassNotFoundException: sun.reflect.ReflectionFactory
Reproducible sample: https://github.com/armandino/objenesis-java9-module-bug
The text was updated successfully, but these errors were encountered: