From 857d63322eba3c4f201b87f024da476c8b93b0be Mon Sep 17 00:00:00 2001 From: Fayez Abu Alia Date: Fri, 7 Jun 2019 10:28:48 +0200 Subject: [PATCH] Fixed Bug 152 Faculty Probleme --- .../dhbwstuttgart/bytecode/BytecodeGenMethod.java | 14 ++++++-------- .../bytecode/utilities/MethodCallHelper.java | 13 +++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java b/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java index b7e6e6ea6..02169d6ae 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java @@ -896,7 +896,8 @@ public class BytecodeGenMethod implements StatementVisitor { // methodCall.arglist.accept(this); // is methodCall.receiver functional Interface)? - if (varsFunInterface.contains(methodCall.receiver.getType()) || (methodRefl!= null && receiverRefl.contains("interface"))) { + if (varsFunInterface.contains(methodCall.receiver.getType()) || (methodRefl!= null && receiverRefl.contains("interface")) || + receiverName.contains("$$")) { mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, clazz.replace(".", "/"), methodCall.name, mDesc, true); } else { @@ -908,16 +909,12 @@ public class BytecodeGenMethod implements StatementVisitor { if(methodRefl != null && !methodRefl.getReturnType().isPrimitive()) { if(methodRefl.getReturnType().equals(Object.class)) { - String checkCast = getResolvedType(methodCall.getType()); - if(!checkCast.contains("TPH ")) { - int pos = checkCast.length(); - if(checkCast.contains("<")) - pos = checkCast.indexOf("<"); - mv.visitTypeInsn(Opcodes.CHECKCAST,checkCast.substring(0,pos)); - } + helper.createCheckCast(methodCall,mv); } if(isBinaryExp) doUnboxing(getResolvedType(methodCall.getType())); + } else if(receiverName.contains("$$") && !methCallType.equals(Type.getInternalName(Object.class))) { + helper.createCheckCast(methodCall,mv); } System.out.println("ISParent Binary = "+isParentBinary +" -> " + parentBinary); if(methodRefl == null && (parentBinary || !isReturnStmt)) { @@ -926,6 +923,7 @@ public class BytecodeGenMethod implements StatementVisitor { } } + private String getDescForMethInCurrPkg(String name) { // TODO Auto-generated method stub diff --git a/src/main/java/de/dhbwstuttgart/bytecode/utilities/MethodCallHelper.java b/src/main/java/de/dhbwstuttgart/bytecode/utilities/MethodCallHelper.java index e1f7ea6dc..be57376b8 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/utilities/MethodCallHelper.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/utilities/MethodCallHelper.java @@ -282,5 +282,18 @@ public class MethodCallHelper { } } + + /** + * @param methodCall + */ + public void createCheckCast(MethodCall methodCall, MethodVisitor mv) { + String checkCast = getResolvedType(methodCall.getType()); + if(!checkCast.contains("TPH ")) { + int pos = checkCast.length(); + if(checkCast.contains("<")) + pos = checkCast.indexOf("<"); + mv.visitTypeInsn(Opcodes.CHECKCAST,checkCast.substring(0,pos)); + } + } }