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

IllegalAccessError on @QuarkusTest when using method in package private interface #29593

Closed
xtaixe opened this issue Nov 30, 2022 · 9 comments · Fixed by #29705
Closed

IllegalAccessError on @QuarkusTest when using method in package private interface #29593

xtaixe opened this issue Nov 30, 2022 · 9 comments · Fixed by #29705
Labels
area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working
Milestone

Comments

@xtaixe
Copy link

xtaixe commented Nov 30, 2022

Describe the bug

IllegalAccessError on @QuarkusTest when using method in package private interface (through a public interface that extends that one)

Expected behavior

The test executes.

Actual behavior

IllegalAccessError exception thrown.

How to Reproduce?

Reproducer:
code-with-quarkus.zip

Output of uname -a or ver

Darwin N4MFM06QYD 21.6.0 Darwin Kernel Version 21.6.0: Thu Sep 29 20:13:56 PDT 2022; root:xnu-8020.240.7~1/RELEASE_ARM64_T6000 arm64

Output of java -version

openjdk version "17.0.4" 2022-07-19 OpenJDK Runtime Environment GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06) OpenJDK 64-Bit Server VM GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.14.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /Users/xtaixe/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6 Java version: 17.0.4, vendor: GraalVM Community, runtime: /Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.2.0/Contents/Home Default locale: en_ES, platform encoding: UTF-8 OS name: "mac os x", version: "12.6.1", arch: "aarch64", family: "mac"

Additional information

No response

@xtaixe xtaixe added the kind/bug Something isn't working label Nov 30, 2022
@geoand geoand added area/testing area/arc Issue related to ARC (dependency injection) and removed triage/needs-triage area/testing labels Dec 1, 2022
@geoand
Copy link
Contributor

geoand commented Dec 1, 2022

cc @mkouba @manovotn

@manovotn
Copy link
Contributor

manovotn commented Dec 6, 2022

Hm, I am not sure how is this supposed to work.
We need to place the bean proxy in some package - in this case the package of the class which declares the producer method.
And by doing that, such proxy doesn't have access to the BaseInterface which is pack-private but at the same time a required bean type which that proxy indirectly implements...

@manovotn
Copy link
Contributor

manovotn commented Dec 6, 2022

Just tried this with Weld to see if I am missing something obvious but Weld has the exact same issue and it doesn't work there either.

@xtaixe BTW you can make this work by avoiding proxy creation - instead of @ApplicationScoped, use @Singleton.
Alternatively, you can OFC replace the anonymous class with a classic impl class and that would work as well.

mkouba added a commit to mkouba/quarkus that referenced this issue Dec 6, 2022
- make sure that an interface method of an interface-based client proxy
is invoked upon the provider type and not the type that declares the
method
- fixes quarkusio#29593
@mkouba
Copy link
Contributor

mkouba commented Dec 6, 2022

This pull request should fix the problem: #29705

BTW you can make this work by avoiding proxy creation - instead of @ApplicationScoped, use @Singleton.

You can also make the BaseInterface public or avoid using annonymous classes in the mean time ;-).

@xtaixe
Copy link
Author

xtaixe commented Dec 6, 2022

You can also make the BaseInterface public or avoid using annonymous classes in the mean time ;-).

@mkouba I made it public for now, but in my actual case it is a base interface that shouldn't be exposed. The anonymous class was just for the reproducer, in my actual case it's not and it still happens (just in case you need to review the fix).

@manovotn
Copy link
Contributor

manovotn commented Dec 6, 2022

@mkouba I made it public for now, but in my actual case it is a base interface that shouldn't be exposed. The anonymous class was just for the reproducer, in my actual case it's not and it still happens (just in case you need to review the fix).

It depends on the return type of your producer method - if you keep that as an interface, you'll keep seeing the issue.
If you change it to the impl class, it should start working even with the current version.

@mkouba
Copy link
Contributor

mkouba commented Dec 6, 2022

in my actual case it's not and it still happens (just in case you need to review the fix).

Hm, does your producer method return an implementation class or an interface? I was not quite clear - I meant the return type of the producer method must not be an interface but an impl class (and no anonymous class needed). The return type is the only source of information when we generate a client proxy for a producer method.

@xtaixe
Copy link
Author

xtaixe commented Dec 6, 2022

The return type it's an interface and I don't know the actual type (it's created using a builder). So the issue will keep happening even with the fix?

@mkouba
Copy link
Contributor

mkouba commented Dec 6, 2022

The return type it's an interface and I don't know the actual type (it's created using a builder). So the issue will keep happening even with the fix?

Nope, the fix should solve the problem. In this case, the workaround mentioned by @manovotn is the only option.

@quarkus-bot quarkus-bot bot added this to the 2.16 - main milestone Dec 6, 2022
@gsmet gsmet modified the milestones: 2.16 - main, 2.15.0.Final Dec 6, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Dec 6, 2022
- make sure that an interface method of an interface-based client proxy
is invoked upon the provider type and not the type that declares the
method
- fixes quarkusio#29593

(cherry picked from commit 4d51083)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants