2

Given the following Java code:

public interface HasUniqueKey<Key> {
  Key getInternId();
}

public class Util {
  public static List<Integer> toIntegerList(List<? extends HasUniqueKey<Integer>> entities) {
    return entities.stream().map(m -> m.getInternId()).collect(Collectors.toList());
  }
}

Eclipse Mars and Neon (haven't tested others) are producing the following bytecode for the lambda (as seen with javap -v -p -c -l -s -constants):

private static java.lang.Integer lambda$0(HasUniqueKey);
    descriptor: (LHasUniqueKey;)Ljava/lang/Integer;
    flags: ACC_PRIVATE, ACC_STATIC, ACC_SYNTHETIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokeinterface #68,  1           // InterfaceMethod HasUniqueKey.getInternId:()Ljava/lang/Object;
         6: checkcast     #74                 // class java/lang/Integer
         9: areturn
      LineNumberTable:
        line 8: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      10     0     m   LHasUniqueKey;
      LocalVariableTypeTable:
        Start  Length  Slot  Name   Signature
            0      10     0     m   !+LHasUniqueKey<Ljava/lang/Integer;>;

I'm quite puzzled as to this last signature for parameter m: !+LHasUniqueKey<Ljava/lang/Integer;>;. It doesn't seem to comply with the JLS definition on signatures, the "!+" is invalid there (and I have no idea what "!" means in this context).

The javac compiler doesn't produce LocalVariableTypeTable metadata, since that is intended for debuggers only.

Can anyone provide some insight as to what this signature means? Is this a bug on Eclipse JDT?

Johnco
  • 4,037
  • 4
  • 34
  • 43

0 Answers0