Merge branch 'bytecode2' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into plugin

This commit is contained in:
Martin Plümicke 2018-06-20 20:06:37 +02:00
commit a92521f04a
24 changed files with 145 additions and 77 deletions

View File

@ -30,6 +30,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
import de.dhbwstuttgart.typeinference.result.ResolvedType;
import de.dhbwstuttgart.typeinference.result.ResultPair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -43,6 +44,9 @@ public class BytecodeGen implements ASTVisitor {
private boolean isInterface;
private List<ResultSet> listOfResultSets;
private ResultSet resultSet;
private String path;
private int indexOfFirstParam = 0;
private String superClass;
@ -54,8 +58,8 @@ public class BytecodeGen implements ASTVisitor {
// stores generics and their bounds of method
HashMap<String, String> genericsAndBoundsMethod = new HashMap<>();
private final TPHExtractor tphExtractor = new TPHExtractor();
private final ArrayList<GenericInsertPair> commonPairs = new ArrayList<>();
private ArrayList<MethodAndTPH> ListOfMethodsAndTph = new ArrayList<>();
HashMap<String,RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes = new HashMap<>();
byte[] bytecode;
@ -63,16 +67,17 @@ public class BytecodeGen implements ASTVisitor {
ArrayList<String> methodNameAndParamsT = new ArrayList<>();
public BytecodeGen(HashMap<String,byte[]> classFiles, List<ResultSet> listOfResultSets) {
public BytecodeGen(HashMap<String,byte[]> classFiles, List<ResultSet> listOfResultSets, String path) {
this.classFiles = classFiles;
this.listOfResultSets = listOfResultSets;
this.path = path;
}
@Override
public void visit(SourceFile sourceFile) {
for(ClassOrInterface cl : sourceFile.getClasses()) {
System.out.println("in Class: " + cl.getClassName().toString());
BytecodeGen classGen = new BytecodeGen(classFiles, listOfResultSets);
BytecodeGen classGen = new BytecodeGen(classFiles, listOfResultSets,path);
cl.accept(classGen);
classGen.writeClass(cl.getClassName().toString());
}
@ -115,11 +120,10 @@ public class BytecodeGen implements ASTVisitor {
resultSet = rs;
// Nur einmal ausführen!!
if(!isVisited) {
TPHExtractor tphExtractor = new TPHExtractor();
classOrInterface.accept(tphExtractor);
getCommonTPHS(tphExtractor);
ListOfMethodsAndTph = tphExtractor.ListOfMethodsAndTph;
String sig = null;
/* if class has generics then creates signature
* Signature looks like:
@ -164,26 +168,6 @@ public class BytecodeGen implements ASTVisitor {
if(!tphExtractor.allTPHS.get(tph))
cTPHs.add(tph);
}
ArrayList<MethodAndTPH> tphsMethod = tphExtractor.ListOfMethodsAndTph;
// Für jede Methode speichere die gemeinsame TPHs:
// -> Für jedes Pair prüfe ob, auf der rechten Seite ein TPH steht, der
// in der Liste der TPHs der Methode enthalten ist.
// Wenn ja -> gemeinsamer TPH
for(MethodAndTPH m:tphsMethod){
for(GenericInsertPair p : m.getPairs()){
if(!m.getTphs().contains(p.TA2))
cTPHs.add(p.TA2);
}
}
for(TypePlaceholder tph : cTPHs) {
for(GenericInsertPair p : tphExtractor.allPairs) {
if(p.contains(tph))
commonPairs.add(p);
}
}
}
@Override
@ -210,7 +194,7 @@ public class BytecodeGen implements ASTVisitor {
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", desc, sig, null);
mv.visitCode();
BytecodeGenMethod gen = new BytecodeGenMethod(className,superClass,resultSet,field, mv,paramsAndLocals,cw,
genericsAndBoundsMethod,genericsAndBounds,isInterface,classFiles);
genericsAndBoundsMethod,genericsAndBounds,isInterface,classFiles, path);
if(!field.getParameterList().iterator().hasNext()) {
mv.visitInsn(Opcodes.RETURN);
}
@ -268,14 +252,10 @@ public class BytecodeGen implements ASTVisitor {
/* if method has generics or return type is TPH, create signature */
// zwite operand muss weggelassen werden
if(hasGen||method.getReturnType().acceptTV(new TypeToString()).equals("TPH")) {
ArrayList<GenericInsertPair> pairs = new ArrayList<>();
for(MethodAndTPH m : ListOfMethodsAndTph) {
if(m.getName().equals(method.name)) {
pairs = m.getPairs();
break;
}
}
ArrayList<GenericInsertPair> pairs = simplifyPairs(method.name,tphExtractor.allPairs);
System.out.println(method.name + " => Simplified Pairs: ");
pairs.forEach(p->System.out.println(p.TA1.getName() + " -> "+p.TA2.getName()));
Signature signature = new Signature(method, genericsAndBoundsMethod, genericsAndBounds,methodParamsAndTypes,resultSet, pairs);
sig = signature.toString();
}
@ -288,12 +268,78 @@ public class BytecodeGen implements ASTVisitor {
mv.visitCode();
BytecodeGenMethod gen = new BytecodeGenMethod(className,superClass,resultSet,method, mv,paramsAndLocals,cw,
genericsAndBoundsMethod,genericsAndBounds,isInterface,classFiles);
genericsAndBoundsMethod,genericsAndBounds,isInterface,classFiles, path);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
private ArrayList<GenericInsertPair> simplifyPairs(String methodName, ArrayList<GenericInsertPair> allPairs) {
ArrayList<GenericInsertPair> simplifiedPairs = new ArrayList<>();
MethodAndTPH method;
ArrayList<TypePlaceholder> methodTphs = new ArrayList<>();
ArrayList<GenericInsertPair> methodPairs = new ArrayList<>();
for(MethodAndTPH m : tphExtractor.ListOfMethodsAndTph) {
if(m.getName().equals(methodName)) {
methodTphs = m.getTphs();
methodPairs = m.getPairs();
break;
}
}
HashMap<TypePlaceholder, TypePlaceholder> subAndSuperTph = new HashMap<>();
for(GenericInsertPair p : allPairs) {
// Tph2.jav
if(subAndSuperTph.containsKey(p.TA1)) {
if(methodTphs.contains(subAndSuperTph.get(p.TA1)))
continue;
}
subAndSuperTph.put(p.TA1, p.TA2);
}
int numOfVisitedPairs = 0;
for(TypePlaceholder subTph: subAndSuperTph.keySet()) {
if(numOfVisitedPairs>=subAndSuperTph.size())
break;
if(!methodTphs.contains(subTph))
continue;
HashMap<Integer, TypePlaceholder> tphsInRel= new HashMap<>();
tphsInRel.put(tphsInRel.size(), subTph);
TypePlaceholder superTph = subAndSuperTph.get(subTph);
tphsInRel.put(tphsInRel.size(), superTph);
numOfVisitedPairs++;
while(subAndSuperTph.containsKey(superTph)) {
superTph = subAndSuperTph.get(superTph);
tphsInRel.put(tphsInRel.size(), superTph);
numOfVisitedPairs++;
}
// TODO: teste noch den Fall X < Y und Y nicht in TPHS der Methode
// Dann hat man nach der While-Schleife X < Y
// Y muss durch Object ersetzt.
// Subtype
TypePlaceholder subTphRes = tphsInRel.get(0);
// Die größte Supertype
TypePlaceholder superTphRes = tphsInRel.get(tphsInRel.size()-1);
int i = 2;
while(!methodTphs.contains(superTphRes) && (tphsInRel.size()-i) >0) {
superTphRes = tphsInRel.get(tphsInRel.size()-i);
i++;
}
GenericInsertPair sPair = new GenericInsertPair(subTphRes, superTphRes);
simplifiedPairs.add(sPair);
}
return simplifiedPairs;
}
@Override
public void visit(ParameterList formalParameters) {
paramsAndLocals = new HashMap<>();
@ -553,6 +599,7 @@ public class BytecodeGen implements ASTVisitor {
methodAndTph.getTphs().add(resolvedTPH);
allTPHS.put(resolvedTPH,inMethod);
ResolvedType rst = resultSet.resolveType(tph);
resultSet.resolveType(tph).additionalGenerics.forEach(ag ->{
if(ag.contains(resolvedTPH)&&ag.TA1.equals(resolvedTPH)&&!contains(allPairs,ag)) {
if(inMethod)

View File

@ -57,7 +57,7 @@ public class BytecodeGenMethod implements StatementVisitor {
private HashMap<String, String> genericsAndBounds;
private boolean isBinaryExp = false;
private String superClass;
private String path;
private IStatement statement = null;
// for tests **
@ -73,7 +73,7 @@ public class BytecodeGenMethod implements StatementVisitor {
public BytecodeGenMethod(String className, String superClass,ResultSet resultSet, Method m, MethodVisitor mv,
HashMap<String, Integer> paramsAndLocals, ClassWriter cw, HashMap<String, String> genericsAndBoundsMethod,
HashMap<String, String> genericsAndBounds, boolean isInterface, HashMap<String, byte[]> classFiles) {
HashMap<String, String> genericsAndBounds, boolean isInterface, HashMap<String, byte[]> classFiles, String path) {
this.className = className;
this.superClass = superClass;
@ -86,19 +86,21 @@ public class BytecodeGenMethod implements StatementVisitor {
this.genericsAndBounds = genericsAndBounds;
this.isInterface = isInterface;
this.classFiles = classFiles;
this.path = path;
if (!isInterface)
this.m.block.accept(this);
}
public BytecodeGenMethod(LambdaExpression lambdaExpression, ResultSet resultSet, MethodVisitor mv,
int indexOfFirstParamLam, boolean isInterface, HashMap<String, byte[]> classFiles) {
int indexOfFirstParamLam, boolean isInterface, HashMap<String, byte[]> classFiles, String path) {
this.resultSet = resultSet;
this.mv = mv;
this.isInterface = isInterface;
this.classFiles = classFiles;
this.path = path;
Iterator<FormalParameter> itr = lambdaExpression.params.iterator();
int i = indexOfFirstParamLam;
@ -534,7 +536,7 @@ public class BytecodeGenMethod implements StatementVisitor {
methodName, arg3.toString(), null, null);
new BytecodeGenMethod(lambdaExpression, this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
classFiles);
classFiles,this.path);
mvLambdaBody.visitMaxs(0, 0);
mvLambdaBody.visitEnd();
@ -575,7 +577,7 @@ public class BytecodeGenMethod implements StatementVisitor {
try {
System.out.println("generating " + name + ".class file...");
output = new FileOutputStream(
new File(System.getProperty("user.dir") + "/testBytecode/generatedBC/" + name + ".class"));
new File(path + name + ".class"));
output.write(bytecode);
output.close();
System.out.println(name + ".class file generated");
@ -636,6 +638,8 @@ public class BytecodeGenMethod implements StatementVisitor {
@Override
public void visit(MethodCall methodCall) {
//ClassLoader.getSystemClassLoader().loadClass(className).getMethod(name, parameterTypes)
System.out.println("Methodcall type : " + resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()));
methodCall.receiver.accept(this);
methodCall.arglist.accept(this);

View File

@ -147,16 +147,33 @@ public class Signature {
}
}
// methodPairs.forEach(p->{
// String name = p.TA2.getName() + "$";
// if(!genericsAndBoundsMethod.containsKey(name)) {
// sw.visitFormalTypeParameter(name);
// String bound = Type.getInternalName(Object.class);
// sw.visitClassBound().visitClassType(bound);
// sw.visitClassBound().visitEnd();
// genericsAndBoundsMethod.put(name, bound);
// }
// });
for(GenericInsertPair p:methodPairs) {
String name = p.TA1.getName()+"$";
if(!genericsAndBoundsMethod.containsKey(name)) {
sw.visitFormalTypeParameter(name);
sw.visitClassBound().visitTypeVariable(p.TA2.getName()+"$");
genericsAndBoundsMethod.put(name, p.TA2.getName()+"$");
}
}
ArrayList<TypePlaceholder> types = new ArrayList<>();
ArrayList<TypePlaceholder> superTypes = new ArrayList<>();
for(GenericInsertPair p : methodPairs) {
types.add(p.TA1);
superTypes.add(p.TA2);
}
for(GenericInsertPair p : methodPairs) {
String name = p.TA2.getName()+"$";
if(!types.contains(p.TA2) && !genericsAndBoundsMethod.containsKey(name)) {
String bound = Type.getInternalName(Object.class);
sw.visitFormalTypeParameter(name);
sw.visitClassBound().visitClassType(bound);
genericsAndBoundsMethod.put(name, bound);
sw.visitClassBound().visitEnd();
}
}
}
// visit each method-parameter to create the signature

View File

@ -229,25 +229,26 @@ public class JavaTXCompiler {
SourceFile ret = generator.convert(tree, environment.packageCrawler);
return ret;
}
public void generateBytecode() throws ClassNotFoundException, IOException {
// um pfad erweitern
public void generateBytecode(String path) throws ClassNotFoundException, IOException {
for(File f : sourceFiles.keySet()) {
HashMap<String,byte[]> classFiles = new HashMap<>();
SourceFile sf = sourceFiles.get(f);
List<ResultSet> typeinferenceResult = this.typeInference();
BytecodeGen bytecodeGen = new BytecodeGen(classFiles,typeinferenceResult);
BytecodeGen bytecodeGen = new BytecodeGen(classFiles,typeinferenceResult,path);
// BytecodeGen bytecodeGen = new BytecodeGen(classFiles,typeinferenceResult.get(0));
bytecodeGen.visit(sf);
this.writeClassFile(bytecodeGen.getClassFiles());
this.writeClassFile(bytecodeGen.getClassFiles(), path);
}
}
private void writeClassFile(HashMap<String, byte[]> classFiles) throws IOException {
private void writeClassFile(HashMap<String, byte[]> classFiles, String path) throws IOException {
FileOutputStream output;
for(String name : classFiles.keySet()) {
byte[] bytecode = classFiles.get(name);
System.out.println("generating "+name+ ".class file ...");
output = new FileOutputStream(new File(System.getProperty("user.dir") + "/testBytecode/generatedBC/" +name+".class"));
//output = new FileOutputStream(new File(System.getProperty("user.dir") + "/testBytecode/generatedBC/" +name+".class"));
output = new FileOutputStream(new File(path +name+".class"));
output.write(bytecode);
output.close();
System.out.println(name+".class file generated");

View File

@ -25,8 +25,8 @@ public class BinaryTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/BinaryInMeth.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("BinaryInMeth");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -27,8 +27,8 @@ public class FacTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Fac.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Fac");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -26,8 +26,8 @@ public class GenTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Gen.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Gen");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -28,8 +28,8 @@ public class GreaterEqualTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/GreaterEqual.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("File://"+pathToClassFile)});
classToTest = loader.loadClass("GreaterEqual");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -28,8 +28,8 @@ public class GreaterThanTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/GreaterThan.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("File://"+pathToClassFile)});
classToTest = loader.loadClass("GreaterThan");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -16,7 +16,7 @@ public class LambdaTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Lambda.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/");
}

View File

@ -28,8 +28,8 @@ public class LessEqualTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/LessEqual.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("LessEqual");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -28,8 +28,8 @@ public class LessThanTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/LessThan.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("LessThan");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -25,8 +25,8 @@ public class MatrixTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Matrix.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Matrix");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -25,8 +25,8 @@ public class OLTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/OL.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("OL");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -28,8 +28,8 @@ public class OpTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Op.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Op");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -30,8 +30,8 @@ public class OverloadingTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Overloading.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Overloading");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -27,9 +27,8 @@ public class PlusTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Plus.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Plus");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -27,8 +27,8 @@ public class PostIncTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/PostIncDec.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("PostIncDec");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -27,8 +27,8 @@ public class PreIncTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/PreInc.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://" + pathToClassFile)});
classToTest = loader.loadClass("PreInc");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -27,8 +27,8 @@ public class RelOpsTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/RelOps.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("RelOps");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -26,8 +26,8 @@ public class StaticTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/StaticM.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://" + pathToClassFile)});
classToTest = loader.loadClass("StaticM");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -26,8 +26,8 @@ public class Tph2Test {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Tph2.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Tph2");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -25,8 +25,8 @@ public class TphTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Tph.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Tph");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();

View File

@ -27,8 +27,8 @@ public class WhileTest {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/While.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode();
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("While");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();