diff --git a/src/de/dhbwstuttgart/bytecode/BytecodeGen.java b/src/de/dhbwstuttgart/bytecode/BytecodeGen.java index 5115a29bd..0dd573749 100644 --- a/src/de/dhbwstuttgart/bytecode/BytecodeGen.java +++ b/src/de/dhbwstuttgart/bytecode/BytecodeGen.java @@ -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 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 genericsAndBoundsMethod = new HashMap<>(); + private final TPHExtractor tphExtractor = new TPHExtractor(); private final ArrayList commonPairs = new ArrayList<>(); - private ArrayList ListOfMethodsAndTph = new ArrayList<>(); HashMap methodParamsAndTypes = new HashMap<>(); byte[] bytecode; @@ -63,16 +67,17 @@ public class BytecodeGen implements ASTVisitor { ArrayList methodNameAndParamsT = new ArrayList<>(); - public BytecodeGen(HashMap classFiles, List listOfResultSets) { + public BytecodeGen(HashMap classFiles, List 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 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, "", 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 pairs = new ArrayList<>(); - for(MethodAndTPH m : ListOfMethodsAndTph) { - if(m.getName().equals(method.name)) { - pairs = m.getPairs(); - break; - } - } + ArrayList 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 simplifyPairs(String methodName, ArrayList allPairs) { + ArrayList simplifiedPairs = new ArrayList<>(); + + MethodAndTPH method; + ArrayList methodTphs = new ArrayList<>(); + ArrayList methodPairs = new ArrayList<>(); + for(MethodAndTPH m : tphExtractor.ListOfMethodsAndTph) { + if(m.getName().equals(methodName)) { + methodTphs = m.getTphs(); + methodPairs = m.getPairs(); + break; + } + } + + HashMap 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 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) diff --git a/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java b/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java index edec62e71..9d03979fc 100644 --- a/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java +++ b/src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java @@ -57,7 +57,7 @@ public class BytecodeGenMethod implements StatementVisitor { private HashMap 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 paramsAndLocals, ClassWriter cw, HashMap genericsAndBoundsMethod, - HashMap genericsAndBounds, boolean isInterface, HashMap classFiles) { + HashMap genericsAndBounds, boolean isInterface, HashMap 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 classFiles) { + int indexOfFirstParamLam, boolean isInterface, HashMap classFiles, String path) { this.resultSet = resultSet; this.mv = mv; this.isInterface = isInterface; this.classFiles = classFiles; + this.path = path; Iterator 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); diff --git a/src/de/dhbwstuttgart/bytecode/signature/Signature.java b/src/de/dhbwstuttgart/bytecode/signature/Signature.java index 51329a55f..7b222770c 100644 --- a/src/de/dhbwstuttgart/bytecode/signature/Signature.java +++ b/src/de/dhbwstuttgart/bytecode/signature/Signature.java @@ -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 types = new ArrayList<>(); + ArrayList 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 diff --git a/src/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/de/dhbwstuttgart/core/JavaTXCompiler.java index dfa89b40a..12845234b 100644 --- a/src/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -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 classFiles = new HashMap<>(); SourceFile sf = sourceFiles.get(f); List 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 classFiles) throws IOException { + private void writeClassFile(HashMap 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"); diff --git a/test/bytecode/BinaryTest.java b/test/bytecode/BinaryTest.java index 7f2f5fa41..07a70d541 100644 --- a/test/bytecode/BinaryTest.java +++ b/test/bytecode/BinaryTest.java @@ -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(); diff --git a/test/bytecode/FacTest.java b/test/bytecode/FacTest.java index c4cab24e5..f5dd86ea9 100644 --- a/test/bytecode/FacTest.java +++ b/test/bytecode/FacTest.java @@ -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(); diff --git a/test/bytecode/GenTest.java b/test/bytecode/GenTest.java index d0067d084..e8ca6938e 100644 --- a/test/bytecode/GenTest.java +++ b/test/bytecode/GenTest.java @@ -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(); diff --git a/test/bytecode/GreaterEqualTest.java b/test/bytecode/GreaterEqualTest.java index c65a40153..b60c446c5 100644 --- a/test/bytecode/GreaterEqualTest.java +++ b/test/bytecode/GreaterEqualTest.java @@ -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(); diff --git a/test/bytecode/GreaterThanTest.java b/test/bytecode/GreaterThanTest.java index 8ab07ff14..1a460a8cb 100644 --- a/test/bytecode/GreaterThanTest.java +++ b/test/bytecode/GreaterThanTest.java @@ -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(); diff --git a/test/bytecode/LambdaTest.java b/test/bytecode/LambdaTest.java index f29690cb2..72d21f548 100644 --- a/test/bytecode/LambdaTest.java +++ b/test/bytecode/LambdaTest.java @@ -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/"); } diff --git a/test/bytecode/LessEqualTest.java b/test/bytecode/LessEqualTest.java index de9cdb8c0..dc439af9c 100644 --- a/test/bytecode/LessEqualTest.java +++ b/test/bytecode/LessEqualTest.java @@ -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(); diff --git a/test/bytecode/LessThanTest.java b/test/bytecode/LessThanTest.java index 6846f8205..99eba80c8 100644 --- a/test/bytecode/LessThanTest.java +++ b/test/bytecode/LessThanTest.java @@ -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(); diff --git a/test/bytecode/MatrixTest.java b/test/bytecode/MatrixTest.java index 988841516..db8dc8aba 100644 --- a/test/bytecode/MatrixTest.java +++ b/test/bytecode/MatrixTest.java @@ -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(); diff --git a/test/bytecode/OLTest.java b/test/bytecode/OLTest.java index ff91073e1..288e580f2 100644 --- a/test/bytecode/OLTest.java +++ b/test/bytecode/OLTest.java @@ -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(); diff --git a/test/bytecode/OpTest.java b/test/bytecode/OpTest.java index 1d213a781..3909f0cd8 100644 --- a/test/bytecode/OpTest.java +++ b/test/bytecode/OpTest.java @@ -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(); diff --git a/test/bytecode/OverloadingTest.java b/test/bytecode/OverloadingTest.java index 294bf533d..6b4bf8eb2 100644 --- a/test/bytecode/OverloadingTest.java +++ b/test/bytecode/OverloadingTest.java @@ -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(); diff --git a/test/bytecode/PlusTest.java b/test/bytecode/PlusTest.java index 51503c58c..85f05b752 100644 --- a/test/bytecode/PlusTest.java +++ b/test/bytecode/PlusTest.java @@ -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(); diff --git a/test/bytecode/PostIncTest.java b/test/bytecode/PostIncTest.java index 36e638169..6c3ebc330 100644 --- a/test/bytecode/PostIncTest.java +++ b/test/bytecode/PostIncTest.java @@ -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(); diff --git a/test/bytecode/PreIncTest.java b/test/bytecode/PreIncTest.java index 434b88e13..29feac338 100644 --- a/test/bytecode/PreIncTest.java +++ b/test/bytecode/PreIncTest.java @@ -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(); diff --git a/test/bytecode/RelOpsTest.java b/test/bytecode/RelOpsTest.java index 06b246305..1bdf1a1d3 100644 --- a/test/bytecode/RelOpsTest.java +++ b/test/bytecode/RelOpsTest.java @@ -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(); diff --git a/test/bytecode/StaticTest.java b/test/bytecode/StaticTest.java index f639645cf..98642b4e2 100644 --- a/test/bytecode/StaticTest.java +++ b/test/bytecode/StaticTest.java @@ -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(); diff --git a/test/bytecode/Tph2Test.java b/test/bytecode/Tph2Test.java index 4cda41484..de7064314 100644 --- a/test/bytecode/Tph2Test.java +++ b/test/bytecode/Tph2Test.java @@ -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(); diff --git a/test/bytecode/TphTest.java b/test/bytecode/TphTest.java index 449db765d..92b786cec 100644 --- a/test/bytecode/TphTest.java +++ b/test/bytecode/TphTest.java @@ -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(); diff --git a/test/bytecode/WhileTest.java b/test/bytecode/WhileTest.java index 5690facb4..b3020ffe9 100644 --- a/test/bytecode/WhileTest.java +++ b/test/bytecode/WhileTest.java @@ -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();