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

Classes with @Funq methods fail in constructor injection for normal scoped bean #27671

Closed
michalvavrik opened this issue Sep 1, 2022 · 2 comments · Fixed by #27674
Closed
Labels
area/arc Issue related to ARC (dependency injection) area/funqy area/kubernetes kind/bug Something isn't working
Milestone

Comments

@michalvavrik
Copy link
Contributor

michalvavrik commented Sep 1, 2022

Describe the bug

When class that is normal scoped bean has method annotated with @Funq and uses constructor injection, an exception is thrown. I looked into this and the reason is that when (and only when!) class does extend SomeClass and there is no default constructor without args, Funqy generates it for us here

if (!(classInfo.superClassType() != null && classInfo.superClassType().name().equals(DotNames.OBJECT))) {

but Quarkus Arc does too for normal scoped beans unless a bean class extends a class that does not declare a no-args constructor.

Expected behavior

Constructor injection for normal scoped beans works just fine.

Actual behavior

An exception is thrown: Exception in thread "main" java.lang.reflect.InvocationTargetException
Caused by: java.lang.ClassFormatError: Duplicate method name "<init>" with signature "()V" in class file io/quarkus/funqy/deployment/DependencyInjectionTest$HiFunction

How to Reproduce?

  1. git clone https://github.com/michalvavrik/funqy-knative-events-constructor-injection-reproducer.git
  2. mvn clean verify

Output of uname -a or ver

Linux fedora 5.19.4-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 25 17:42:04 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "17.0.3" 2022-04-19

GraalVM version (if different from Java)

GraalVM CE 22.1.0

Quarkus version or git rev

999-SNAPSHOT

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

Apache Maven 3.8.6

Additional information

No response

@michalvavrik michalvavrik added the kind/bug Something isn't working label Sep 1, 2022
@quarkus-bot quarkus-bot bot added area/arc Issue related to ARC (dependency injection) area/funqy area/kubernetes labels Sep 1, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 1, 2022

@michalvavrik michalvavrik changed the title Classes with @Funq functions does not support constructor injection Classes with @Funq methods do not support constructor injection Sep 1, 2022
@michalvavrik
Copy link
Contributor Author

michalvavrik commented Sep 1, 2022

I couldn't reproduce it in JUnit test in quarkus-funqy-server-common, but I still can reproduce it with app using Funqy knative-events. I'll provide full reproducer later today.

UPDATE: added reproducer as it's related to normal scope beans

@michalvavrik michalvavrik changed the title Classes with @Funq methods do not support constructor injection Classes with @Funq methods fail in constructor injection for normal scoped bean Sep 1, 2022
michalvavrik added a commit to michalvavrik/quarkus that referenced this issue Sep 1, 2022
@quarkus-bot quarkus-bot bot added this to the 2.13 - main milestone Sep 2, 2022
@gsmet gsmet modified the milestones: 2.13 - main, 2.12.1.Final Sep 5, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 5, 2022
evanchooly pushed a commit to nenros/quarkus that referenced this issue Sep 8, 2022
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) area/funqy area/kubernetes kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants