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

No type annotations generated for nested lambdas

    XMLWordPrintable

Details

    • 8
    • b104
    • x86
    • windows_8
    • Verified

    Description

      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 :
      Windows 10

      A DESCRIPTION OF THE PROBLEM :
      For next class only two first lambdas will be marked with type annotations (in compiled bytecode). Thirst and fourth lambdas will be compiled without any type annotations information.

      package org.jcoro;

      import java.lang.annotation.ElementType;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;

      public class TestClass {
          @Target({ElementType.METHOD, ElementType.TYPE_USE})
          @Retention(RetentionPolicy.RUNTIME)
          public @interface TypeAnn {
              String value() default "";
          }

          public static void main(String[] args) {
              Runnable one = (@TypeAnn("1") Runnable) () -> {
                  Runnable two = (@TypeAnn("2") Runnable) () -> {
                      Runnable three = (@TypeAnn("3") Runnable) () -> {
                          Runnable four = (@TypeAnn("4") Runnable) () -> {
                          };
                      };
                  };
              };
          }
      }


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the test example
      2. Disassemble class file using command
      javap -v -l -p -c -s -sysinfo -constants

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      All of invokedynamic calls should be annotated with something like this:

      RuntimeVisibleTypeAnnotations:
              0: #18(#19=s#22): CAST, offset=0, type_index=0

      ACTUAL -
      Only two lambdas are annotated.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package org.jcoro;

      import java.lang.annotation.ElementType;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;

      public class TestClass {
          @Target({ElementType.METHOD, ElementType.TYPE_USE})
          @Retention(RetentionPolicy.RUNTIME)
          public @interface TypeAnn {
              String value() default "";
          }

          public static void main(String[] args) {
              Runnable one = (@TypeAnn("1") Runnable) () -> {
                  Runnable two = (@TypeAnn("2") Runnable) () -> {
                      Runnable three = (@TypeAnn("3") Runnable) () -> {
                          Runnable four = (@TypeAnn("4") Runnable) () -> {
                          };
                      };
                  };
              };
          }
      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              sadayapalam Srikanth Adayapalam (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: