diff --git a/src/de/dhbwstuttgart/syntaxtree/Class.java b/src/de/dhbwstuttgart/syntaxtree/Class.java index f5cbb6c9..8309c7b1 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Class.java +++ b/src/de/dhbwstuttgart/syntaxtree/Class.java @@ -196,11 +196,11 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I { this.name = name; if(name.equals("java.lang.Object")){ - superclassid=null; + superclassid=null; } this.offset = offset; if(!name.equals("Object") && !name.equals("java.lang.Object"))//Alle Klassen außer Object erben von Object: - this.superClass = new Class("java.lang.Object", -1).getType(); + this.superClass = new ObjectClass().getType(); } // ino.end @@ -235,7 +235,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I public Class(String name, RefType superClass, Modifiers mod, int offset){ this(name,mod,offset); - if(superClass == null)this.superClass = new Class("java.lang.Object",-1).getType(); + if(superClass == null)this.superClass = new ObjectClass().getType(); else this.superClass = superClass; } diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java index c02ed64f..cf71372a 100644 --- a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java +++ b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java @@ -4,6 +4,7 @@ import de.dhbwstuttgart.bytecode.ClassGenerator; import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Constructor; import de.dhbwstuttgart.syntaxtree.Method; +import de.dhbwstuttgart.syntaxtree.ObjectClass; import de.dhbwstuttgart.syntaxtree.ParameterList; import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; @@ -67,7 +68,7 @@ public class ASTFactory { } public static Class createObjectClass() { - Class generatedClass = new Class("java.lang.Object", 0); + Class generatedClass = new ObjectClass(); return generatedClass; } diff --git a/test/bytecode/main/Id.jav b/test/bytecode/main/Id.jav new file mode 100644 index 00000000..ed295176 --- /dev/null +++ b/test/bytecode/main/Id.jav @@ -0,0 +1,7 @@ +class Id{ + +public static void main(String[] args){} + +op = (x)->x; + +} \ No newline at end of file diff --git a/test/bytecode/main/LambdaExprTest.java b/test/bytecode/main/LambdaExprTest.java new file mode 100644 index 00000000..1e671db9 --- /dev/null +++ b/test/bytecode/main/LambdaExprTest.java @@ -0,0 +1,44 @@ +package bytecode.main; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; + +import org.junit.Test; + +import bytecode.SourceFileBytecodeTest; +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 LambdaExprTest extends SourceFileBytecodeTest{ + @Override + protected void init() { + testName = "Id"; + rootDirectory = System.getProperty("user.dir")+"/test/bytecode/main/"; + } + + @Test + public void testConstruct() throws Exception{ + ClassLoader classLoader = getClassLoader(); + + Class cls = classLoader.loadClass(testName); + + //Invoke main method: + cls.getMethod("main", String[].class).invoke(this, new String[0]); + + //Object obj = cls.newInstance(); + + assertTrue(true); + } +} \ No newline at end of file diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest30.jav b/test/plugindevelopment/TypeInsertTests/LambdaTest30.jav new file mode 100644 index 00000000..af0a6baf --- /dev/null +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest30.jav @@ -0,0 +1,13 @@ +class LambdaTest30{ + + java.lang.String methode(x){ + return x; + } + + lambdaGen(){ + Fun0 op; + op = () -> this.methode("Hallo Welt"); + return op; + } + +} \ No newline at end of file diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest30.java b/test/plugindevelopment/TypeInsertTests/LambdaTest30.java new file mode 100644 index 00000000..dcf2b683 --- /dev/null +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest30.java @@ -0,0 +1,18 @@ +package plugindevelopment.TypeInsertTests; + +import de.dhbwstuttgart.typeinference.Menge; + +import org.junit.Test; + +public class LambdaTest30 { + + private static final String TEST_FILE = "LambdaTest30.jav"; + + @Test + public void run(){ + Menge mustContain = new Menge(); + //mustContain.add("A a"); + MultipleTypesInsertTester.test(this.TEST_FILE, mustContain); + } + +}