Skip to content

Conversation

jonasrutishauser
Copy link
Contributor

This fixes several visibility issues in the generated subclass if decorators are not visible from the decorated bean or an other decorator in the chain.
An example error looks like this:

java.lang.IllegalAccessError: failed to access class io.quarkus.arc.test.decorators.NonPublicDecoratorTest$AdditionalConverterDecorator from class io.quarkus.arc.test.decorators.other.ToUpperCaseConverter_Subclass (io.quarkus.arc.test.decorators.NonPublicDecoratorTest$AdditionalConverterDecorator and io.quarkus.arc.test.decorators.other.ToUpperCaseConverter_Subclass are in unnamed module of loader 'app')
	at io.quarkus.arc.test.decorators.other.ToUpperCaseConverter_Subclass.<init>(Unknown Source)
	at io.quarkus.arc.test.decorators.other.ToUpperCaseConverter_Bean.doCreate(Unknown Source)
	at io.quarkus.arc.test.decorators.other.ToUpperCaseConverter_Bean.create(Unknown Source)
	at io.quarkus.arc.test.decorators.other.ToUpperCaseConverter_Bean.create(Unknown Source)
	at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:119)
	at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:38)
	at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:35)
	at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:32)
	at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
	at io.quarkus.arc.impl.ComputingCacheContextInstances.computeIfAbsent(ComputingCacheContextInstances.java:19)
	at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:35)
	at io.quarkus.arc.impl.ClientProxies.getApplicationScopedDelegate(ClientProxies.java:23)
	at io.quarkus.arc.test.decorators.other.ToUpperCaseConverter_ClientProxy.arc$delegate(Unknown Source)
	at io.quarkus.arc.test.decorators.other.ToUpperCaseConverter_ClientProxy.convert(Unknown Source)
	at io.quarkus.arc.test.decorators.NonPublicDecoratorTest.testDecoration(NonPublicDecoratorTest.java:36)
	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)

The fix is to use the methods on the decorated types and not the decorator class.

A work around without the fix would be to make the decorator abstract (only works with a single decorator and not with a chain).

@quarkus-bot quarkus-bot bot added the area/arc Issue related to ARC (dependency injection) label Oct 7, 2025
@gsmet gsmet requested review from mkouba, Ladicek and manovotn October 8, 2025 12:17
@Ladicek
Copy link
Contributor

Ladicek commented Oct 8, 2025

I take it you use the fact that decorated types are all interfaces, and even abuse that by storing the "next" decorator into a field of type Object, knowing that invokeinterface looks at the runtime class of the object and not the static class? Clever! I'm not 100% sure about this and will have to look deeper, but looks sensible on the first sight.

Copy link

quarkus-bot bot commented Oct 8, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 5d821eb.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants