Skip to content

NPE from ArcAnnotationProcessor when default value() is used #1832

@sarxos

Description

@sarxos

Hello @mkouba ,

This is in regards to the issue we discussed today on Zulip.

After using jandex-maven-plugin to generate META-INF/jandex.idx I'm getting errors from all my tests.

Maven plugin I used:

<plugin>
  <groupId>org.jboss.jandex</groupId>
  <artifactId>jandex-maven-plugin</artifactId>
  <version>1.0.5</version>
  <executions>
    <execution>
      <id>make-index</id>
      <goals>
        <goal>jandex</goal>
      </goals>
    </execution>
  </executions>
</plugin>

And the stack trace I'm getting is:

Caused by: java.lang.NullPointerException: Value not set for java.lang.Class<? extends akka.actor.Actor> value()
    at io.quarkus.arc.processor.AnnotationLiteralProcessor.process(AnnotationLiteralProcessor.java:92)
    at io.quarkus.arc.processor.BeanGenerator.initConstructor(BeanGenerator.java:624)
    at io.quarkus.arc.processor.BeanGenerator.createConstructor(BeanGenerator.java:513)
    at io.quarkus.arc.processor.BeanGenerator.generateProducerMethodBean(BeanGenerator.java:371)
    at io.quarkus.arc.processor.BeanGenerator.generate(BeanGenerator.java:124)
    at io.quarkus.arc.processor.BeanProcessor.process(BeanProcessor.java:186)
    at io.quarkus.arc.deployment.ArcAnnotationProcessor.build(ArcAnnotationProcessor.java:259)

The source code (at revision with jandex failure):

https://github.com/sarxos/abberwoult/tree/00dd5d0a182f8ea85657044a4e4a228a7d828756

The problematic annotation is this buddy here:

@Qualifier
@Documented
@Target({ FIELD, PARAMETER, METHOD })
@Retention(RUNTIME)
public @interface ActorByClass {

	final Class<? extends Actor> NO_CLASS = Actor.class;

	@Nonbinding
	Class<? extends Actor> value() default Actor.class;
}

After you suggested to override jandex dependency in corresponding maven plugin to 2.1.1.Final all tests are again passing, which proves that jandex-maven-plugin uses outdated dependency.

The workarounds so far:

  1. Use empty META-INF/beans.xml instead of jandex-maven-plugin, or
  2. Force newer (2.1.1.Final) jandex dependency in jandex-maven-plugin:
<plugin>
  <groupId>org.jboss.jandex</groupId>
  <artifactId>jandex-maven-plugin</artifactId>
  <version>1.0.5</version>
  <executions>
    <execution>
      <id>make-index</id>
      <goals>
        <goal>jandex</goal>
      </goals>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>org.jboss</groupId>
      <artifactId>jandex</artifactId>
      <version>2.1.1.Final</version>
    </dependency>
  </dependencies>
</plugin>

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/arcIssue related to ARC (dependency injection)kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions