diff --git a/src/de/dhbwstuttgart/bytecode/ClassGenerator.java b/src/de/dhbwstuttgart/bytecode/ClassGenerator.java index 57bbc87f2..8e2a86d19 100644 --- a/src/de/dhbwstuttgart/bytecode/ClassGenerator.java +++ b/src/de/dhbwstuttgart/bytecode/ClassGenerator.java @@ -126,7 +126,7 @@ public class ClassGenerator extends ClassGen{ //Signatur setzen: String typeParameters = this.generateParameterSignature(); - String superClassSignature = this.superClass.getBytecodeSignature(this, getTypeinferenceResults().getTypeReconstructions().firstElement()); + String superClassSignature = this.superClass.getBytecodeSignature(this, null); String classSignature = typeParameters + superClassSignature; if(classSignature.length()>0){ this.addAttribute(new Signature(cp.addUtf8("Signature"),2,cp.addUtf8(classSignature),cp.getConstantPool())); diff --git a/src/de/dhbwstuttgart/syntaxtree/Constructor.java b/src/de/dhbwstuttgart/syntaxtree/Constructor.java index 17fcd8740..f7e7fc459 100644 --- a/src/de/dhbwstuttgart/syntaxtree/Constructor.java +++ b/src/de/dhbwstuttgart/syntaxtree/Constructor.java @@ -67,7 +67,7 @@ public class Constructor extends Method { InstructionList il = new InstructionList(); //sollte nicht new sein sondern aus Block kommen Class parentClass = this.getParentClass(); - MethodGenerator method = new MethodGenerator(Constants.ACC_PUBLIC, this.getType().getBytecodeType(cg, cg.getTypeinferenceResults().getTypeReconstructions().firstElement()), org.apache.commons.bcel6.generic.Type.NO_ARGS , new String[] { }, "", parentClass.name, il, _cp); + MethodGenerator method = new MethodGenerator(Constants.ACC_PUBLIC, this.getType().getBytecodeType(cg, null), org.apache.commons.bcel6.generic.Type.NO_ARGS , new String[] { }, "", parentClass.name, il, _cp); //FieldInitializations an Block anfügen Block block = this.get_Block(); @@ -79,7 +79,7 @@ public class Constructor extends Method { //method.setMaxStack(); //Die Stack Größe automatisch berechnen lassen (erst nach dem alle Instructions angehängt wurden) - cg.addMethod(method.createMethod(cg, getParameterList(), this.getType(), get_Block(), cg.getTypeinferenceResults().getTypeReconstructions().firstElement())); + cg.addMethod(method.createMethod(cg, getParameterList(), this.getType(), get_Block(), null)); } /** diff --git a/test/bytecode/SingleClassTester.java b/test/bytecode/SingleClassTester.java index 1a02e4d39..5c4eface1 100644 --- a/test/bytecode/SingleClassTester.java +++ b/test/bytecode/SingleClassTester.java @@ -38,6 +38,8 @@ public class SingleClassTester { Menge bytecode = compiler.generateBytecode(sourceFiles, results); //System.out.println(bytecode); + + ByteCodeResult result = bytecode.firstElement(); JavaClass javaClass = result.getByteCode().getJavaClass(); diff --git a/test/bytecode/types/AutoOverloading.jav b/test/bytecode/types/AutoOverloading.jav index 193bbfe7b..314a7f48f 100644 --- a/test/bytecode/types/AutoOverloading.jav +++ b/test/bytecode/types/AutoOverloading.jav @@ -1,5 +1,3 @@ -import java.util.Vector; - class AutoOverloading{ method2(String p){ diff --git a/test/bytecode/types/AutoOverloadingVector.jav b/test/bytecode/types/AutoOverloadingVector.jav new file mode 100644 index 000000000..431abf650 --- /dev/null +++ b/test/bytecode/types/AutoOverloadingVector.jav @@ -0,0 +1,18 @@ +import java.util.Vector; + +class AutoOverloadingVector{ + method2(p){ + + } + + + method(Vector p){ + method2(p.firstElement()); + } + + + method(Vector p){ + method2(p.firstElement()); + } + +} \ No newline at end of file diff --git a/test/bytecode/types/AutoOverloadingVectorTest.java b/test/bytecode/types/AutoOverloadingVectorTest.java new file mode 100644 index 000000000..aa4264b7b --- /dev/null +++ b/test/bytecode/types/AutoOverloadingVectorTest.java @@ -0,0 +1,84 @@ +package bytecode.types; + +import static org.junit.Assert.*; + +import java.io.File; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Vector; + +import org.junit.Test; + +import bytecode.SourceFileBytecodeTest; + +public class AutoOverloadingVectorTest extends SourceFileBytecodeTest{ + @Override + protected void init() { + testName = "AutoOverloadingVector"; + rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/"; + } + + @Test + public void testConstruct() throws Exception{ + ClassLoader classLoader = getClassLoader(); + + Class cls = classLoader.loadClass(testName); + + Object obj = cls.newInstance(); + assertTrue(true); + } + + @Test + public void testString() { + try{ + ClassLoader classLoader = getClassLoader(); + + Class cls = classLoader.loadClass(testName); + + Object obj = cls.newInstance(); + + File file = new File(rootDirectory); + URL url = file.toURL(); + URL[] urls = new URL[]{url}; + + Class string = classLoader.loadClass("java.lang.String"); + + Class[] params = new Class[1]; + params[0] = string; + + Method method = cls.getDeclaredMethod("method2", params); + method.invoke(obj, string.newInstance()); + assertTrue(true); + }catch(Exception e){ + throw new RuntimeException(e); + } + } + + @Test + public void testInteger() { + try{ + ClassLoader classLoader = getClassLoader(); + + Class cls = classLoader.loadClass(testName); + + Object obj = cls.newInstance(); + + File file = new File(rootDirectory); + URL url = file.toURL(); + URL[] urls = new URL[]{url}; + + Integer integer = new Integer(123); + + Class[] params = new Class[1]; + params[0] = integer.getClass(); + + Method method = cls.getDeclaredMethod("method2", params); + method.invoke(obj, integer); + assertTrue(true); + }catch(Exception e){ + throw new RuntimeException(e); + } + } +} diff --git a/test/bytecode/types/MethodWithTypedVector.jav b/test/bytecode/types/MethodWithTypedVector.jav index a74062eeb..35261e96f 100644 --- a/test/bytecode/types/MethodWithTypedVector.jav +++ b/test/bytecode/types/MethodWithTypedVector.jav @@ -4,4 +4,8 @@ class MethodWithTypedVector{ public void method(Vector v) { } + + public void method(Vector v) { + + } } \ No newline at end of file