From ae01af7a400e74559f76052f2588f5e56430e9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Schr=C3=B6dter?= Date: Tue, 3 May 2016 18:15:14 +0200 Subject: [PATCH 1/3] Bugfix: OverloadingTest --- src/de/dhbwstuttgart/syntaxtree/Method.java | 5 +---- src/de/dhbwstuttgart/syntaxtree/type/RefType.java | 9 +++++---- src/de/dhbwstuttgart/syntaxtree/type/Type.java | 5 ----- test/bytecode/types/OL.jav | 4 ++-- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/Method.java b/src/de/dhbwstuttgart/syntaxtree/Method.java index dfff897c0..c50f8416f 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Method.java +++ b/src/de/dhbwstuttgart/syntaxtree/Method.java @@ -78,15 +78,12 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable private Modifiers modifiers; protected static Logger inferencelog = Logger.getLogger("inference"); protected static Logger parserlog = Logger.getLogger("parser"); - - protected Menge createdMethods = new Menge<>(); public Method(int offset) { super(offset); } - public Method(String name, Type returnType, ParameterList parameterList, - Block block, GenericDeclarationList gtvDeclarations, int offset) { + public Method(String name, Type returnType, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, int offset) { this(offset); /* * if(parameterList != null)parameterList.parserPostProcessing(this); diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java index 20e8fe251..2df27dbab 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -602,17 +602,18 @@ public class RefType extends ObjectType implements IMatchable sb.append(((RefType) type).getCombinedType(cg, rs).replace(".", "%")); }else if(type instanceof TypePlaceholder){ sb.append(((TypePlaceholder) type).getBytecodeType(cg, rs).toString().replace(".", "%")); + }else if(type instanceof WildcardType){ + return this.getName().toString(); }else{ sb.append(type.getBytecodeType(cg, rs).toString().replace(".", "%")); } sb.append("%"); } - }else{ - sb.append(this.getName().toString()); - } + return sb.toString(); + } - return sb.toString(); + return sb.append(this.getName().toString()).toString(); } public GenericClassType getGenericClassType(){ diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Type.java b/src/de/dhbwstuttgart/syntaxtree/type/Type.java index 7d57e1e95..6fc42efa0 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/Type.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/Type.java @@ -17,11 +17,6 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.exceptions.DebugException; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; -class Test { - void methode(ArrayList t){ - - } -} //TODO: Die Klasse Type muss abstract werden! // ino.class.Type.26716.declaration diff --git a/test/bytecode/types/OL.jav b/test/bytecode/types/OL.jav index c6349bdc2..67a79c559 100644 --- a/test/bytecode/types/OL.jav +++ b/test/bytecode/types/OL.jav @@ -1,6 +1,6 @@ class OL { - m(x) { return x + x; } - Boolean m(Boolean x) {return x; } + m(Boolean x) {return x; } + } \ No newline at end of file From 58db64ad22da62ddd28fd5466a8610e095667534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Schr=C3=B6dter?= Date: Thu, 12 May 2016 20:50:36 +0200 Subject: [PATCH 2/3] WildCardTest implementiert --- test/bytecode/types/ExtendsTypeTest.java | 33 ----------------- .../types/ExtendsVectorStringTest.java | 2 +- test/bytecode/types/SuperType.java | 37 ------------------- test/bytecode/types/WildcardTest.jav | 10 ++--- test/bytecode/types/WildcardTest.java | 2 +- 5 files changed, 6 insertions(+), 78 deletions(-) delete mode 100644 test/bytecode/types/ExtendsTypeTest.java delete mode 100644 test/bytecode/types/SuperType.java diff --git a/test/bytecode/types/ExtendsTypeTest.java b/test/bytecode/types/ExtendsTypeTest.java deleted file mode 100644 index a3560b9c6..000000000 --- a/test/bytecode/types/ExtendsTypeTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package bytecode.types; - -import static org.junit.Assert.*; - -import java.io.File; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Vector; - -import org.junit.Ignore; -import org.junit.Test; - -import bytecode.SourceFileBytecodeTest; - -public class ExtendsTypeTest extends SourceFileBytecodeTest{ - @Override - protected void init() { - testName = "ExtendsType"; - rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/"; - } - - @Test - @Ignore - public void testConstruct() throws Exception{ - ClassLoader classLoader = getClassLoader(); - - Class cls = classLoader.loadClass(testName); - - Object obj = cls.newInstance(); - assertTrue(true); - } -} diff --git a/test/bytecode/types/ExtendsVectorStringTest.java b/test/bytecode/types/ExtendsVectorStringTest.java index f92c61ad2..c106fbeec 100644 --- a/test/bytecode/types/ExtendsVectorStringTest.java +++ b/test/bytecode/types/ExtendsVectorStringTest.java @@ -61,7 +61,7 @@ public class ExtendsVectorStringTest extends ASTBytecodeTest{ Object obj = cls.newInstance(); - Class objectClass = classLoader.loadClass("java.lang.Object"); + Class objectClass = classLoader.loadClass("java.lang.String"); Class[] params = new Class[1]; params[0] = objectClass; diff --git a/test/bytecode/types/SuperType.java b/test/bytecode/types/SuperType.java deleted file mode 100644 index 42a8d77b9..000000000 --- a/test/bytecode/types/SuperType.java +++ /dev/null @@ -1,37 +0,0 @@ -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 org.junit.Ignore; - -import bytecode.SourceFileBytecodeTest; - - -public class SuperType extends SourceFileBytecodeTest{ - - @Override - protected void init() { - testName = "ExtendsType"; - rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/"; - } - - @Test - @Ignore - public void testConstruct() throws Exception{ - ClassLoader classLoader = getClassLoader(); - - Class cls = classLoader.loadClass(testName); - - Object obj = cls.newInstance(); - assertTrue(true); - } -} diff --git a/test/bytecode/types/WildcardTest.jav b/test/bytecode/types/WildcardTest.jav index f029c2d08..647d7b668 100644 --- a/test/bytecode/types/WildcardTest.jav +++ b/test/bytecode/types/WildcardTest.jav @@ -1,13 +1,11 @@ import java.util.Vector; -class SuperType{ - Vector numberVector; - - void method() { - method(numberVector); +class WildcardTest{ + void lower(Vector v) { + } - void method(Vector v) { + void upper(Vector v) { } } \ No newline at end of file diff --git a/test/bytecode/types/WildcardTest.java b/test/bytecode/types/WildcardTest.java index 6dd41df80..44df73a95 100644 --- a/test/bytecode/types/WildcardTest.java +++ b/test/bytecode/types/WildcardTest.java @@ -12,7 +12,7 @@ import bytecode.SourceFileBytecodeTest; public class WildcardTest extends SourceFileBytecodeTest{ @Override protected void init() { - testName = "Wildcard"; + testName = "WildcardTest"; rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/"; } From 47c2b787133b42ec48a4c794708a626165069e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Schr=C3=B6dter?= Date: Thu, 12 May 2016 21:14:57 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Testfall=20f=C3=BCr=20Bug=2048:=20Uninizier?= =?UTF-8?q?te=20Variablen=20erstellt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/bytecode/UninitializedVariable.jav | 15 ++++++++ test/bytecode/UninitializedVariableTest.java | 39 ++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/bytecode/UninitializedVariable.jav create mode 100644 test/bytecode/UninitializedVariableTest.java diff --git a/test/bytecode/UninitializedVariable.jav b/test/bytecode/UninitializedVariable.jav new file mode 100644 index 000000000..0854d0a90 --- /dev/null +++ b/test/bytecode/UninitializedVariable.jav @@ -0,0 +1,15 @@ +import java.util.Vector; + +class UninitializedVariable{ + + Integer method(Integer v) { + return v; + } + + public static void main(String[] args) { + UninitializedVariable ol; + ol = new UninitializedVariable(); + Integer v; + ol.method(v); + } +} \ No newline at end of file diff --git a/test/bytecode/UninitializedVariableTest.java b/test/bytecode/UninitializedVariableTest.java new file mode 100644 index 000000000..838d97083 --- /dev/null +++ b/test/bytecode/UninitializedVariableTest.java @@ -0,0 +1,39 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; + +import org.junit.Test; + +import plugindevelopment.TypeInsertTester; +import de.dhbwstuttgart.core.MyCompiler; +import de.dhbwstuttgart.core.MyCompilerAPI; +import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.typeinference.ByteCodeResult; +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; +import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; + +public class UninitializedVariableTest extends SourceFileBytecodeTest{ + @Override + protected void init() { + testName = "UninitializedVariable"; + rootDirectory = System.getProperty("user.dir")+"/test/bytecode/"; + } + + @Test + public void testConstruct() throws Exception{ + ClassLoader classLoader = getClassLoader(); + + Class cls = classLoader.loadClass(testName); + + Object obj = cls.newInstance(); + assertTrue(true); + } +}