Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8143191

RuntimeVisibleParameterAnnotations for lambdas and confusing CDI injection

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 8u60
    • tools
    • x86_64
    • linux

      FULL PRODUCT VERSION :
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Netbeans 8.0.2
      Glassfish 4.1

      A DESCRIPTION OF THE PROBLEM :
      We have a method with the following signature:

      void deviceConnected(@Observes @DeviceConnected PublishedMessage pm)

      In that method is a lambda:

      wifiDeviceCache.invoke(d.getMacAddress(), (MutableEntry<String, WifiDevice> entry, Object... arguments) -> {
      ...
      }

      When WELD is processing this file it generates the following error:

      Severe: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type String with qualifiers @Default
        at injection point [BackedAnnotatedParameter] Parameter 5 of [BackedAnnotatedMethod] private com.lairdtech.tasverii.edm.entities.DeviceList.lambda$deviceConnected$9(String, Bssid, Date, String, String, @Observes @DeviceConnected PublishedMessage, String, MutableEntry<Object, Object>, Object[])
        at com.lairdtech.tasverii.edm.entities.DeviceList.lambda$deviceConnected$9(DeviceList.java:0)
      WELD-001475: The following beans match by type, but none have matching qualifiers:
        - Producer Method [String] with qualifiers [@BatchProperty @Any] declared as [[UnbackedAnnotatedMethod] @Produces @Dependent @BatchProperty public com.ibm.jbatch.container.cdi.BatchProducerBean.produceProperty(InjectionPoint)],
        - Producer Method [String] with qualifiers [@JaxRsParamQualifier @Any] declared as [[UnbackedAnnotatedMethod] @Produces @JaxRsParamQualifier public org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider$JaxRsParamProducer.getParameterValue(InjectionPoint, BeanManager)]

      If you replace this one class with a version compiled with jdk8u51 then the error goes away.

      When I disassemble the two classes (8u60 version & 8u51 version), they differ in the following way:

      8u51:

            LocalVariableTable:
              Start Length Slot Name Signature
                 22 58 10 wifiDevice Lcom/lairdlink/lib/cpwebdevices/device/WifiDevice;
                  0 163 0 this Lcom/lairdtech/tasverii/edm/entities/DeviceList;
                  0 163 8 entry Ljavax/cache/processor/MutableEntry;
                  0 163 9 arguments [Ljava/lang/Object;
                110 53 10 wifiDevice Lcom/lairdlink/lib/cpwebdevices/device/WifiDevice;

      8u60:

            LocalVariableTable:
              Start Length Slot Name Signature
                 22 58 10 wifiDevice Lcom/lairdlink/lib/cpwebdevices/device/WifiDevice;
                  0 163 0 this Lcom/lairdtech/tasverii/edm/entities/DeviceList;
                  0 163 1 ssid Ljava/lang/String;
                  0 163 2 bssid Lcom/lairdlink/lib/cpwebdevices/parsers/Bssid;
                  0 163 3 connectedDate Ljava/util/Date;
                  0 163 4 deviceType Ljava/lang/String;
                  0 163 5 ipAddr Ljava/lang/String;
                  0 163 6 pm Lcom/lairdlink/lib/rest/PublishedMessage;
                  0 163 7 name Ljava/lang/String;
                  0 163 8 entry Ljavax/cache/processor/MutableEntry;
                  0 163 9 arguments [Ljava/lang/Object;
                110 53 10 wifiDevice Lcom/lairdlink/lib/cpwebdevices/device/WifiDevice;

      and the 8u60 version has the following lines added:

          RuntimeVisibleParameterAnnotations:
            parameter 0:
            parameter 1:
            parameter 2:
            parameter 3:
            parameter 4:
            parameter 5:
              0: #223()
              1: #224()
            parameter 6:
            parameter 7:
            parameter 8:

      FYI, the constants it's referencing are:

        #223 = Utf8 Ljavax/enterprise/event/Observes;
        #224 = Utf8 Lcom/lairdlink/lib/cpwebdevices/rest/DeviceConnected;



      REGRESSION. Last worked in version 8u51

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile a method with javaee annotations that contains a lambda that references the annotated parameter.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Appropriate CDI injections happen.
      ACTUAL -
      CDI complains that it can't inject values in the lambda's signature.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Severe: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type String with qualifiers @Default
        at injection point [BackedAnnotatedParameter] Parameter 5 of [BackedAnnotatedMethod] private com.lairdtech.tasverii.edm.entities.DeviceList.lambda$deviceConnected$9(String, Bssid, Date, String, String, @Observes @DeviceConnected PublishedMessage, String, MutableEntry<Object, Object>, Object[])
        at com.lairdtech.tasverii.edm.entities.DeviceList.lambda$deviceConnected$9(DeviceList.java:0)
      WELD-001475: The following beans match by type, but none have matching qualifiers:
        - Producer Method [String] with qualifiers [@BatchProperty @Any] declared as [[UnbackedAnnotatedMethod] @Produces @Dependent @BatchProperty public com.ibm.jbatch.container.cdi.BatchProducerBean.produceProperty(InjectionPoint)],
        - Producer Method [String] with qualifiers [@JaxRsParamQualifier @Any] declared as [[UnbackedAnnotatedMethod] @Produces @JaxRsParamQualifier public org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider$JaxRsParamProducer.getParameterValue(InjectionPoint, BeanManager)]

      REPRODUCIBILITY :
      This bug can be reproduced always.

            fmatte Fairoz Matte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: