From 32ab198f9e8e043055e80aa4049aa9b9b20c054e Mon Sep 17 00:00:00 2001 From: Fayez Abu Alia Date: Wed, 28 Mar 2018 14:57:36 +0200 Subject: [PATCH] =?UTF-8?q?Bugfix=20f=C3=BCr=20duplicate=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/de/dhbwstuttgart/bytecode/BytecodeGen.java | 6 ++++-- test/bytecode/OverloadingTest.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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); } }