diff --git a/src/de/dhbwstuttgart/bytecode/BytecodeGen.java b/src/de/dhbwstuttgart/bytecode/BytecodeGen.java index c6618faa..c7fbe36d 100644 --- a/src/de/dhbwstuttgart/bytecode/BytecodeGen.java +++ b/src/de/dhbwstuttgart/bytecode/BytecodeGen.java @@ -167,12 +167,14 @@ public class BytecodeGen implements ASTVisitor { public void visit(Method method) { // TODO: check if the method is static => if static then the first param will be stored in pos 0 // else it will be stored in pos 1 and this will be stored in pos 0 + String retType = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor()); + String methParamTypes = retType+method.name+"%%"; method.getParameterList().accept(this); - String methParamTypes = method.name+";"; + Iterator itr = method.getParameterList().iterator(); while(itr.hasNext()) { FormalParameter fp = itr.next(); - methParamTypes = methParamTypes+ resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+";"; + methParamTypes += resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+";"; } if(methodNameAndParamsT.contains(methParamTypes)) { diff --git a/test/bytecode/OverloadingTest.java b/test/bytecode/OverloadingTest.java index 4cdaf39d..294bf533 100644 --- a/test/bytecode/OverloadingTest.java +++ b/test/bytecode/OverloadingTest.java @@ -44,14 +44,14 @@ public class OverloadingTest { public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { Method meth = classToTest.getDeclaredMethod("test", classToTest); String res = (String) meth.invoke(instanceOfClass, instanceOfClass); - assertEquals("\"Overloading\"", res); + assertEquals("Overloading", res); } @Test public void test2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { Method meth = classToTest.getDeclaredMethod("test", classOL2); String res = (String) meth.invoke(instanceOfClass, instanceOfClassOL2); - assertEquals("\"Overloading2\"", res); + assertEquals("Overloading2", res); } }