Details
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 ----------
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
- duplicates
-
JDK-8148432 tools/javac/annotations/typeAnnotations/classfile/NestedLambdasCastedTest.java fails on all platforms
- Closed
-
JDK-8033803 Incorrect offset for type annotations for NEW / CHECKCAST etc.
- Resolved