Merge branch 'addPackages' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into addPackages
This commit is contained in:
commit
7fd03d505e
3
.gitignore
vendored
3
.gitignore
vendored
@ -23,3 +23,6 @@ bin
|
|||||||
|
|
||||||
#
|
#
|
||||||
manually/
|
manually/
|
||||||
|
|
||||||
|
logFiles/**
|
||||||
|
!logFiles/.gitkeep
|
||||||
|
19
abgabeprotokoll.md
Normal file
19
abgabeprotokoll.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# JavaTXCompiler Klasse
|
||||||
|
* Konstruktor hat einen weiteren Parameter
|
||||||
|
* contextPath
|
||||||
|
* Arrays aus URLs (file-urls)
|
||||||
|
* Parameter ist Optional
|
||||||
|
* wird er gesetzt, so werden Classfiles aus den übergebenen Pfaden geladen
|
||||||
|
* die übergebenen Pfade müssen dabei die Source-Roots sein
|
||||||
|
* Beispiel:
|
||||||
|
`import de.test.Klasse;`
|
||||||
|
* `Klasse.class` liegt in `output/de/test/Klasse.class`
|
||||||
|
* dann muss contextpath auf `output` gesetzt werden
|
||||||
|
* wird der Parameter nicht übergeben, so wird der Sourceroot auf das Verzeichnis gesetzt, in dem der Compiler ausgeführt wird
|
||||||
|
* dies ist das Verhalten vom javac Compiler
|
||||||
|
|
||||||
|
* generateBytecode - Methode hat neuen Parameter: path
|
||||||
|
* wird hier null übergeben, so wird die class-File in den gleichen Ordner wie die übergebene .jav File geschrieben
|
||||||
|
* wird hier ein Pfad übergeben, so gilt dieser als output root.
|
||||||
|
* Klassen werden in outputRoot/package/name/KlassenName.class geschrieben
|
||||||
|
|
0
logFiles/.gitkeep
Normal file
0
logFiles/.gitkeep
Normal file
@ -7,6 +7,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.FieldVisitor;
|
import org.objectweb.asm.FieldVisitor;
|
||||||
import org.objectweb.asm.MethodVisitor;
|
import org.objectweb.asm.MethodVisitor;
|
||||||
@ -81,7 +82,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
String type;
|
String type;
|
||||||
|
|
||||||
public static RefTypeOrTPHOrWildcardOrGeneric THISTYPE = null;
|
public static RefTypeOrTPHOrWildcardOrGeneric THISTYPE = null;
|
||||||
private String className;
|
private JavaClassName className;
|
||||||
private String pkgName;
|
private String pkgName;
|
||||||
private boolean isInterface;
|
private boolean isInterface;
|
||||||
private Collection<ResultSet> listOfResultSets;
|
private Collection<ResultSet> listOfResultSets;
|
||||||
@ -107,7 +108,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
|
|
||||||
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes = new HashMap<>();
|
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes = new HashMap<>();
|
||||||
byte[] bytecode;
|
byte[] bytecode;
|
||||||
HashMap<String, byte[]> classFiles;
|
HashMap<JavaClassName, byte[]> classFiles;
|
||||||
|
|
||||||
private final ArrayList<String> methodNameAndParamsT = new ArrayList<>();
|
private final ArrayList<String> methodNameAndParamsT = new ArrayList<>();
|
||||||
private final ArrayList<String> fieldNameAndParamsT = new ArrayList<>();
|
private final ArrayList<String> fieldNameAndParamsT = new ArrayList<>();
|
||||||
@ -118,24 +119,26 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
private GenericsGeneratorResultForClass generatedGenerics;
|
private GenericsGeneratorResultForClass generatedGenerics;
|
||||||
|
|
||||||
private Resolver resolver;
|
private Resolver resolver;
|
||||||
|
private final ClassLoader classLoader;
|
||||||
|
|
||||||
public BytecodeGen(HashMap<String, byte[]> classFiles, Collection<ResultSet> listOfResultSets, List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles, SourceFile sf,
|
public BytecodeGen(HashMap<JavaClassName, byte[]> classFiles, Collection<ResultSet> listOfResultSets, List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles, SourceFile sf,
|
||||||
String path) {
|
String path, ClassLoader classLoader) {
|
||||||
this.classFiles = classFiles;
|
this.classFiles = classFiles;
|
||||||
this.listOfResultSets = listOfResultSets;
|
this.listOfResultSets = listOfResultSets;
|
||||||
this.simplifyResultsForAllSourceFiles = simplifyResultsForAllSourceFiles;
|
this.simplifyResultsForAllSourceFiles = simplifyResultsForAllSourceFiles;
|
||||||
this.sf = sf;
|
this.sf = sf;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.pkgName = sf.getPkgName();
|
this.pkgName = sf.getPkgName();
|
||||||
|
this.classLoader = classLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(SourceFile sourceFile) {
|
public void visit(SourceFile sourceFile) {
|
||||||
for (ClassOrInterface cl : sourceFile.getClasses()) {
|
for (ClassOrInterface cl : sourceFile.getClasses()) {
|
||||||
System.out.println("in Class: " + cl.getClassName().toString());
|
System.out.println("in Class: " + cl.getClassName().toString());
|
||||||
BytecodeGen classGen = new BytecodeGen(classFiles, listOfResultSets, simplifyResultsForAllSourceFiles, sf, path);
|
BytecodeGen classGen = new BytecodeGen(classFiles, listOfResultSets, simplifyResultsForAllSourceFiles, sf, path, classLoader);
|
||||||
cl.accept(classGen);
|
cl.accept(classGen);
|
||||||
classGen.writeClass(cl.getClassName().toString());
|
classGen.writeClass(cl.getClassName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,22 +148,22 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
*
|
*
|
||||||
* @param name name of the class with which the bytecode is to be associated
|
* @param name name of the class with which the bytecode is to be associated
|
||||||
*/
|
*/
|
||||||
private void writeClass(String name) {
|
private void writeClass(JavaClassName name) {
|
||||||
bytecode = cw.toByteArray();
|
bytecode = cw.toByteArray();
|
||||||
classFiles.put(name, bytecode);
|
classFiles.put(name, bytecode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, byte[]> getClassFiles() {
|
public HashMap<JavaClassName, byte[]> getClassFiles() {
|
||||||
return classFiles;
|
return classFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(ClassOrInterface classOrInterface) {
|
public void visit(ClassOrInterface classOrInterface) {
|
||||||
|
|
||||||
className = classOrInterface.getClassName().toString();
|
className = classOrInterface.getClassName();
|
||||||
|
|
||||||
cw.visitSource(className + ".jav", null);
|
cw.visitSource(className.getClassName() + ".jav", null);
|
||||||
|
|
||||||
isInterface = (classOrInterface.getModifiers() & 512) == 512;
|
isInterface = (classOrInterface.getModifiers() & 512) == 512;
|
||||||
|
|
||||||
@ -172,7 +175,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
// resultSet = listOfResultSets.get(0);
|
// resultSet = listOfResultSets.get(0);
|
||||||
boolean isVisited = false;
|
boolean isVisited = false;
|
||||||
List<ResultSet> listOfResultSetsList = new ArrayList<>(listOfResultSets);
|
List<ResultSet> listOfResultSetsList = new ArrayList<>(listOfResultSets);
|
||||||
generatedGenerics = simplifyResultsForAllSourceFiles.stream().map(sr->sr.getSimplifyResultsByName(pkgName, className)).findFirst().get();
|
generatedGenerics = simplifyResultsForAllSourceFiles.stream().map(sr->sr.getSimplifyResultsByName(className)).findFirst().get();
|
||||||
for (int i = 0; i < listOfResultSetsList.size(); i++) {
|
for (int i = 0; i < listOfResultSetsList.size(); i++) {
|
||||||
//for (ResultSet rs : listOfResultSets) {
|
//for (ResultSet rs : listOfResultSets) {
|
||||||
superClass = classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor());
|
superClass = classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor());
|
||||||
@ -199,7 +202,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
System.out.println("Signature: => " + sig);
|
System.out.println("Signature: => " + sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
cw.visit(Opcodes.V1_8, acc, classOrInterface.getClassName().toString(), sig,
|
cw.visit(Opcodes.V1_8, acc, classOrInterface.getClassName().toString().replace(".", "/"), sig,
|
||||||
classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor()), null);
|
classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor()), null);
|
||||||
|
|
||||||
isVisited = true;
|
isVisited = true;
|
||||||
@ -269,7 +272,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
constructorPos += 1;
|
constructorPos += 1;
|
||||||
|
|
||||||
BytecodeGenMethod gen = new BytecodeGenMethod(className, superClass, resultSet, field, mv, paramsAndLocals, cw,
|
BytecodeGenMethod gen = new BytecodeGenMethod(className, superClass, resultSet, field, mv, paramsAndLocals, cw,
|
||||||
genericsAndBoundsMethod, genericsAndBounds, isInterface, classFiles, sf, path, block, constructorPos);
|
genericsAndBoundsMethod, genericsAndBounds, isInterface, classFiles, sf, path, block, constructorPos, classLoader);
|
||||||
if (!field.getParameterList().iterator().hasNext()
|
if (!field.getParameterList().iterator().hasNext()
|
||||||
&& !(field.block.statements.get(field.block.statements.size() - 1) instanceof ReturnVoid)) {
|
&& !(field.block.statements.get(field.block.statements.size() - 1) instanceof ReturnVoid)) {
|
||||||
mv.visitInsn(Opcodes.RETURN);
|
mv.visitInsn(Opcodes.RETURN);
|
||||||
@ -350,7 +353,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
|
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
BytecodeGenMethod gen = new BytecodeGenMethod(className, superClass, resultSet, method, mv, paramsAndLocals, cw,
|
BytecodeGenMethod gen = new BytecodeGenMethod(className, superClass, resultSet, method, mv, paramsAndLocals, cw,
|
||||||
genericsAndBoundsMethod, genericsAndBounds, isInterface, classFiles, sf, path);
|
genericsAndBoundsMethod, genericsAndBounds, isInterface, classFiles, sf, path, classLoader);
|
||||||
|
|
||||||
mv.visitMaxs(0, 0);
|
mv.visitMaxs(0, 0);
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.utilities.*;
|
import de.dhbwstuttgart.bytecode.utilities.*;
|
||||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||||
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.*;
|
import de.dhbwstuttgart.syntaxtree.statement.*;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.BinaryExpr.Operator;
|
import de.dhbwstuttgart.syntaxtree.statement.BinaryExpr.Operator;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.UnaryExpr.Operation;
|
import de.dhbwstuttgart.syntaxtree.statement.UnaryExpr.Operation;
|
||||||
@ -45,7 +46,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
private Method m;
|
private Method m;
|
||||||
private MethodVisitor mv;
|
private MethodVisitor mv;
|
||||||
private HashMap<String, Integer> paramsAndLocals = new HashMap<>();
|
private HashMap<String, Integer> paramsAndLocals = new HashMap<>();
|
||||||
private String className;
|
private JavaClassName className;
|
||||||
private int lamCounter;
|
private int lamCounter;
|
||||||
private ClassWriter cw;
|
private ClassWriter cw;
|
||||||
private ResultSet resultSet;
|
private ResultSet resultSet;
|
||||||
@ -71,16 +72,18 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
|
|
||||||
private boolean isRightSideALambda = false;
|
private boolean isRightSideALambda = false;
|
||||||
private KindOfLambda kindOfLambda;
|
private KindOfLambda kindOfLambda;
|
||||||
private HashMap<String, byte[]> classFiles;
|
private HashMap<JavaClassName, byte[]> classFiles;
|
||||||
|
|
||||||
private int constructorPos = 0;
|
private int constructorPos = 0;
|
||||||
|
|
||||||
private ArrayList<RefTypeOrTPHOrWildcardOrGeneric> varsFunInterface = new ArrayList<>();;
|
private ArrayList<RefTypeOrTPHOrWildcardOrGeneric> varsFunInterface = new ArrayList<>();;
|
||||||
|
private final ClassLoader classLoader;
|
||||||
|
|
||||||
// generate bytecode for constructor
|
// generate bytecode for constructor
|
||||||
public BytecodeGenMethod(String className, String superClass,ResultSet resultSet, Method m, MethodVisitor mv,
|
public BytecodeGenMethod(JavaClassName className, String superClass, ResultSet resultSet, Method m, MethodVisitor mv,
|
||||||
HashMap<String, Integer> paramsAndLocals, ClassWriter cw, HashMap<String, String> genericsAndBoundsMethod,
|
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<JavaClassName, byte[]> classFiles,
|
||||||
SourceFile sf,String path, Block block, int constructorPos) {
|
SourceFile sf, String path, Block block, int constructorPos, ClassLoader classLoader) {
|
||||||
|
|
||||||
this.className = className;
|
this.className = className;
|
||||||
this.superClass = superClass;
|
this.superClass = superClass;
|
||||||
@ -98,16 +101,15 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
this.path = path;
|
this.path = path;
|
||||||
this.lamCounter = -1;
|
this.lamCounter = -1;
|
||||||
this.constructorPos = constructorPos;
|
this.constructorPos = constructorPos;
|
||||||
|
this.classLoader = classLoader;
|
||||||
if(block != null)
|
if(block != null)
|
||||||
this.blockFieldInit = block;
|
this.blockFieldInit = block;
|
||||||
this.m.block.accept(this);
|
this.m.block.accept(this);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BytecodeGenMethod(String className, String superClass,ResultSet resultSet, Method m, MethodVisitor mv,
|
public BytecodeGenMethod(JavaClassName className, String superClass,ResultSet resultSet, Method m, MethodVisitor mv,
|
||||||
HashMap<String, Integer> paramsAndLocals, ClassWriter cw, HashMap<String, String> genericsAndBoundsMethod,
|
HashMap<String, Integer> paramsAndLocals, ClassWriter cw, HashMap<String, String> genericsAndBoundsMethod,
|
||||||
HashMap<String, String> genericsAndBounds, boolean isInterface, HashMap<String, byte[]> classFiles, SourceFile sf,String path) {
|
HashMap<String, String> genericsAndBounds, boolean isInterface, HashMap<JavaClassName, byte[]> classFiles, SourceFile sf,String path, ClassLoader classLoader) {
|
||||||
|
|
||||||
this.className = className;
|
this.className = className;
|
||||||
this.superClass = superClass;
|
this.superClass = superClass;
|
||||||
@ -124,14 +126,14 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
this.sf = sf;
|
this.sf = sf;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.lamCounter = -1;
|
this.lamCounter = -1;
|
||||||
|
this.classLoader = classLoader;
|
||||||
if (!isInterface)
|
if (!isInterface)
|
||||||
this.m.block.accept(this);
|
this.m.block.accept(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BytecodeGenMethod(String className, ClassWriter cw, LambdaExpression lambdaExpression, ArrayList<String> usedVars, ResultSet resultSet, MethodVisitor mv,
|
public BytecodeGenMethod(JavaClassName className, ClassWriter cw, LambdaExpression lambdaExpression, ArrayList<String> usedVars, ResultSet resultSet, MethodVisitor mv,
|
||||||
int indexOfFirstParamLam, boolean isInterface, HashMap<String, byte[]> classFiles, String path, int lamCounter, SourceFile sf,HashMap<String, String> genericsAndBoundsMethod,
|
int indexOfFirstParamLam, boolean isInterface, HashMap<JavaClassName, byte[]> classFiles, String path, int lamCounter, SourceFile sf,HashMap<String, String> genericsAndBoundsMethod,
|
||||||
HashMap<String, String> genericsAndBounds) {
|
HashMap<String, String> genericsAndBounds, ClassLoader classLoader) {
|
||||||
this.className = className;
|
this.className = className;
|
||||||
this.cw = cw;
|
this.cw = cw;
|
||||||
this.resultSet = resultSet;
|
this.resultSet = resultSet;
|
||||||
@ -144,6 +146,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
this.sf = sf;
|
this.sf = sf;
|
||||||
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
|
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
|
||||||
this.genericsAndBounds = genericsAndBounds;
|
this.genericsAndBounds = genericsAndBounds;
|
||||||
|
this.classLoader = classLoader;
|
||||||
|
|
||||||
Iterator<FormalParameter> itr = lambdaExpression.params.iterator();
|
Iterator<FormalParameter> itr = lambdaExpression.params.iterator();
|
||||||
int i = indexOfFirstParamLam;
|
int i = indexOfFirstParamLam;
|
||||||
@ -622,7 +625,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
}
|
}
|
||||||
String newDesc = addUsedVarsToDesugaredMethodDescriptor(lamDesc);
|
String newDesc = addUsedVarsToDesugaredMethodDescriptor(lamDesc);
|
||||||
// first check if capturing lambda then invokestatic or invokespecial
|
// first check if capturing lambda then invokestatic or invokespecial
|
||||||
Handle arg2 = new Handle(staticOrSpecial, this.className, desugaredMethodName, newDesc, false);
|
Handle arg2 = new Handle(staticOrSpecial, this.className.getClassName(), desugaredMethodName, newDesc, false);
|
||||||
// Descriptor of functional interface methode
|
// Descriptor of functional interface methode
|
||||||
SamMethod samMethod = new SamMethod(kindOfLambda.getArgumentList(), lambdaExpression.getType());
|
SamMethod samMethod = new SamMethod(kindOfLambda.getArgumentList(), lambdaExpression.getType());
|
||||||
// Desc: (this/nothing)TargetType
|
// Desc: (this/nothing)TargetType
|
||||||
@ -636,7 +639,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
|
|
||||||
new BytecodeGenMethod(className, cw,lambdaExpression, usedVars,this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
|
new BytecodeGenMethod(className, cw,lambdaExpression, usedVars,this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
|
||||||
classFiles,this.path, lamCounter, sf, genericsAndBoundsMethod,
|
classFiles,this.path, lamCounter, sf, genericsAndBoundsMethod,
|
||||||
genericsAndBounds);
|
genericsAndBounds, classLoader);
|
||||||
|
|
||||||
mvLambdaBody.visitMaxs(0, 0);
|
mvLambdaBody.visitMaxs(0, 0);
|
||||||
mvLambdaBody.visitEnd();
|
mvLambdaBody.visitEnd();
|
||||||
@ -756,7 +759,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
|
|
||||||
MethodCallHelper helper = new MethodCallHelper(methodCall, sf, resultSet, path);
|
MethodCallHelper helper = new MethodCallHelper(methodCall, sf, resultSet, path);
|
||||||
|
|
||||||
ClassLoader cLoader = ClassLoader.getSystemClassLoader();
|
ClassLoader cLoader = this.classLoader;
|
||||||
// This will be used if the class is not standard class (not in API)
|
// This will be used if the class is not standard class (not in API)
|
||||||
ClassLoader cLoader2;
|
ClassLoader cLoader2;
|
||||||
|
|
||||||
@ -797,7 +800,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(methodRefl == null) {
|
if(methodRefl == null) {
|
||||||
boolean toCreate = !receiverName.equals(className) && helper.isInCurrPkg(clazz);
|
boolean toCreate = !receiverName.equals(className.getClassName()) && helper.isInCurrPkg(clazz);
|
||||||
if(toCreate) {
|
if(toCreate) {
|
||||||
try {
|
try {
|
||||||
mDesc = helper.getDesc(clazz);
|
mDesc = helper.getDesc(clazz);
|
||||||
@ -811,7 +814,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
// mDesc = helper.generateBCForFunN(methCallType,typesOfParams);
|
// mDesc = helper.generateBCForFunN(methCallType,typesOfParams);
|
||||||
}else {
|
}else {
|
||||||
try {
|
try {
|
||||||
cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)});
|
cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)}, classLoader);
|
||||||
java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
|
java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
|
||||||
System.out.println("Methods of " + receiverName + " ");
|
System.out.println("Methods of " + receiverName + " ");
|
||||||
for(int i = 0; i<methods.length; i++) {
|
for(int i = 0; i<methods.length; i++) {
|
||||||
@ -832,7 +835,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
System.out.println("Methodcall type : " + resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()));
|
System.out.println("Methodcall type : " + resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()));
|
||||||
List<Boolean> argListMethCall = new LinkedList<>();
|
List<Boolean> argListMethCall = new LinkedList<>();
|
||||||
String receiverRefl="";
|
String receiverRefl="";
|
||||||
if(methodRefl == null && receiverName.equals(className)) {
|
if(methodRefl == null && receiverName.equals(className.getClassName())) {
|
||||||
MethodFromMethodCall method = new MethodFromMethodCall(methodCall.arglist, methodCall.getType(),
|
MethodFromMethodCall method = new MethodFromMethodCall(methodCall.arglist, methodCall.getType(),
|
||||||
receiverName, genericsAndBoundsMethod, genericsAndBounds);
|
receiverName, genericsAndBoundsMethod, genericsAndBounds);
|
||||||
mDesc = method.accept(new DescriptorToString(resultSet));
|
mDesc = method.accept(new DescriptorToString(resultSet));
|
||||||
|
@ -16,6 +16,7 @@ import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
|||||||
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
||||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||||
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||||
@ -75,7 +76,7 @@ public class GeneratedGenericsFinder implements ASTVisitor {
|
|||||||
private final List<String> methodNameAndParamsT = new ArrayList<>();
|
private final List<String> methodNameAndParamsT = new ArrayList<>();
|
||||||
|
|
||||||
private String pkgName;
|
private String pkgName;
|
||||||
private String className;
|
private JavaClassName className;
|
||||||
private Resolver resolver;
|
private Resolver resolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,7 +118,7 @@ public class GeneratedGenericsFinder implements ASTVisitor {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void visit(ClassOrInterface classOrInterface) {
|
public void visit(ClassOrInterface classOrInterface) {
|
||||||
className = classOrInterface.getClassName().toString();
|
className = classOrInterface.getClassName();
|
||||||
List<ResultSet> listOfResultSetsList = new ArrayList<>(listOfResultSets);
|
List<ResultSet> listOfResultSetsList = new ArrayList<>(listOfResultSets);
|
||||||
|
|
||||||
boolean isVisited = false;
|
boolean isVisited = false;
|
||||||
|
@ -12,6 +12,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.*;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.*;
|
||||||
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
@ -30,7 +31,7 @@ public class GenericsGenerator {
|
|||||||
class constraints: tphClass < tphMeth1, tphMeth1 < tphMeth2, tphMeth2 < Object
|
class constraints: tphClass < tphMeth1, tphMeth1 < tphMeth2, tphMeth2 < Object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static GenericsGeneratorResultForClass generateConstraints(final String className, final TPHExtractor tphExtractor,
|
public static GenericsGeneratorResultForClass generateConstraints(final JavaClassName className, final TPHExtractor tphExtractor,
|
||||||
final List<String> tphsClass, final ConstraintsSimplierResult simplifiedConstraints) {
|
final List<String> tphsClass, final ConstraintsSimplierResult simplifiedConstraints) {
|
||||||
|
|
||||||
List<GenericsGeneratorResult> classConstraints = generateConstraintsForClass(tphExtractor,
|
List<GenericsGeneratorResult> classConstraints = generateConstraintsForClass(tphExtractor,
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
@ -37,9 +39,9 @@ public class GenericGenratorResultForSourceFile {
|
|||||||
genericGeneratorResultForAllClasses.add(sResClass);
|
genericGeneratorResultForAllClasses.add(sResClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericsGeneratorResultForClass getSimplifyResultsByName(String pkgName, String name) {
|
public GenericsGeneratorResultForClass getSimplifyResultsByName(JavaClassName name) {
|
||||||
|
|
||||||
if (this.pkgName.equals(pkgName)) {
|
if (this.pkgName.equals(name.getPackageName())) {
|
||||||
return genericGeneratorResultForAllClasses.stream()
|
return genericGeneratorResultForAllClasses.stream()
|
||||||
.filter(sr -> sr.getClassName().equals(name))
|
.filter(sr -> sr.getClassName().equals(name))
|
||||||
.findAny()
|
.findAny()
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -11,11 +13,11 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GenericsGeneratorResultForClass {
|
public class GenericsGeneratorResultForClass {
|
||||||
private final String className;
|
private final JavaClassName className;
|
||||||
private final List<GenericsGeneratorResult> classConstraints;
|
private final List<GenericsGeneratorResult> classConstraints;
|
||||||
private final GenericGeneratorResultsForAllMethods methodsAndTheirConstraints;
|
private final GenericGeneratorResultsForAllMethods methodsAndTheirConstraints;
|
||||||
|
|
||||||
public GenericsGeneratorResultForClass(String className) {
|
public GenericsGeneratorResultForClass(JavaClassName className) {
|
||||||
this(className, Collections.emptyList(), new GenericGeneratorResultsForAllMethods());
|
this(className, Collections.emptyList(), new GenericGeneratorResultsForAllMethods());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -23,8 +25,8 @@ public class GenericsGeneratorResultForClass {
|
|||||||
* @param classConstraints
|
* @param classConstraints
|
||||||
* @param methodsAndTheirConstraints
|
* @param methodsAndTheirConstraints
|
||||||
*/
|
*/
|
||||||
public GenericsGeneratorResultForClass(String className, List<GenericsGeneratorResult> classConstraints,
|
public GenericsGeneratorResultForClass(JavaClassName className, List<GenericsGeneratorResult> classConstraints,
|
||||||
GenericGeneratorResultsForAllMethods methodsAndTheirConstraints) {
|
GenericGeneratorResultsForAllMethods methodsAndTheirConstraints) {
|
||||||
this.className = className;
|
this.className = className;
|
||||||
this.classConstraints = classConstraints;
|
this.classConstraints = classConstraints;
|
||||||
this.methodsAndTheirConstraints = methodsAndTheirConstraints;
|
this.methodsAndTheirConstraints = methodsAndTheirConstraints;
|
||||||
@ -33,7 +35,7 @@ public class GenericsGeneratorResultForClass {
|
|||||||
/**
|
/**
|
||||||
* @return the className
|
* @return the className
|
||||||
*/
|
*/
|
||||||
public String getClassName() {
|
public JavaClassName getClassName() {
|
||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//PL 2018-12-19: typeInferenceOld nach typeInference uebertragen
|
//PL 2018-12-19: typeInferenceOld nach typeInference uebertragen
|
||||||
package de.dhbwstuttgart.core;
|
package de.dhbwstuttgart.core;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import de.dhbwstuttgart.bytecode.BytecodeGen;
|
import de.dhbwstuttgart.bytecode.BytecodeGen;
|
||||||
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
||||||
import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder;
|
import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder;
|
||||||
@ -41,6 +42,8 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -50,24 +53,34 @@ public class JavaTXCompiler {
|
|||||||
|
|
||||||
public static JavaTXCompiler INSTANCE;
|
public static JavaTXCompiler INSTANCE;
|
||||||
final CompilationEnvironment environment;
|
final CompilationEnvironment environment;
|
||||||
Boolean resultmodel = true;
|
Boolean resultmodel = true;
|
||||||
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
||||||
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll?
|
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll?
|
||||||
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
||||||
|
private final ClassLoader classLoader;
|
||||||
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
|
||||||
this(Arrays.asList(sourceFile));
|
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
||||||
INSTANCE = this;
|
this(Arrays.asList(sourceFile), null);
|
||||||
}
|
INSTANCE = this;
|
||||||
|
}
|
||||||
|
|
||||||
public JavaTXCompiler(File sourceFile, Boolean log) throws IOException, ClassNotFoundException {
|
public JavaTXCompiler(File sourceFile, Boolean log) throws IOException, ClassNotFoundException {
|
||||||
this(sourceFile);
|
this(sourceFile);
|
||||||
this.log = log;
|
this.log = log;
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JavaTXCompiler(List<File> sources) throws IOException, ClassNotFoundException {
|
public JavaTXCompiler(List<File> sourceFiles) throws IOException, ClassNotFoundException {
|
||||||
environment = new CompilationEnvironment(sources);
|
this(sourceFiles, null);
|
||||||
|
INSTANCE = this;
|
||||||
|
}
|
||||||
|
public JavaTXCompiler(List<File> sources, List<URL> contextPath) throws IOException, ClassNotFoundException {
|
||||||
|
if(contextPath == null || contextPath.isEmpty()){
|
||||||
|
//When no contextPaths are given, the working directory is the sources root
|
||||||
|
contextPath = Lists.newArrayList(new URL("file://" + System.getProperty("user.dir")));
|
||||||
|
}
|
||||||
|
classLoader = new URLClassLoader(contextPath.toArray(new URL[0]), ClassLoader.getSystemClassLoader());
|
||||||
|
environment = new CompilationEnvironment(sources);
|
||||||
for (File s : sources) {
|
for (File s : sources) {
|
||||||
sourceFiles.put(s, parse(s));
|
sourceFiles.put(s, parse(s));
|
||||||
}
|
}
|
||||||
@ -85,7 +98,7 @@ public class JavaTXCompiler {
|
|||||||
for (JavaClassName name : sourceFiles.get(forSourceFile).getImports()) {
|
for (JavaClassName name : sourceFiles.get(forSourceFile).getImports()) {
|
||||||
//TODO: Hier werden imports von eigenen (.jav) Klassen nicht beachtet
|
//TODO: Hier werden imports von eigenen (.jav) Klassen nicht beachtet
|
||||||
ClassOrInterface importedClass = ASTFactory.createClass(
|
ClassOrInterface importedClass = ASTFactory.createClass(
|
||||||
ClassLoader.getSystemClassLoader().loadClass(name.toString()));
|
classLoader.loadClass(name.toString()));
|
||||||
importedClasses.add(importedClass);
|
importedClasses.add(importedClass);
|
||||||
}
|
}
|
||||||
allClasses.addAll(importedClasses);
|
allClasses.addAll(importedClasses);
|
||||||
@ -122,7 +135,7 @@ public class JavaTXCompiler {
|
|||||||
for (JavaClassName name : forSourceFile.getImports()) {
|
for (JavaClassName name : forSourceFile.getImports()) {
|
||||||
// TODO: Hier werden imports von eigenen (.jav) Klassen nicht beachtet
|
// TODO: Hier werden imports von eigenen (.jav) Klassen nicht beachtet
|
||||||
ClassOrInterface importedClass = ASTFactory
|
ClassOrInterface importedClass = ASTFactory
|
||||||
.createClass(ClassLoader.getSystemClassLoader().loadClass(name.toString()));
|
.createClass(classLoader.loadClass(name.toString()));
|
||||||
importedClasses.add(importedClass);
|
importedClasses.add(importedClass);
|
||||||
allClasses.addAll(importedClasses);
|
allClasses.addAll(importedClasses);
|
||||||
}
|
}
|
||||||
@ -291,7 +304,7 @@ public class JavaTXCompiler {
|
|||||||
logFile = logFile == null
|
logFile = logFile == null
|
||||||
? new FileWriter(new File("log_" + sourceFiles.keySet().iterator().next().getName()))
|
? new FileWriter(new File("log_" + sourceFiles.keySet().iterator().next().getName()))
|
||||||
: logFile;
|
: logFile;
|
||||||
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses, logFile);
|
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses, logFile, classLoader);
|
||||||
System.out.println(finiteClosure);
|
System.out.println(finiteClosure);
|
||||||
urm = new UnifyResultModel(cons, finiteClosure);
|
urm = new UnifyResultModel(cons, finiteClosure);
|
||||||
urm.addUnifyResultListener(resultListener);
|
urm.addUnifyResultListener(resultListener);
|
||||||
@ -459,7 +472,7 @@ public class JavaTXCompiler {
|
|||||||
// File(System.getProperty("user.dir")+"/src/test/resources/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
// File(System.getProperty("user.dir")+"/src/test/resources/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
||||||
new FileWriter(new File(System.getProperty("user.dir") + "/logFiles/" + "log_"
|
new FileWriter(new File(System.getProperty("user.dir") + "/logFiles/" + "log_"
|
||||||
+ sourceFiles.keySet().iterator().next().getName()));
|
+ sourceFiles.keySet().iterator().next().getName()));
|
||||||
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses, logFile);
|
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses, logFile, classLoader);
|
||||||
System.out.println(finiteClosure);
|
System.out.println(finiteClosure);
|
||||||
ConstraintSet<UnifyPair> unifyCons = UnifyTypeFactory.convert(cons);
|
ConstraintSet<UnifyPair> unifyCons = UnifyTypeFactory.convert(cons);
|
||||||
|
|
||||||
@ -708,17 +721,17 @@ public class JavaTXCompiler {
|
|||||||
|
|
||||||
private SourceFile parse(File sourceFile) throws IOException, java.lang.ClassNotFoundException {
|
private SourceFile parse(File sourceFile) throws IOException, java.lang.ClassNotFoundException {
|
||||||
CompilationUnitContext tree = JavaTXParser.parse(sourceFile);
|
CompilationUnitContext tree = JavaTXParser.parse(sourceFile);
|
||||||
SyntaxTreeGenerator generator = new SyntaxTreeGenerator(environment.getRegistry(sourceFile),
|
SyntaxTreeGenerator generator = new SyntaxTreeGenerator(environment.getRegistry(sourceFile, classLoader),
|
||||||
new GenericsRegistry(null));
|
new GenericsRegistry(null));
|
||||||
SourceFile ret = generator.convert(tree, environment.packageCrawler);
|
SourceFile ret = generator.convert(tree, environment.packageCrawler, classLoader);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateBytecodForFile(String path, HashMap<String, byte[]> classFiles, SourceFile sf,
|
public void generateBytecodForFile(String path, HashMap<JavaClassName, byte[]> classFiles, SourceFile sf,
|
||||||
List<ResultSet> typeinferenceResult) throws IOException {
|
List<ResultSet> typeinferenceResult) throws IOException {
|
||||||
try {
|
try {
|
||||||
List<GenericGenratorResultForSourceFile> genericResults = getGeneratedGenericResultsForAllSourceFiles(typeinferenceResult);
|
List<GenericGenratorResultForSourceFile> genericResults = getGeneratedGenericResultsForAllSourceFiles(typeinferenceResult);
|
||||||
BytecodeGen bytecodeGen = new BytecodeGen(classFiles,typeinferenceResult, genericResults, sf,path);
|
BytecodeGen bytecodeGen = new BytecodeGen(classFiles,typeinferenceResult, genericResults, sf,path, classLoader);
|
||||||
bytecodeGen.visit(sf);
|
bytecodeGen.visit(sf);
|
||||||
this.writeClassFile(bytecodeGen.getClassFiles(), path);
|
this.writeClassFile(bytecodeGen.getClassFiles(), path);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
@ -753,7 +766,13 @@ public class JavaTXCompiler {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// um pfad erweitern
|
public void generateBytecode() throws ClassNotFoundException, IOException, BytecodeGeneratorError {
|
||||||
|
generateBytecode(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param path - can be null, then class file output is in the same directory as the parsed source files
|
||||||
|
*/
|
||||||
public void generateBytecode(String path) throws ClassNotFoundException, IOException, BytecodeGeneratorError {
|
public void generateBytecode(String path) throws ClassNotFoundException, IOException, BytecodeGeneratorError {
|
||||||
List<ResultSet> typeinferenceResult = this.typeInference();
|
List<ResultSet> typeinferenceResult = this.typeInference();
|
||||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = getGeneratedGenericResultsForAllSourceFiles(
|
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = getGeneratedGenericResultsForAllSourceFiles(
|
||||||
@ -770,27 +789,30 @@ public class JavaTXCompiler {
|
|||||||
public void generateBytecode(String path, List<ResultSet> typeinferenceResult,
|
public void generateBytecode(String path, List<ResultSet> typeinferenceResult,
|
||||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles) throws IOException {
|
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles) throws IOException {
|
||||||
for (File f : sourceFiles.keySet()) {
|
for (File f : sourceFiles.keySet()) {
|
||||||
HashMap<String, byte[]> classFiles = new HashMap<>();
|
HashMap<JavaClassName, byte[]> classFiles = new HashMap<>();
|
||||||
SourceFile sf = sourceFiles.get(f);
|
SourceFile sf = sourceFiles.get(f);
|
||||||
BytecodeGen bytecodeGen = new BytecodeGen(classFiles, typeinferenceResult, simplifyResultsForAllSourceFiles,
|
BytecodeGen bytecodeGen = new BytecodeGen(classFiles, typeinferenceResult, simplifyResultsForAllSourceFiles,
|
||||||
sf, path);
|
sf, path, classLoader);
|
||||||
bytecodeGen.visit(sf);
|
bytecodeGen.visit(sf);
|
||||||
String packagePath = sf.getPkgName().replace(".","/");
|
|
||||||
if(path == null){
|
if(path == null){
|
||||||
path = f.getPath();
|
path = f.getParent(); //Set path to path of the parsed .jav file
|
||||||
|
}else{
|
||||||
|
path += sf.getPkgName().replace(".","/"); //add package path to root path
|
||||||
}
|
}
|
||||||
writeClassFile(bytecodeGen.getClassFiles(), path + packagePath);
|
writeClassFile(bytecodeGen.getClassFiles(), path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeClassFile(HashMap<String, byte[]> classFiles, String path) throws IOException {
|
private void writeClassFile(HashMap<JavaClassName, byte[]> classFiles, String path) throws IOException {
|
||||||
FileOutputStream output;
|
FileOutputStream output;
|
||||||
for (String name : classFiles.keySet()) {
|
for (JavaClassName name : classFiles.keySet()) {
|
||||||
byte[] bytecode = classFiles.get(name);
|
byte[] bytecode = classFiles.get(name);
|
||||||
System.out.println("generating " + name + ".class file ...");
|
System.out.println("generating " + name + ".class file ...");
|
||||||
// output = new FileOutputStream(new File(System.getProperty("user.dir") +
|
// output = new FileOutputStream(new File(System.getProperty("user.dir") +
|
||||||
// "/testBytecode/generatedBC/" +name+".class"));
|
// "/testBytecode/generatedBC/" +name+".class"));
|
||||||
output = new FileOutputStream(new File(path + name + ".class"));
|
File outputFile = new File(path + File.separator + name.getClassName() + ".class");
|
||||||
|
outputFile.getParentFile().mkdirs();
|
||||||
|
output = new FileOutputStream(outputFile);
|
||||||
output.write(bytecode);
|
output.write(bytecode);
|
||||||
output.close();
|
output.close();
|
||||||
System.out.println(name + ".class file generated");
|
System.out.println(name + ".class file generated");
|
||||||
|
@ -50,7 +50,6 @@ public class CompilationEnvironment {
|
|||||||
*/
|
*/
|
||||||
//String bootClassPath = System.getProperty("sun.boot.class.path");
|
//String bootClassPath = System.getProperty("sun.boot.class.path");
|
||||||
// ClassLoader cl = ClassLoader.getPlatformClassLoader();
|
// ClassLoader cl = ClassLoader.getPlatformClassLoader();
|
||||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
|
||||||
String bootClassPath = System.getProperty("java.class.path");
|
String bootClassPath = System.getProperty("java.class.path");
|
||||||
librarys = new ArrayList<>();
|
librarys = new ArrayList<>();
|
||||||
for(String path : bootClassPath.split(File.pathSeparator)) {
|
for(String path : bootClassPath.split(File.pathSeparator)) {
|
||||||
@ -67,10 +66,10 @@ public class CompilationEnvironment {
|
|||||||
this.packageCrawler = new PackageCrawler(librarys);
|
this.packageCrawler = new PackageCrawler(librarys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JavaClassRegistry getRegistry(File forSourceFile) throws ClassNotFoundException, IOException {
|
public JavaClassRegistry getRegistry(File forSourceFile, ClassLoader classLoader) throws ClassNotFoundException, IOException {
|
||||||
Map<String, Integer> allNames;
|
Map<String, Integer> allNames;
|
||||||
CompilationUnitContext tree = JavaTXParser.parse(forSourceFile);
|
CompilationUnitContext tree = JavaTXParser.parse(forSourceFile);
|
||||||
allNames = GatherNames.getNames(tree, packageCrawler);
|
allNames = GatherNames.getNames(tree, packageCrawler, classLoader);
|
||||||
return new JavaClassRegistry(allNames);
|
return new JavaClassRegistry(allNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,16 +22,16 @@ public class FCGenerator {
|
|||||||
*
|
*
|
||||||
* @param availableClasses - Alle geparsten Klassen
|
* @param availableClasses - Alle geparsten Klassen
|
||||||
*/
|
*/
|
||||||
public static Set<UnifyPair> toUnifyFC(Collection<ClassOrInterface> availableClasses) throws ClassNotFoundException {
|
public static Set<UnifyPair> toUnifyFC(Collection<ClassOrInterface> availableClasses, ClassLoader classLoader) throws ClassNotFoundException {
|
||||||
return toFC(availableClasses).stream().map(t -> UnifyTypeFactory.convert(t)).collect(Collectors.toSet());
|
return toFC(availableClasses, classLoader).stream().map(t -> UnifyTypeFactory.convert(t)).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<Pair> toFC(Collection<ClassOrInterface> availableClasses) throws ClassNotFoundException {
|
public static Set<Pair> toFC(Collection<ClassOrInterface> availableClasses, ClassLoader classLoader) throws ClassNotFoundException {
|
||||||
HashSet<Pair> pairs = new HashSet<>();
|
HashSet<Pair> pairs = new HashSet<>();
|
||||||
//PL 2018-09-18: gtvs vor die for-Schleife gezogen, damit immer die gleichen Typeplaceholder eingesetzt werden.
|
//PL 2018-09-18: gtvs vor die for-Schleife gezogen, damit immer die gleichen Typeplaceholder eingesetzt werden.
|
||||||
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> gtvs = new HashMap<>();
|
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> gtvs = new HashMap<>();
|
||||||
for(ClassOrInterface cly : availableClasses){
|
for(ClassOrInterface cly : availableClasses){
|
||||||
pairs.addAll(getSuperTypes(cly, availableClasses, gtvs));
|
pairs.addAll(getSuperTypes(cly, availableClasses, gtvs, classLoader));
|
||||||
}
|
}
|
||||||
return pairs;
|
return pairs;
|
||||||
}
|
}
|
||||||
@ -48,8 +48,8 @@ public class FCGenerator {
|
|||||||
* @param forType
|
* @param forType
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static List<Pair> getSuperTypes(ClassOrInterface forType, Collection<ClassOrInterface> availableClasses) throws ClassNotFoundException {
|
private static List<Pair> getSuperTypes(ClassOrInterface forType, Collection<ClassOrInterface> availableClasses, ClassLoader classLoader) throws ClassNotFoundException {
|
||||||
return getSuperTypes(forType, availableClasses, new HashMap<>());
|
return getSuperTypes(forType, availableClasses, new HashMap<>(), classLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +61,7 @@ public class FCGenerator {
|
|||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
private static List<Pair> getSuperTypes(ClassOrInterface forType, Collection<ClassOrInterface> availableClasses,
|
private static List<Pair> getSuperTypes(ClassOrInterface forType, Collection<ClassOrInterface> availableClasses,
|
||||||
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> gtvs) throws ClassNotFoundException {
|
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> gtvs, ClassLoader classLoader) throws ClassNotFoundException {
|
||||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||||
//Die GTVs, die in forType hinzukommen:
|
//Die GTVs, die in forType hinzukommen:
|
||||||
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> newGTVs = new HashMap<>();
|
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> newGTVs = new HashMap<>();
|
||||||
@ -86,7 +86,7 @@ public class FCGenerator {
|
|||||||
ClassOrInterface superClass;
|
ClassOrInterface superClass;
|
||||||
if(!hasSuperclass.isPresent()) //Wenn es die Klasse in den available Klasses nicht gibt wird sie im Classpath gesucht. Ansonsten Exception
|
if(!hasSuperclass.isPresent()) //Wenn es die Klasse in den available Klasses nicht gibt wird sie im Classpath gesucht. Ansonsten Exception
|
||||||
{
|
{
|
||||||
superClass = ASTFactory.createClass(ClassLoader.getSystemClassLoader().loadClass(superType.getName().toString()));
|
superClass = ASTFactory.createClass(classLoader.loadClass(superType.getName().toString()));
|
||||||
}else{
|
}else{
|
||||||
superClass = hasSuperclass.get();
|
superClass = hasSuperclass.get();
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ public class FCGenerator {
|
|||||||
if(superClass.getClassName().equals(ASTFactory.createObjectClass().getClassName())){
|
if(superClass.getClassName().equals(ASTFactory.createObjectClass().getClassName())){
|
||||||
superTypes = Arrays.asList(new Pair(ASTFactory.createObjectType(), ASTFactory.createObjectType(), PairOperator.SMALLER));
|
superTypes = Arrays.asList(new Pair(ASTFactory.createObjectType(), ASTFactory.createObjectType(), PairOperator.SMALLER));
|
||||||
}else{
|
}else{
|
||||||
superTypes = getSuperTypes(superClass, availableClasses, newGTVs);
|
superTypes = getSuperTypes(superClass, availableClasses, newGTVs, classLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
retList.add(ret);
|
retList.add(ret);
|
||||||
|
@ -279,9 +279,21 @@ public class StatementGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Statement convert(Java8Parser.ClassInstanceCreationExpressionContext stmt) {
|
private Statement convert(Java8Parser.ClassInstanceCreationExpressionContext newExpression) {
|
||||||
//TODO
|
Java8Parser.TypeArgumentsContext genericArgs = null;
|
||||||
throw new NotImplementedException();
|
if(newExpression.expressionName()!= null)throw new NotImplementedException();
|
||||||
|
if(newExpression.typeArgumentsOrDiamond()!= null){
|
||||||
|
if(newExpression.typeArgumentsOrDiamond().typeArguments()!=null){
|
||||||
|
genericArgs = newExpression.typeArgumentsOrDiamond().typeArguments();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(newExpression.typeArguments()!= null)throw new NotImplementedException();
|
||||||
|
|
||||||
|
TerminalNode identifier = newExpression.Identifier(0);
|
||||||
|
RefType newClass = (RefType) TypeGenerator.convertTypeName(identifier.getText(),genericArgs,identifier.getSymbol(),reg,generics);
|
||||||
|
|
||||||
|
ArgumentList args = convert(newExpression.argumentList());
|
||||||
|
return new NewClass(newClass, args, newExpression.getStart());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Statement convert(Java8Parser.PreIncrementExpressionContext stmt) {
|
private Statement convert(Java8Parser.PreIncrementExpressionContext stmt) {
|
||||||
|
@ -19,6 +19,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
|||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.net.URL;
|
||||||
import java.sql.Ref;
|
import java.sql.Ref;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -74,10 +75,10 @@ public class SyntaxTreeGenerator{
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceFile convert(Java8Parser.CompilationUnitContext ctx, PackageCrawler packageCrawler) throws ClassNotFoundException{
|
public SourceFile convert(Java8Parser.CompilationUnitContext ctx, PackageCrawler packageCrawler, ClassLoader classLoader) throws ClassNotFoundException{
|
||||||
if(ctx.packageDeclaration()!=null)this.pkgName = convert(ctx.packageDeclaration());
|
if(ctx.packageDeclaration()!=null)this.pkgName = convert(ctx.packageDeclaration());
|
||||||
List<ClassOrInterface> classes = new ArrayList<>();
|
List<ClassOrInterface> classes = new ArrayList<>();
|
||||||
Map<String, Integer> imports = GatherNames.getImports(ctx, packageCrawler);
|
Map<String, Integer> imports = GatherNames.getImports(ctx, packageCrawler, classLoader);
|
||||||
this.imports = imports.keySet().stream().map(name -> reg.getName(name)).collect(Collectors.toSet());
|
this.imports = imports.keySet().stream().map(name -> reg.getName(name)).collect(Collectors.toSet());
|
||||||
for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
|
for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
|
||||||
ClassOrInterface newClass;
|
ClassOrInterface newClass;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package de.dhbwstuttgart.parser.scope;
|
package de.dhbwstuttgart.parser.scope;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.net.URLClassLoader;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import de.dhbwstuttgart.parser.antlr.Java8BaseListener;
|
import de.dhbwstuttgart.parser.antlr.Java8BaseListener;
|
||||||
import de.dhbwstuttgart.syntaxtree.AbstractASTWalker;
|
import de.dhbwstuttgart.syntaxtree.AbstractASTWalker;
|
||||||
@ -15,7 +14,7 @@ import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
|||||||
|
|
||||||
public class GatherNames {
|
public class GatherNames {
|
||||||
|
|
||||||
public static Map<String, Integer> getNames(Java8Parser.CompilationUnitContext ctx, PackageCrawler packages) throws ClassNotFoundException{
|
public static Map<String, Integer> getNames(Java8Parser.CompilationUnitContext ctx, PackageCrawler packages, ClassLoader classLoader) throws ClassNotFoundException{
|
||||||
Map<String, Integer> ret = new HashMap<>();
|
Map<String, Integer> ret = new HashMap<>();
|
||||||
String pkgName = getPackageName(ctx);
|
String pkgName = getPackageName(ctx);
|
||||||
String nameString = "";
|
String nameString = "";
|
||||||
@ -64,14 +63,13 @@ public class GatherNames {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret.putAll(getImports(ctx, packages));
|
ret.putAll(getImports(ctx, packages, classLoader));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Map<String, Integer> getImports(Java8Parser.CompilationUnitContext ctx, PackageCrawler packages) throws ClassNotFoundException {
|
public static Map<String, Integer> getImports(Java8Parser.CompilationUnitContext ctx, PackageCrawler packages, ClassLoader classLoader) throws ClassNotFoundException {
|
||||||
Map<String, Integer> ret = new HashMap<>();
|
Map<String, Integer> ret = new HashMap<>();
|
||||||
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
|
||||||
//ret.putAll(packages.getClassNames("java.lang"));
|
//ret.putAll(packages.getClassNames("java.lang"));
|
||||||
for(Java8Parser.ImportDeclarationContext importDeclCtx : ctx.importDeclaration()){
|
for(Java8Parser.ImportDeclarationContext importDeclCtx : ctx.importDeclaration()){
|
||||||
if(importDeclCtx.singleTypeImportDeclaration() != null){
|
if(importDeclCtx.singleTypeImportDeclaration() != null){
|
||||||
|
@ -84,7 +84,15 @@ public class JavaClassName {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return (packageName!=null ? packageName.toString() : "") + name;
|
return (packageName!=null ? packageName.toString() + "." : "") + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPackageName() {
|
||||||
|
return (packageName!=null ? packageName.toString() : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClassName(){
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +138,9 @@ class PackageName{
|
|||||||
String ret = "";
|
String ret = "";
|
||||||
if(names == null)return "";
|
if(names == null)return "";
|
||||||
for(String n : names)ret+=n+".";
|
for(String n : names)ret+=n+".";
|
||||||
|
if (ret != null && ret.length() > 0 && ret.charAt(ret.length() - 1) == '.') {
|
||||||
|
ret = ret.substring(0, ret.length() - 1);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ import java.util.*;
|
|||||||
|
|
||||||
public class ASPFactory implements TypeVisitor<String>{
|
public class ASPFactory implements TypeVisitor<String>{
|
||||||
|
|
||||||
public static String generateASP(ConstraintSet<Pair> constraints, Collection<ClassOrInterface> fcClasses) throws ClassNotFoundException{
|
public static String generateASP(ConstraintSet<Pair> constraints, Collection<ClassOrInterface> fcClasses, ClassLoader classLoader) throws ClassNotFoundException{
|
||||||
ASPFactory factory = new ASPFactory();
|
ASPFactory factory = new ASPFactory();
|
||||||
factory.convertFC(fcClasses);
|
factory.convertFC(fcClasses, classLoader);
|
||||||
List<Constraint<Pair>> constraints1 = constraints.cartesianProduct().iterator().next();
|
List<Constraint<Pair>> constraints1 = constraints.cartesianProduct().iterator().next();
|
||||||
for(Constraint<Pair> constraint : constraints1){
|
for(Constraint<Pair> constraint : constraints1){
|
||||||
for(Pair p : constraint){
|
for(Pair p : constraint){
|
||||||
@ -32,8 +32,8 @@ public class ASPFactory implements TypeVisitor<String>{
|
|||||||
ASPWriter writer = new ASPWriter();
|
ASPWriter writer = new ASPWriter();
|
||||||
boolean isFCType = false;
|
boolean isFCType = false;
|
||||||
|
|
||||||
private void convertFC(Collection<ClassOrInterface> classes) throws ClassNotFoundException {
|
private void convertFC(Collection<ClassOrInterface> classes, ClassLoader classLoader) throws ClassNotFoundException {
|
||||||
Set<Pair> fc = FCGenerator.toFC(classes);
|
Set<Pair> fc = FCGenerator.toFC(classes, classLoader);
|
||||||
isFCType = true;
|
isFCType = true;
|
||||||
for(Pair fcp : fc){
|
for(Pair fcp : fc){
|
||||||
convertPair(fcp);
|
convertPair(fcp);
|
||||||
|
@ -55,9 +55,9 @@ public class ASPGencayFactory implements TypeVisitor<String> {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String generateASP(ConstraintSet<Pair> constraints, Collection<ClassOrInterface> fcClasses) throws ClassNotFoundException{
|
public static String generateASP(ConstraintSet<Pair> constraints, Collection<ClassOrInterface> fcClasses, ClassLoader classLoader) throws ClassNotFoundException{
|
||||||
ASPGencayFactory factory = new ASPGencayFactory();
|
ASPGencayFactory factory = new ASPGencayFactory();
|
||||||
factory.convertFC(fcClasses);
|
factory.convertFC(fcClasses, classLoader);
|
||||||
List<Constraint<Pair>> constraints1 = constraints.cartesianProduct().iterator().next();
|
List<Constraint<Pair>> constraints1 = constraints.cartesianProduct().iterator().next();
|
||||||
for(Constraint<Pair> constraint : constraints1){
|
for(Constraint<Pair> constraint : constraints1){
|
||||||
for(Pair p : constraint){
|
for(Pair p : constraint){
|
||||||
@ -69,8 +69,8 @@ public class ASPGencayFactory implements TypeVisitor<String> {
|
|||||||
return factory.writer.getASPFile();
|
return factory.writer.getASPFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void convertFC(Collection<ClassOrInterface> classes) throws ClassNotFoundException {
|
private void convertFC(Collection<ClassOrInterface> classes, ClassLoader classLoader) throws ClassNotFoundException {
|
||||||
Set<Pair> fc = FCGenerator.toFC(classes);
|
Set<Pair> fc = FCGenerator.toFC(classes, classLoader);
|
||||||
isFCType = true;
|
isFCType = true;
|
||||||
for(Pair fcp : fc){
|
for(Pair fcp : fc){
|
||||||
generateTheta((RefType) fcp.TA1);
|
generateTheta((RefType) fcp.TA1);
|
||||||
|
@ -31,7 +31,7 @@ public class UnifyTypeFactory {
|
|||||||
|
|
||||||
private static ArrayList<PlaceholderType> PLACEHOLDERS = new ArrayList<>();
|
private static ArrayList<PlaceholderType> PLACEHOLDERS = new ArrayList<>();
|
||||||
|
|
||||||
public static FiniteClosure generateFC(List<ClassOrInterface> fromClasses, Writer logFile) throws ClassNotFoundException {
|
public static FiniteClosure generateFC(List<ClassOrInterface> fromClasses, Writer logFile, ClassLoader classLoader) throws ClassNotFoundException {
|
||||||
/*
|
/*
|
||||||
Die transitive Hülle muss funktionieren.
|
Die transitive Hülle muss funktionieren.
|
||||||
Man darf schreiben List<A> extends AL<A>
|
Man darf schreiben List<A> extends AL<A>
|
||||||
@ -42,7 +42,7 @@ public class UnifyTypeFactory {
|
|||||||
Generell dürfen sie immer die gleichen Namen haben.
|
Generell dürfen sie immer die gleichen Namen haben.
|
||||||
TODO: die transitive Hülle bilden
|
TODO: die transitive Hülle bilden
|
||||||
*/
|
*/
|
||||||
return new FiniteClosure(FCGenerator.toUnifyFC(fromClasses), logFile);
|
return new FiniteClosure(FCGenerator.toUnifyFC(fromClasses, classLoader), logFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UnifyPair generateSmallerPair(UnifyType tl, UnifyType tr){
|
public static UnifyPair generateSmallerPair(UnifyType tl, UnifyType tr){
|
||||||
|
@ -47,7 +47,7 @@ public class TypeInsertFactory {
|
|||||||
new TypeToInsertString(resolvedType.resolvedType).insert);
|
new TypeToInsertString(resolvedType.resolvedType).insert);
|
||||||
List<GenericGenratorResultForSourceFile> simplifyResults = JavaTXCompiler.INSTANCE.getGeneratedGenericResultsForAllSourceFiles(newResults);
|
List<GenericGenratorResultForSourceFile> simplifyResults = JavaTXCompiler.INSTANCE.getGeneratedGenericResultsForAllSourceFiles(newResults);
|
||||||
for (GenericGenratorResultForSourceFile simplifyResultsEntries : simplifyResults) {
|
for (GenericGenratorResultForSourceFile simplifyResultsEntries : simplifyResults) {
|
||||||
GenericsGeneratorResultForClass genericResultsForClass = simplifyResultsEntries.getSimplifyResultsByName("", cl.getClassName().toString());
|
GenericsGeneratorResultForClass genericResultsForClass = simplifyResultsEntries.getSimplifyResultsByName(cl.getClassName());
|
||||||
return new TypeInsert(insertPoint, createGenericInsert(genericResultsForClass, cl, m, resultSet, offset), resolvedType.getResultPair());
|
return new TypeInsert(insertPoint, createGenericInsert(genericResultsForClass, cl, m, resultSet, offset), resolvedType.getResultPair());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public class ClingoTest {
|
|||||||
@Test
|
@Test
|
||||||
public void test() throws IOException, InterruptedException, ClassNotFoundException {
|
public void test() throws IOException, InterruptedException, ClassNotFoundException {
|
||||||
String content = "";
|
String content = "";
|
||||||
content = ASPFactory.generateASP(this.getPairs(), this.getFC());
|
content = ASPFactory.generateASP(this.getPairs(), this.getFC(), ClassLoader.getSystemClassLoader());
|
||||||
|
|
||||||
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
|
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
|
||||||
writer.println(content);
|
writer.println(content);
|
||||||
|
@ -40,7 +40,7 @@ public class UnifyWithoutWildcards {
|
|||||||
|
|
||||||
public ResultSet run(ConstraintSet<Pair> toTest) throws IOException, InterruptedException, ClassNotFoundException {
|
public ResultSet run(ConstraintSet<Pair> toTest) throws IOException, InterruptedException, ClassNotFoundException {
|
||||||
String content = "";
|
String content = "";
|
||||||
content = ASPFactory.generateASP(toTest, this.getFC());
|
content = ASPFactory.generateASP(toTest, this.getFC(), ClassLoader.getSystemClassLoader());
|
||||||
|
|
||||||
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
|
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
|
||||||
writer.println(content);
|
writer.println(content);
|
||||||
|
@ -35,7 +35,7 @@ public class GeneratorTest extends UnifyWithoutWildcards{
|
|||||||
RefType t2 = new RefType(new JavaClassName("java.util.List"), list2, new NullToken());
|
RefType t2 = new RefType(new JavaClassName("java.util.List"), list2, new NullToken());
|
||||||
testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT));
|
testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT));
|
||||||
String resultSet = ASPGencayFactory.generateASP(testSet,
|
String resultSet = ASPGencayFactory.generateASP(testSet,
|
||||||
new HashSet<>(Arrays.asList(ASTFactory.createClass(List.class))));
|
new HashSet<>(Arrays.asList(ASTFactory.createClass(List.class))), ClassLoader.getSystemClassLoader());
|
||||||
System.out.println(resultSet);
|
System.out.println(resultSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public class GeneratorTest extends UnifyWithoutWildcards{
|
|||||||
RefType t1 = new RefType(new JavaClassName("asp.UnifyWithoutWildcards$Matrix"), list1, new NullToken());
|
RefType t1 = new RefType(new JavaClassName("asp.UnifyWithoutWildcards$Matrix"), list1, new NullToken());
|
||||||
RefType t2 = new RefType(new JavaClassName("java.util.HashMap"), list2, new NullToken());
|
RefType t2 = new RefType(new JavaClassName("java.util.HashMap"), list2, new NullToken());
|
||||||
testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT));
|
testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT));
|
||||||
String resultSet = ASPGencayFactory.generateASP(testSet, this.getFC());
|
String resultSet = ASPGencayFactory.generateASP(testSet, this.getFC(), ClassLoader.getSystemClassLoader());
|
||||||
System.out.println(resultSet);
|
System.out.println(resultSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class ASPTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final ConstraintSet<Pair> cons = compiler.getConstraints();
|
final ConstraintSet<Pair> cons = compiler.getConstraints();
|
||||||
String asp = ASPFactory.generateASP(cons, allClasses);
|
String asp = ASPFactory.generateASP(cons, allClasses, ClassLoader.getSystemClassLoader());
|
||||||
System.out.println(asp);
|
System.out.println(asp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,14 +14,14 @@ public class SuperInterfacesTest {
|
|||||||
public void test() throws ClassNotFoundException {
|
public void test() throws ClassNotFoundException {
|
||||||
Collection<ClassOrInterface> classes = new ArrayList<>();
|
Collection<ClassOrInterface> classes = new ArrayList<>();
|
||||||
classes.add(ASTFactory.createClass(TestClass.class));
|
classes.add(ASTFactory.createClass(TestClass.class));
|
||||||
System.out.println(FCGenerator.toFC(classes));
|
System.out.println(FCGenerator.toFC(classes, ClassLoader.getSystemClassLoader()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGeneric() throws ClassNotFoundException {
|
public void testGeneric() throws ClassNotFoundException {
|
||||||
Collection<ClassOrInterface> classes = new ArrayList<>();
|
Collection<ClassOrInterface> classes = new ArrayList<>();
|
||||||
classes.add(ASTFactory.createClass(TestClassGeneric.class));
|
classes.add(ASTFactory.createClass(TestClassGeneric.class));
|
||||||
System.out.println(FCGenerator.toFC(classes));
|
System.out.println(FCGenerator.toFC(classes, ClassLoader.getSystemClassLoader()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,20 +6,47 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
public class Bytecode extends TestCase {
|
public class Bytecode extends TestCase {
|
||||||
|
|
||||||
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/de/test/";
|
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/";
|
||||||
@Test
|
@Test
|
||||||
public void testSetPackageNameInBytecode() throws IOException, ClassNotFoundException {
|
public void testSetPackageNameInBytecode() throws Exception {
|
||||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"packageNameTest.jav"));
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"de/test/TestClass.jav"));
|
||||||
compiler.typeInference();
|
compiler.typeInference();
|
||||||
File f = new File(rootDirectory + "Test.class");
|
File f = new File(rootDirectory + "de/test/TestClass.class");
|
||||||
if(f.exists() && !f.isDirectory()) {
|
if(f.exists() && !f.isDirectory()) {
|
||||||
f.delete();
|
f.delete();
|
||||||
}
|
}
|
||||||
compiler.generateBytecode(null);
|
compiler.generateBytecode(null);
|
||||||
f = new File(rootDirectory + "Test.class");
|
f = new File(rootDirectory + "de/test/TestClass.class");
|
||||||
assertTrue(f.exists());
|
assertTrue(f.exists());
|
||||||
|
|
||||||
|
|
||||||
|
URLClassLoader loader = new URLClassLoader(new URL[]{new URL("file://" + rootDirectory)});
|
||||||
|
Class<?> classToTest = loader.loadClass("de.test.TestClass");
|
||||||
|
Object instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetPackageNameInBytecodeAndOutputFolder() throws Exception {
|
||||||
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"de/test/TestClass.jav"));
|
||||||
|
compiler.typeInference();
|
||||||
|
File f = new File(rootDirectory + "de/test/output/de/test/TestClass.class");
|
||||||
|
if(f.exists() && !f.isDirectory()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
compiler.generateBytecode(rootDirectory + "de/test/output/");
|
||||||
|
f = new File(rootDirectory + "de/test/output/de/test/TestClass.class");
|
||||||
|
assertTrue(f.exists());
|
||||||
|
|
||||||
|
URLClassLoader loader = new URLClassLoader(new URL[]{new URL("file://" + rootDirectory + "de/test/output/")});
|
||||||
|
Class<?> classToTest = loader.loadClass("de.test.TestClass");
|
||||||
|
Object instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,73 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class CheckPackageFolder extends TestCase {
|
public class CheckPackageFolder extends TestCase {
|
||||||
|
|
||||||
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/de/test/";
|
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/de/test/";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCorrectFolder1File() throws IOException, ClassNotFoundException {
|
public void testCorrectFolder1FileWithWrongPackageName() throws IOException, ClassNotFoundException {
|
||||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"packageNameTestWrongPackage.jav"));
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"packageNameTestWrongPackage.jav"));
|
||||||
assertTrue(true); //Es ist erlaubt falsche package Namen zu verwenden. Warnung wäre optional
|
compiler.typeInference();
|
||||||
|
File f = new File(rootDirectory + "TestClass.class");
|
||||||
|
if(f.exists() && !f.isDirectory()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
compiler.generateBytecode();
|
||||||
|
f = new File(rootDirectory + "TestClass.class");
|
||||||
|
assertTrue(f.exists()); //Es ist erlaubt falsche package Namen zu verwenden. Warnung wäre optional
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCorrectFolder1File() throws IOException, ClassNotFoundException {
|
||||||
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"TestClass.jav"));
|
||||||
|
compiler.typeInference();
|
||||||
|
File f = new File(rootDirectory + "TestClass.class");
|
||||||
|
if(f.exists() && !f.isDirectory()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
compiler.generateBytecode();
|
||||||
|
f = new File(rootDirectory + "TestClass.class");
|
||||||
|
assertTrue(f.exists()); //Es ist erlaubt falsche package Namen zu verwenden. Warnung wäre optional
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCorrectFolder1FileAndOutputDirectory() throws IOException, ClassNotFoundException {
|
||||||
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"TestClass.jav"));
|
||||||
|
compiler.typeInference();
|
||||||
|
File f = new File(rootDirectory + "output/de/test/TestClass.class");
|
||||||
|
if(f.exists() && !f.isDirectory()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
compiler.generateBytecode(rootDirectory+"output/");
|
||||||
|
f = new File(rootDirectory + "output/de/test/TestClass.class");
|
||||||
|
assertTrue(f.exists()); //Es ist erlaubt falsche package Namen zu verwenden. Warnung wäre optional
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dieser Test wird übersprungen, da der Bytecode-Generator nicht mit zwei Eingabedateien gleichzeitig umgehen kann
|
||||||
|
@Test
|
||||||
|
public void testCorrectFolder2Files() throws IOException, ClassNotFoundException {
|
||||||
|
JavaTXCompiler compiler = new JavaTXCompiler(Arrays.asList(
|
||||||
|
new File(rootDirectory+"subpackage1/Test1.jav"),
|
||||||
|
new File(rootDirectory+"subpackage2/Test2.jav")
|
||||||
|
));
|
||||||
|
compiler.typeInference();
|
||||||
|
File f = new File(rootDirectory + "subpackage1/Test1.class");
|
||||||
|
if(f.exists() && !f.isDirectory()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
File f2 = new File(rootDirectory + "subpackage2/Test2.class");
|
||||||
|
if(f.exists() && !f.isDirectory()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
compiler.generateBytecode();
|
||||||
|
f = new File(rootDirectory + "subpackage1/Test1.class");
|
||||||
|
f2 = new File(rootDirectory + "subpackage2/Test2.class");
|
||||||
|
assertTrue(f.exists());
|
||||||
|
assertTrue(f2.exists());
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
86
src/test/java/packages/ImportTest.java
Normal file
86
src/test/java/packages/ImportTest.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package packages;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class ImportTest extends TestCase {
|
||||||
|
|
||||||
|
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/de/test/";
|
||||||
|
|
||||||
|
|
||||||
|
public ImportTest() throws ClassNotFoundException, IOException {
|
||||||
|
/*
|
||||||
|
Generate ToImport class in rootDirectory and in output-Directory
|
||||||
|
*/
|
||||||
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"ToImport.jav"));
|
||||||
|
compiler.typeInference();
|
||||||
|
compiler.generateBytecode(rootDirectory + "output/");
|
||||||
|
File f = new File(rootDirectory + "output/de/test/ToImport.class");
|
||||||
|
assertTrue(f.exists());
|
||||||
|
|
||||||
|
compiler = new JavaTXCompiler(new File(rootDirectory+"subpackage1/ToImport2.jav"));
|
||||||
|
compiler.typeInference();
|
||||||
|
compiler.generateBytecode(rootDirectory + "output/");
|
||||||
|
f = new File(rootDirectory + "output/de/test/subpackage1/ToImport2.class");
|
||||||
|
assertTrue(f.exists());
|
||||||
|
|
||||||
|
compiler = new JavaTXCompiler(new File(rootDirectory+"subpackage2/ToImport3.jav"));
|
||||||
|
compiler.typeInference();
|
||||||
|
compiler.generateBytecode(rootDirectory + "output/");
|
||||||
|
f = new File(rootDirectory + "output/de/test/subpackage2/ToImport3.class");
|
||||||
|
assertTrue(f.exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetPackageNameInBytecodeAndOutputFolder() throws IOException, ClassNotFoundException {
|
||||||
|
JavaTXCompiler compiler = new JavaTXCompiler(
|
||||||
|
Lists.newArrayList(new File(rootDirectory+"ImportTest.jav")),
|
||||||
|
Lists.newArrayList(new URL("file://"+rootDirectory+"output/")));
|
||||||
|
compiler.typeInference();
|
||||||
|
File f = new File(rootDirectory + "output/de/test/ImportTest.class");
|
||||||
|
if(f.exists() && !f.isDirectory()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
compiler.generateBytecode(rootDirectory + "output/");
|
||||||
|
f = new File(rootDirectory + "output/de/test/ImportTest.class");
|
||||||
|
assertTrue(f.exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetPackageNameInBytecodeAndStandardOutputFolder() throws IOException, ClassNotFoundException {
|
||||||
|
JavaTXCompiler compiler = new JavaTXCompiler(
|
||||||
|
Lists.newArrayList(new File(rootDirectory+"ImportTest.jav")),
|
||||||
|
Lists.newArrayList(new URL("file://"+rootDirectory+"output/")));
|
||||||
|
compiler.typeInference();
|
||||||
|
File f = new File(rootDirectory + "ImportTest.class");
|
||||||
|
if(f.exists() && !f.isDirectory()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
compiler.generateBytecode(null);
|
||||||
|
f = new File(rootDirectory + "ImportTest.class");
|
||||||
|
assertTrue(f.exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testImportTwoClasses() throws IOException, ClassNotFoundException {
|
||||||
|
JavaTXCompiler compiler = new JavaTXCompiler(
|
||||||
|
Lists.newArrayList(new File(rootDirectory+"ImportTest2.jav")),
|
||||||
|
Lists.newArrayList(new URL("file://"+rootDirectory+"output/")));
|
||||||
|
compiler.typeInference();
|
||||||
|
File f = new File(rootDirectory + "ImportTest2.class");
|
||||||
|
if(f.exists() && !f.isDirectory()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
compiler.generateBytecode(null);
|
||||||
|
f = new File(rootDirectory + "ImportTest2.class");
|
||||||
|
assertTrue(f.exists());
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,7 @@ public class ParsePackageName {
|
|||||||
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/de/test/";
|
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/de/test/";
|
||||||
@Test
|
@Test
|
||||||
public void parsePackage() throws IOException, ClassNotFoundException {
|
public void parsePackage() throws IOException, ClassNotFoundException {
|
||||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"packageNameTest.jav"));
|
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"TestClass.jav"));
|
||||||
for(File f : compiler.sourceFiles.keySet()){
|
for(File f : compiler.sourceFiles.keySet()){
|
||||||
SourceFile sf = compiler.sourceFiles.get(f);
|
SourceFile sf = compiler.sourceFiles.get(f);
|
||||||
assert sf.getPkgName().equals("de.test");
|
assert sf.getPkgName().equals("de.test");
|
||||||
|
@ -28,6 +28,10 @@ public class JavaTXCompilerTest {
|
|||||||
execute(new File(rootDirectory+"fc.jav"));
|
execute(new File(rootDirectory+"fc.jav"));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
|
public void importTest() throws IOException, ClassNotFoundException {
|
||||||
|
execute(new File(rootDirectory+"Import.jav"));
|
||||||
|
}
|
||||||
|
@Test
|
||||||
public void lambda() throws IOException, ClassNotFoundException {
|
public void lambda() throws IOException, ClassNotFoundException {
|
||||||
execute(new File(rootDirectory+"Lambda.jav"));
|
execute(new File(rootDirectory+"Lambda.jav"));
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import java.util.Vector;
|
|||||||
|
|
||||||
class Import {
|
class Import {
|
||||||
void methode(){
|
void methode(){
|
||||||
Vector v;
|
var v;
|
||||||
v.add(v);
|
v.add(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package de.test;
|
||||||
|
|
||||||
|
import de.test.ToImport;
|
||||||
|
|
||||||
|
class ImportTest{
|
||||||
|
void methode(){
|
||||||
|
new ToImport();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package de.test;
|
||||||
|
|
||||||
|
import de.test.subpackage1.ToImport2;
|
||||||
|
import de.test.subpackage2.ToImport3;
|
||||||
|
|
||||||
|
class ImportTest2{
|
||||||
|
void methode(){
|
||||||
|
new ToImport2().m1();
|
||||||
|
new ToImport3().m2();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
package de.test;
|
||||||
|
|
||||||
|
public class TestClass{}
|
@ -1,3 +1,4 @@
|
|||||||
package de.test;
|
package de.test;
|
||||||
|
|
||||||
class TestClass{}
|
class ToImport{
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package de.test.subpackage1;
|
||||||
|
|
||||||
|
class Test1{
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package de.test.subpackage1;
|
||||||
|
|
||||||
|
class ToImport2{
|
||||||
|
void m1(){}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package de.test.subpackage2;
|
||||||
|
|
||||||
|
class Test2{
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package de.test.subpackage2;
|
||||||
|
|
||||||
|
class ToImport3{
|
||||||
|
void m2(){}
|
||||||
|
}
|
35
vorgehen.md
35
vorgehen.md
@ -15,10 +15,13 @@
|
|||||||
* Java kompiliert in den gleichen Ordner wie die source file
|
* Java kompiliert in den gleichen Ordner wie die source file
|
||||||
* Java erhält eine liste von Source Files, die es kompilieren soll
|
* Java erhält eine liste von Source Files, die es kompilieren soll
|
||||||
* anhand von deren Standort lassen sich relativ die Position von kompilierten Class-files bestimmen
|
* anhand von deren Standort lassen sich relativ die Position von kompilierten Class-files bestimmen
|
||||||
|
* macht der javac Compiler allerdings nicht
|
||||||
|
* er nimmt sein Running Directory als classPath standardmäßig, falls keiner angegeben
|
||||||
|
* javac geht davon aus, dass CP richtig gesetzt wird, oder javac im Source-Root ausgeführt wird
|
||||||
|
|
||||||
* -cp path or -classpath path
|
* -cp path or -classpath path
|
||||||
Specifies where to find user class files, and (optionally) annotation processors and source files. This class path overrides the user class path in the CLASSPATH environment variable. If neither CLASSPATH, -cp nor -classpath is specified, then the
|
Specifies where to find user class files, and (optionally) annotation processors and source files. This class path overrides the user class path in the CLASSPATH environment variable. If neither CLASSPATH, -cp nor -classpath is specified, then the
|
||||||
user class path is the current directory. See Setting the Class Path.
|
user class path is the current directory. See Setting the Class Path.
|
||||||
|
|
||||||
* Compiler kontrolliert nicht, ob package im korrekten Ordner ist
|
* Compiler kontrolliert nicht, ob package im korrekten Ordner ist
|
||||||
* auch keine Warnung
|
* auch keine Warnung
|
||||||
@ -28,3 +31,33 @@
|
|||||||
* Optional
|
* Optional
|
||||||
* damit lässt sich ein andere ort zur Ausgabe der Class-files bestimmen
|
* damit lässt sich ein andere ort zur Ausgabe der Class-files bestimmen
|
||||||
|
|
||||||
|
# Tasks
|
||||||
|
## Class files in richtigen Ordner legen ##
|
||||||
|
* Wenn Pfad übergeben, dann in Pfad + packageName
|
||||||
|
* Ohne Pfad, direkt neben die Source File legen
|
||||||
|
* wenn Source File nicht in richtigem Ordner -> Warnung ausgeben
|
||||||
|
|
||||||
|
### Stand ###
|
||||||
|
* Beinahe abgeschlossen
|
||||||
|
* TODO: Tests schreiben
|
||||||
|
|
||||||
|
## Class files einlesen
|
||||||
|
* Wenn Classpath übergeben
|
||||||
|
* Suchen in Classpath + packageName
|
||||||
|
* Müsste eigentlich UTLClassLoader automatisch machen (also packageNamen anfügen)
|
||||||
|
* Wenn nichts übergeben
|
||||||
|
* dann currentDirectory + packageName
|
||||||
|
* Für die Tests muss korrekter Classpath gesetzt werden
|
||||||
|
|
||||||
|
### Stand ###
|
||||||
|
TODO:
|
||||||
|
* es muss überall wo im Quellcode ClassLoader.getSystemClassLoader() oder ein andere Classloader verwendet wird,
|
||||||
|
* dieser ausgetauscht werden mit dem classLaoder, welcher bei der Instanzierung von JavaTXCompiler erstellt wird
|
||||||
|
|
||||||
|
## Class files mit packageNamen versehen
|
||||||
|
* In die Class file muss noch der korrekte name geschrieben werden
|
||||||
|
* kann möglicherweise ASM
|
||||||
|
* Kann ASM mittesl `cw.visit("name/mit/slashe/Getrennt"..`
|
||||||
|
* wurde bereits erledigt -> TODO: Testen
|
||||||
|
|
||||||
|
## Console Interface um Parameter -classpath und -output directory erweitern
|
||||||
|
Loading…
Reference in New Issue
Block a user