forked from JavaTX/JavaCompilerCore
GenCode: Lambda theorethisch korrekt, hängt aber noch an einer
unbekannten NullPointerException
This commit is contained in:
parent
2b12767764
commit
172ea3fbee
@ -2,8 +2,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.apache.bcel.classfile.ConstantPool;
|
||||
import org.apache.bcel.generic.BIPUSH;
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.ConstantPoolGen;
|
||||
import org.apache.bcel.generic.InstructionFactory;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
import org.apache.bcel.generic.INVOKEDYNAMIC;
|
||||
@ -213,16 +215,22 @@ public class LambdaExpression extends Expr{
|
||||
|
||||
@Override
|
||||
public InstructionList genByteCode(ClassGen cg) {
|
||||
//InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
|
||||
ConstantPoolGen cp = cg.getConstantPool();
|
||||
InstructionList il = new InstructionList();
|
||||
short opcode = 186;//opcode - was genau ist das?
|
||||
/*
|
||||
* Bytecode:
|
||||
* 0: invokedynamic #2, 0 //#2 führt zu einem InvokeDynamic im KP - wildes Referenzieren
|
||||
* 5: astore_1 //Speichert wahrscheinlich den String meiner TestEXPR
|
||||
* 6: return
|
||||
*/
|
||||
|
||||
//---Variante 1 mit opcode----
|
||||
short opcode = 186;//opcode - was genau ist das?
|
||||
il.append(new INVOKEDYNAMIC(opcode, 0));//Invokedynamic lässt sich bei mir weder automatisch noch manuell importieren
|
||||
|
||||
//---Variante 2 mit Konstantenpool-Referenz---
|
||||
//int cpSize = cp.getSize()-1;//Vermutlich ist die benötigte Referenz das aktuellste Element?
|
||||
//il.append(new INVOKEDYNAMIC((short) cpSize, 0));
|
||||
return il;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ class LambdaExpr {
|
||||
|
||||
void method() {
|
||||
|
||||
Runnable r1 = () -> System.out.println("Hello world two!");
|
||||
lambda; lambda = ()-> 1;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user