-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Cannot invoke "org.jboss.jandex.MethodInfo.flags()" because "noArgsConstructor" is null #45462
Comments
/cc @gastaldi (m1) |
You can use the
|
Hm, so if I understand it correctly the bean is not registered in the |
In my test cases, I use the @QuarkusTest annotation to write the test cases, not in the test environment.
When I run this test case, it throws a “noArgsConstructor is null” error. |
I can’t add a no-args constructor because I need to inject a bean of type sqlClient. |
You can, but you'll need to add the |
BTW is there a reason you're using ASM directly? I.e. is there something that gizmo cannot handle? |
As you can see, this extension takes care of Kotlin users. I’ve used Gizmo on the master branch, and it isn’t very friendly with Kotlin. |
If you encounter a problem with Kotlin classes feel free to report an issue in https://github.com/quarkusio/gizmo. |
Do you mean generating code like this? But this will lead to another issue. "Cannot reference 'BookRepositoryAsmImpl. sqlClient' before superclass constructor is called" |
Nope, I mean something like: @ApplicationScoped
@Unremovable
public class BookRepositoryAsmImpl extends JRepositoryImpl<Book, Long> implements BookRepository {
// just for the client proxy
public BookRepositoryAsmImpl() {
super(null);
}
@Inject // this is a bean constructor
public BookRepositoryAsmImpl(JSqlClient sqlClient) {
super(sqlClient, Book.class);
}
} |
It still can’t inject sqlClient. I’ve updated the code in my report-bug branch; you can take a look. |
Describe the bug
I used ASM to generate Java bytecode and automatically create CRUD methods for some interfaces. The generated class works perfectly in non-test environments.
However, when I attempted to use @QuarkusTest to test the generated class, I encountered the following error:
Here is the class I generated. JRepositoryImpl serves as a template and requires a constructor with a JSqlClient parameter. BookRepository is the user’s class.
This is a portion of the JRepositoryImpl code:
This is my test code:
When I start Quarkus normally, everything works as expected. The framework automatically recognizes the generated code and discovers it as a bean.
Under normal startup and in the test environment, the code generated by ASM should automatically be recognized as a bean. Why is the framework attempting to call a no-argument constructor on the generated class?
Expected behavior
Under normal startup and in the test environment, the code generated by ASM should automatically be recognized as a bean.
Actual behavior
The test environment was not correctly identified as a bean
How to Reproduce?
branch: report-bug
https://github.com/flynndi/quarkus-jimmer-extension/tree/report-bug
To view the generated bytecode, use the following command:
mvn clean compile quarkus:dev -Dquarkus.debug.generated-classes-dir=xxxxx
It will reappear when you mvn install it
there are no problems when starting the application normally.
Output of
uname -a
orver
macbook pro m1
Output of
java -version
17
Quarkus version or git rev
3.15
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.7
Additional information
Here are some related issues I encountered while developing a Quarkus extension. If possible, please help me with these as well.
The text was updated successfully, but these errors were encountered: