- edited description
Strange bytecode generated for anonymous lambda class
Issue #286
resolved
ExtendJ 8.1.0-47-gdeb1b1c Java SE 8
ExtendJ generates weird bytecode for the anonymous class implementing the second lambda expression in this test:
import java.util.*;
import java.util.stream.*;
public class Test {
public static void main(String[] args) {
String[] names = { "Alice", "Bob", "Acorn" };
IntStream ints = strLen(Arrays.asList(names));
ints.forEach(i -> System.out.println(i));
}
static IntStream strLen(List<? extends String> names) {
return names.stream().mapToInt(name -> name.length());
}
}
The test compiles and runs fine, but the generated bytecode is strange. The relevant parts of the class Test$2
are:
public int applyAsInt(wildcards.? extends String);
flags: ACC_PUBLIC
Code:
stack=1, locals=2, args_size=2
0: aload_1
1: invokevirtual #24 // Method java/lang/String.length:()I
4: ireturn
LineNumberTable:
line 11: 0
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this LTest$2;
0 5 1 name Ljava/lang/String;
Signature: #27 // (Lwildcards/? extends String;)I
public int applyAsInt(java.lang.Object);
flags: ACC_PUBLIC, ACC_BRIDGE, ACC_SYNTHETIC
Code:
stack=2, locals=2, args_size=2
0: aload_0
1: aload_1
2: checkcast #20 // class java/lang/String
5: invokevirtual #32 // Method applyAsInt:(Ljava/lang/String;)I
8: ireturn
LineNumberTable:
line 0: 0
LocalVariableTable:
Start Length Slot Name Signature
0 9 0 this LTest$2;
0 9 1 p0 Ljava/lang/Object;
The method type signature for the first method is strange, and the second bridge method should not be needed if the first method argument is reified.
Comments (2)
-
reporter -
reporter - changed status to resolved
Recursive wildcard removal
This makes the nonWildcardParameterization() attribute work on recursive wildcard types.
fixes
#286(bitbucket)→ <<cset 55ea0e757b74>>
- Log in to comment