forked from JavaTX/JavaCompilerCore
modified: ../src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java
modified: ../src/main/java/de/dhbwstuttgart/typeinference/constraints/Constraint.java modified: ../src/test/java/bytecode/InheritTest.java new file: ../src/test/resources/bytecode/javFiles/AA.jav new file: ../src/test/resources/bytecode/javFiles/BB.jav new file: ../src/test/resources/bytecode/javFiles/CC.jav new file: ../src/test/resources/bytecode/javFiles/DD.jav modified: ../src/test/resources/bytecode/javFiles/Inherit.jav Inherit funktioniert noch nicht ganz
This commit is contained in:
parent
ccf5df1f1e
commit
ba750187ba
@ -177,6 +177,7 @@ public class JavaTXCompiler {
|
|||||||
gtvs.put(tvarVarIt.next().getName(), paraIt.next());
|
gtvs.put(tvarVarIt.next().getName(), paraIt.next());
|
||||||
}
|
}
|
||||||
Iterator<Method> methodIt = superclass.getMethods().iterator();
|
Iterator<Method> methodIt = superclass.getMethods().iterator();
|
||||||
|
//TODO: PL 2020-05-06: Hier müssen ueberschriebene Methoden noch rausgefiltert werden
|
||||||
while(methodIt.hasNext()) {
|
while(methodIt.hasNext()) {
|
||||||
Method m = methodIt.next();
|
Method m = methodIt.next();
|
||||||
ParameterList newParaList = new ParameterList(
|
ParameterList newParaList = new ParameterList(
|
||||||
@ -975,7 +976,7 @@ public class JavaTXCompiler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RefTypeOrTPHOrWildcardOrGeneric visit(TypePlaceholder typePlaceholder) {
|
public RefTypeOrTPHOrWildcardOrGeneric visit(TypePlaceholder typePlaceholder) {
|
||||||
throw new DebugException("Dieser Fall darf nicht auftreten");
|
return typePlaceholder; //TypePlaceholder der vererbert wird kann bei der Vererbung nicht instanziert werden.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,8 +41,9 @@ public class Constraint<A> extends HashSet<A> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + " isInherited = " + isInherited + "\nextendsContraint: " +
|
return super.toString() + " isInherited = " + isInherited
|
||||||
(extendConstraint != null ? extendConstraint.toStringBase() : "null" ) + "\n" ;
|
//" + extendsContraint: " + (extendConstraint != null ? extendConstraint.toStringBase() : "null" )
|
||||||
|
+ "\n" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toStringBase() {
|
public String toStringBase() {
|
||||||
|
@ -31,18 +31,59 @@ public class InheritTest {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/Inherit.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/AA.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/";
|
||||||
List<ResultSet> typeinferenceResult = compiler.typeInference();
|
List<ResultSet> typeinferenceResult = compiler.typeInference();
|
||||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(typeinferenceResult);
|
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(typeinferenceResult);
|
||||||
compiler.generateBytecode(new File(pathToClassFile),typeinferenceResult,simplifyResultsForAllSourceFiles);
|
compiler.generateBytecode(new File(pathToClassFile),typeinferenceResult,simplifyResultsForAllSourceFiles);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest1 = loader.loadClass("AA");
|
||||||
|
instanceOfClass1 = classToTest1.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/BB.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/";
|
||||||
|
typeinferenceResult = compiler.typeInference();
|
||||||
|
simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(typeinferenceResult);
|
||||||
|
compiler.generateBytecode(new File(pathToClassFile),typeinferenceResult,simplifyResultsForAllSourceFiles);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest1 = loader.loadClass("AA");
|
||||||
|
instanceOfClass1 = classToTest1.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/CC.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/";
|
||||||
|
typeinferenceResult = compiler.typeInference();
|
||||||
|
simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(typeinferenceResult);
|
||||||
|
compiler.generateBytecode(new File(pathToClassFile),typeinferenceResult,simplifyResultsForAllSourceFiles);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest1 = loader.loadClass("AA");
|
||||||
|
instanceOfClass1 = classToTest1.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/DD.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/";
|
||||||
|
typeinferenceResult = compiler.typeInference();
|
||||||
|
simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(typeinferenceResult);
|
||||||
|
compiler.generateBytecode(new File(pathToClassFile),typeinferenceResult,simplifyResultsForAllSourceFiles);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest1 = loader.loadClass("AA");
|
||||||
|
instanceOfClass1 = classToTest1.getDeclaredConstructor().newInstance();
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/Inherit.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
typeinferenceResult = compiler.typeInference();
|
||||||
|
simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(typeinferenceResult);
|
||||||
|
compiler.generateBytecode(new File(pathToClassFile),typeinferenceResult,simplifyResultsForAllSourceFiles);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
classToTest = loader.loadClass("Inherit");
|
classToTest = loader.loadClass("Inherit");
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
classToTest1 = loader.loadClass("A");
|
|
||||||
instanceOfClass1 = classToTest1.getDeclaredConstructor().newInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -52,7 +93,7 @@ public class InheritTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAName() {
|
public void testAName() {
|
||||||
assertEquals("A", classToTest1.getName());
|
assertEquals("AA", classToTest1.getName());
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@Test
|
@Test
|
||||||
|
5
src/test/resources/bytecode/javFiles/AA.jav
Normal file
5
src/test/resources/bytecode/javFiles/AA.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
public class AA {
|
||||||
|
m(Integer i) { }
|
||||||
|
}
|
3
src/test/resources/bytecode/javFiles/BB.jav
Normal file
3
src/test/resources/bytecode/javFiles/BB.jav
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
public class BB extends AA { }
|
7
src/test/resources/bytecode/javFiles/CC.jav
Normal file
7
src/test/resources/bytecode/javFiles/CC.jav
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class CC extends BB {
|
||||||
|
m(Integer i) { }
|
||||||
|
}
|
4
src/test/resources/bytecode/javFiles/DD.jav
Normal file
4
src/test/resources/bytecode/javFiles/DD.jav
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
public class DD extends CC { }
|
||||||
|
|
@ -1,29 +1,17 @@
|
|||||||
import java.lang.Integer;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public class A {
|
import java.lang.Integer;
|
||||||
m(Integer i) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class B extends A { }
|
|
||||||
|
|
||||||
public class C extends B {
|
|
||||||
m(Integer i) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class D extends C { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class Inherit {
|
public class Inherit {
|
||||||
/*
|
|
||||||
main(d, i) {
|
main(d, i) {
|
||||||
d.m(1);
|
d.m(i);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
main(v, i) {
|
main(v, i) {
|
||||||
var aa = v.elementAt(0);
|
var aa = v.elementAt(0);
|
||||||
aa.m(1);
|
aa.m(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user