Exemple #1
0
 @NotNull
 public static CapturedParamInfo findCapturedField(
     FieldInsnNode node, FieldRemapper fieldRemapper) {
   assert node.name.startsWith("$$$") : "Captured field template should start with $$$ prefix";
   FieldInsnNode fin =
       new FieldInsnNode(node.getOpcode(), node.owner, node.name.substring(3), node.desc);
   CapturedParamInfo field = fieldRemapper.findField(fin);
   if (field == null) {
     throw new IllegalStateException(
         "Couldn't find captured field "
             + node.owner
             + "."
             + node.name
             + " in "
             + fieldRemapper.getLambdaInternalName());
   }
   return field;
 }
Exemple #2
0
  private void transformCaptured(@NotNull MethodNode node) {
    if (nodeRemapper.isRoot()) {
      return;
    }

    // Fold all captured variable chain - ALOAD 0 ALOAD this$0 GETFIELD $captured - to GETFIELD
    // $$$$captured
    // On future decoding this field could be inline or unfolded in another field access chain (it
    // can differ in some missed this$0)
    AbstractInsnNode cur = node.instructions.getFirst();
    while (cur != null) {
      if (cur instanceof VarInsnNode && cur.getOpcode() == Opcodes.ALOAD) {
        if (((VarInsnNode) cur).var == 0) {
          List<AbstractInsnNode> accessChain = getCapturedFieldAccessChain((VarInsnNode) cur);
          AbstractInsnNode insnNode = nodeRemapper.foldFieldAccessChainIfNeeded(accessChain, node);
          if (insnNode != null) {
            cur = insnNode;
          }
        }
      }
      cur = cur.getNext();
    }
  }