Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-3638

Missing package import for annotation default value

    XMLWordPrintableJSON

Details

    Description

      For the following annotation class in an OSGi bundle

      @Retention(RetentionPolicy.RUNTIME)
      @Target(

      { ElementType.TYPE, ElementType.METHOD }

      )
      public @interface Transactional
      {
      @Nonbinding Class<? extends Annotation>[] qualifier() default Any.class;
      }

      maven-bundle-plugin fails to generate the package import for javax.enterprise.inject.Any, the default value of the annotation method.

      At runtime, this leads to a non-descriptive exception

      Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
      at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:673) ~[na:1.7.0_04]
      at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:480) ~[na:1.7.0_04]
      at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:306) ~[na:1.7.0_04]
      at java.lang.reflect.Method.getDefaultValue(Method.java:726) ~[na:1.7.0_04]
      at sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:117) ~[na:1.7.0_04]
      at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:84) ~[na:1.7.0_04]
      at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:221) ~[na:1.7.0_04]
      at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:88) ~[na:1.7.0_04]
      at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70) ~[na:1.7.0_04]
      at java.lang.Class.initAnnotationsIfNecessary(Class.java:3089) ~[na:1.7.0_04]
      at java.lang.Class.getDeclaredAnnotations(Class.java:3077) ~[na:1.7.0_04]

      which is hard to debug.

      The problem can be solved by adding an explicit Import-Package element to the plugin configuration, but I don't see why the plugin can't figure this out by itself.

      The example is taken from Apache Deltaspike.

      Attachments

        1. FELIX-3638.zip
          6 kB
          Harald Wellmann

        Activity

          People

            Unassigned Unassigned
            hwellmann Harald Wellmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: