-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Describe the bug
Using a package-private constructor in a class in the main source set that extends a class in a different (gradle) subproject, from the test source set causes an IllegalAccessError
due to differing classloaders. Reproducer attached.
Expected behavior
AlternateImpl
should be able to be instantiated according to the language spec, and indeed it can be with quarkus < 3.22.
Actual behavior
The below stacktrace results from executing ./gradlew :tests:test
class com.example.AlternateImpl tried to access method 'void com.example.SomeImpl.<init>()' (com.example.AlternateImpl is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @363c32cc; com.example.SomeImpl is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @4c4d27c8)
java.lang.IllegalAccessError: class com.example.AlternateImpl tried to access method 'void com.example.SomeImpl.<init>()' (com.example.AlternateImpl is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @363c32cc; com.example.SomeImpl is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @4c4d27c8)
at com.example.AlternateImpl.<init>(AlternateImpl.java:5)
at com.test.UnitTestingTest.testImpl(UnitTestingTest.java:11)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:1047)
at io.quarkus.test.junit.QuarkusTestExtension.interceptTestMethod(QuarkusTestExtension.java:894)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
How to Reproduce?
Output of uname -a
or ver
Darwin CAOT-KEVINR-M2 24.4.0 Darwin Kernel Version 24.4.0: Wed Mar 19 21:17:25 PDT 2025; root:xnu-11417.101.15~1/RELEASE_ARM64_T6020 arm64
Output of java -version
openjdk version "21" 2023-09-19 OpenJDK Runtime Environment GraalVM CE 21+35.1 (build 21+35-jvmci-23.1-b15) OpenJDK 64-Bit Server VM GraalVM CE 21+35.1 (build 21+35-jvmci-23.1-b15, mixed mode, sharing)
Quarkus version or git rev
3.22.1
Build tool (ie. output of mvnw --version
or gradlew --version
)
------------------------------------------------------------ Gradle 8.14 ------------------------------------------------------------ Build time: 2025-04-25 09:29:08 UTC Revision: 34c560e3be961658a6fbcd7170ec2443a228b109 Kotlin: 2.0.21 Groovy: 3.0.24 Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024 Launcher JVM: 21 (GraalVM Community 21+35-jvmci-23.1-b15) Daemon JVM: /Users/$USER/.sdkman/candidates/java/21-graalce (no JDK specified, using current Java home) OS: Mac OS X 15.4 aarch64
Additional information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status