quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

Possible regression in ArC related to code generated for observers #28767

Closed gsmet closed 2 years ago

gsmet commented 2 years ago

Both Quarkus GitHub App and Quarkus GitHub Action extensions tests are failing with main (and only main) with the following error:

Caused by: java.lang.RuntimeException: Failed to start quarkus
    at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
    ... 47 more
Caused by: java.lang.NoSuchFieldError: INSTANCE
    at io.quarkiverse.githubapp.deployment.ConfigFileOrderTest$ListeningClass_Multiplexer_Observer_createLabel_9c21b751bd1c3c76c9e9f8d4cbcacbc05e9e7ed7_9f44fdebc17f6695923ea0ae1fb11976a2d1256e.<init>(Unknown Source)
    at io.quarkus.arc.setup.Default_ComponentsProvider.addObservers1(Unknown Source)
    at io.quarkus.arc.setup.Default_ComponentsProvider.getComponents(Unknown Source)
    at io.quarkus.arc.impl.ArcContainerImpl.<init>(ArcContainerImpl.java:117)
    at io.quarkus.arc.Arc.initialize(Arc.java:31)
    at io.quarkus.arc.runtime.ArcRecorder.initContainer(ArcRecorder.java:43)
    at io.quarkus.deployment.steps.ArcProcessor$generateResources844392269.deploy_0(Unknown Source)
    at io.quarkus.deployment.steps.ArcProcessor$generateResources844392269.deploy(Unknown Source)
    ... 48 more

My understanding is that it would be an error in the generated classes and so probably an error in recent ArC-related work (or somehow I'm doing something that is not expected but it used to work since forever).

Failing build: https://github.com/quarkiverse/quarkus-github-app/actions/runs/3294992831/jobs/5433081604

It's easily reproducible by:

The following tests will fail with the error above:

[ERROR]   ConfigFileOrderTest » ExceptionInInitializer
[ERROR]   GitHubGraphQLClientInjectionTest » ExceptionInInitializer
[ERROR]   OptionalConfigFileTest » ExceptionInInitializer
quarkus-bot[bot] commented 2 years ago

/cc @manovotn, @mkouba

gsmet commented 2 years ago

/cc @Ladicek too

manovotn commented 2 years ago

I am not in front of my work laptop but there were recently two changes to generation of annotation literals, its's going to be one of them:

Ladicek commented 2 years ago

NoSuchFieldError: INSTANCE shows that this is caused by https://github.com/quarkusio/quarkus/commit/e57f709d6eb300eb08091f21bebdd68eb72f5557. Let me take a look.

gsmet commented 2 years ago

What I'm wondering is if I still need to create the AnnotationLiterals myself or if there is a better solution. That being said, having your own AnnotationLiteral should be supported.

Ladicek commented 2 years ago

Having a custom AnnotationLiteral absolutely must work.

Looking at the generated bytecode, the generated constructor of the generated observer class, in my case io.quarkiverse.githubapp.deployment.GitHubGraphQLClientInjectionTest$ListeningClass_Multiplexer_Observer_deleteLabel_061db032c825046e9c8d2d0a932d5538395c5a34_df5559b104debbf1f7c6df81964f6a4e9d2b96bc, refers to Field io/quarkiverse/githubapp/event/Label$Deleted_AnnotationLiteral.INSTANCE, and that seems to exist, as it should.

Ladicek commented 2 years ago

I'll correct myself: Having a custom AnnotationLiteral absolutely must work ... unless your custom AnnotationLiteral is a generated class named <Annotation>_AnnotationLiteral, which is the exact same name ArC uses for its generated annotation literals :-)

manovotn commented 2 years ago

For more context, prior to the commit mention above, the suffix was slightly different which is why this worked. See https://github.com/quarkusio/quarkus/commit/6edd2dcea9a09d4195dd9020cd15e3135a61958f#diff-a2ca7cc07a423ea56e341d4c72c361fb913d4436da612e6a6d2d29c9ac8b4925L40-R40

Ladicek commented 2 years ago

I've submitted #28789 to fix this, but the proper fix would be #28790. That unfortunately isn't a straightforward refactoring, but there might be a way...