Skip to content

Commit a65fafd

Browse files
committed
Remove our lambda special case.
This is now handled by upstream ASM directly. https://gitlab.ow2.org/asm/asm/-/commit/124a45002ba09a6bf6fc6ce4a428321737f466f1
1 parent a72ab51 commit a65fafd

1 file changed

Lines changed: 3 additions & 29 deletions

File tree

‎src/main/java/net/minecraftforge/renamer/internal/EnhancedClassRemapper.java‎

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.util.List;
99

1010
import org.objectweb.asm.ClassVisitor;
11-
import org.objectweb.asm.Handle;
1211
import org.objectweb.asm.Label;
1312
import org.objectweb.asm.MethodVisitor;
1413
import org.objectweb.asm.Opcodes;
@@ -26,9 +25,6 @@ class EnhancedClassRemapper extends ClassRemapper {
2625
this.transformer = transformer;
2726
}
2827

29-
private static final Handle META_FACTORY = new Handle(Opcodes.H_INVOKESTATIC, "java/lang/invoke/LambdaMetafactory", "metafactory", "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;", false);
30-
private static final Handle ALT_META_FACTORY = new Handle(Opcodes.H_INVOKESTATIC, "java/lang/invoke/LambdaMetafactory", "altMetafactory", "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;", false);
31-
3228
@Override
3329
public MethodVisitor visitMethod(final int access, final String mname, final String mdescriptor, final String msignature, final String[] exceptions) {
3430
//System.out.println("Method: " + className + '/' + mname + mdescriptor);
@@ -37,39 +33,17 @@ public MethodVisitor visitMethod(final int access, final String mname, final Str
3733
if (methodVisitor == null)
3834
return null;
3935

36+
// There is no bytecode storage for abstract parameters, so we store them locally in a special file fernflower can see
4037
if ((access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) != 0)
4138
renameAbstract(access, mname, mdescriptor);
4239

40+
// We no longer have to map lambas as Upstream has now added support: https://gitlab.ow2.org/asm/asm/-/commit/124a45002ba09a6bf6fc6ce4a428321737f466f1
41+
// However we still have to map local variable names
4342
return new MethodRemapper(methodVisitor, remapper) {
4443
@Override
4544
public void visitLocalVariable(final String pname, final String pdescriptor, final String psignature, final Label start, final Label end, final int index) {
4645
super.visitLocalVariable(EnhancedClassRemapper.this.remapper.mapParameterName(className, mname, mdescriptor, index, pname), pdescriptor, psignature, start, end, index);
4746
}
48-
49-
@Override
50-
public void visitInvokeDynamicInsn(final String name, final String descriptor, final Handle bootstrapMethodHandle, final Object... bootstrapMethodArguments) {
51-
if (META_FACTORY.equals(bootstrapMethodHandle) || ALT_META_FACTORY.equals(bootstrapMethodHandle)) {
52-
String owner = Type.getReturnType(descriptor).getInternalName();
53-
String odesc = ((Type)bootstrapMethodArguments[0]).getDescriptor();
54-
// First constant argument is "samMethodType - Signature and return type of method to be implemented by the function object."
55-
// index 2 is the signature, but with generic types. Should we use that instead?
56-
57-
// We can't call super, because that'd double map the name.
58-
// So we do our own mapping.
59-
Object[] remappedBootstrapMethodArguments = new Object[bootstrapMethodArguments.length];
60-
for (int i = 0; i < bootstrapMethodArguments.length; ++i) {
61-
remappedBootstrapMethodArguments[i] = remapper.mapValue(bootstrapMethodArguments[i]);
62-
}
63-
mv.visitInvokeDynamicInsn(
64-
remapper.mapMethodName(owner, name, odesc), // We change this
65-
remapper.mapMethodDesc(descriptor),
66-
(Handle) remapper.mapValue(bootstrapMethodHandle),
67-
remappedBootstrapMethodArguments);
68-
return;
69-
}
70-
71-
super.visitInvokeDynamicInsn(name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments);
72-
}
7347
};
7448
}
7549

0 commit comments

Comments
 (0)