Bug 82 gefixt und getestet. Descriptor von MethodCall von Interface korrigiert.

This commit is contained in:
Fayez Abu Alia 2018-07-03 11:15:58 +02:00
parent 29bd9a3f4f
commit 69706ee1d2
4 changed files with 15 additions and 8 deletions

View File

@ -658,13 +658,13 @@ public class BytecodeGenMethod implements StatementVisitor {
methodCall.arglist.accept(this); methodCall.arglist.accept(this);
MethodFromMethodCall method = new MethodFromMethodCall(methodCall.arglist, methodCall.getType(), MethodFromMethodCall method = new MethodFromMethodCall(methodCall.arglist, methodCall.getType(),
genericsAndBoundsMethod, genericsAndBounds); receiverName, genericsAndBoundsMethod, genericsAndBounds);
String mDesc = method.accept(new DescriptorToString(resultSet)); String mDesc = method.accept(new DescriptorToString(resultSet));
System.out.println("Methodcall Desc : " + mDesc); System.out.println("Methodcall Desc : " + mDesc);
// is methodCall.receiver functional Interface)? // is methodCall.receiver functional Interface)?
if (varsFunInterface.contains(methodCall.receiver.getType())) { if (varsFunInterface.contains(methodCall.receiver.getType())) {
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, getResolvedType(methodCall.receiver.getType()), methodCall.name, mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, getResolvedType(methodCall.receiver.getType()), methodCall.name,
mDesc, false); mDesc, true);
} else { } else {
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getResolvedType(methodCall.receiver.getType()), methodCall.name, mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getResolvedType(methodCall.receiver.getType()), methodCall.name,
mDesc, isInterface); mDesc, isInterface);

View File

@ -172,7 +172,7 @@ public class DescriptorToString implements DescriptorVisitor{
for(Expression e : methodFromMethodCall.getArgList().getArguments()) { for(Expression e : methodFromMethodCall.getArgList().getArguments()) {
String d = resultSet.resolveType(e.getType()).resolvedType.acceptTV(new TypeToDescriptor()); String d = resultSet.resolveType(e.getType()).resolvedType.acceptTV(new TypeToDescriptor());
if(d.substring(0, 4).equals("TPH ") ||d.contains("<")) { if(d.substring(0, 4).equals("TPH ") ||d.contains("<") || methodFromMethodCall.getReceiverName().contains("$$")) {
desc += "L"+Type.getInternalName(Object.class)+ ";"; desc += "L"+Type.getInternalName(Object.class)+ ";";
}else { }else {
if(methodFromMethodCall.getGenericsAndBoundsMethod().containsKey(d)) { if(methodFromMethodCall.getGenericsAndBoundsMethod().containsKey(d)) {
@ -189,7 +189,7 @@ public class DescriptorToString implements DescriptorVisitor{
System.out.println("DescriptorToString retType = " + retType); System.out.println("DescriptorToString retType = " + retType);
if(retType.equals("void")) { if(retType.equals("void")) {
desc += ")V"; desc += ")V";
}else if(retType.substring(0, 4).equals("TPH ")|| retType.contains("<")){ }else if(retType.substring(0, 4).equals("TPH ")|| retType.contains("<") || methodFromMethodCall.getReceiverName().contains("$$")){
desc += ")L"+Type.getInternalName(Object.class)+ ";"; desc += ")L"+Type.getInternalName(Object.class)+ ";";
}else { }else {
if(methodFromMethodCall.getGenericsAndBoundsMethod().containsKey(retType)) { if(methodFromMethodCall.getGenericsAndBoundsMethod().containsKey(retType)) {

View File

@ -9,13 +9,16 @@ import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
public class MethodFromMethodCall { public class MethodFromMethodCall {
private ArgumentList argList; private ArgumentList argList;
private RefTypeOrTPHOrWildcardOrGeneric returnType; private RefTypeOrTPHOrWildcardOrGeneric returnType;
private String receiverName;
private HashMap<String, String> genericsAndBoundsMethod; private HashMap<String, String> genericsAndBoundsMethod;
private HashMap<String,String> genericsAndBounds; private HashMap<String,String> genericsAndBounds;
public MethodFromMethodCall(ArgumentList argList,RefTypeOrTPHOrWildcardOrGeneric returnType, public MethodFromMethodCall(ArgumentList argList,RefTypeOrTPHOrWildcardOrGeneric returnType,
HashMap<String, String> genericsAndBoundsMethod,HashMap<String,String> genericsAndBounds) { String receiverName, HashMap<String, String> genericsAndBoundsMethod,
HashMap<String,String> genericsAndBounds) {
this.argList = argList; this.argList = argList;
this.returnType = returnType; this.returnType = returnType;
this.receiverName = receiverName;
this.genericsAndBoundsMethod = genericsAndBoundsMethod; this.genericsAndBoundsMethod = genericsAndBoundsMethod;
this.genericsAndBounds = genericsAndBounds; this.genericsAndBounds = genericsAndBounds;
} }
@ -28,6 +31,10 @@ public class MethodFromMethodCall {
return returnType; return returnType;
} }
public String getReceiverName() {
return receiverName;
}
public HashMap<String, String> getGenericsAndBoundsMethod(){ public HashMap<String, String> getGenericsAndBoundsMethod(){
return genericsAndBoundsMethod; return genericsAndBoundsMethod;
} }

View File

@ -7,8 +7,8 @@ public class Lambda {
var lam1 = (x) -> { var lam1 = (x) -> {
return x; return x;
}; };
// return lam1.apply(new Apply()); return lam1.apply(new Apply());
return lam1; // return lam1;
// return new Vector(); // return new Vector();
} }
} }