ClassLoader austauschen gegen den Classloader, welcher in JavaCompilerCore erstellt wird
This commit is contained in:
parent
3e67da6e34
commit
0378c17e7d
@ -270,7 +270,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.getSystemClassLoader());
|
||||||
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);
|
||||||
@ -351,7 +351,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.getSystemClassLoader());
|
||||||
|
|
||||||
mv.visitMaxs(0, 0);
|
mv.visitMaxs(0, 0);
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
|
@ -77,11 +77,13 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
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(JavaClassName 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<JavaClassName, 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;
|
||||||
@ -99,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(JavaClassName 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<JavaClassName, 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;
|
||||||
@ -125,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(JavaClassName 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<JavaClassName, 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;
|
||||||
@ -145,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;
|
||||||
@ -637,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();
|
||||||
@ -757,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;
|
||||||
|
|
||||||
|
@ -98,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);
|
||||||
@ -135,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);
|
||||||
}
|
}
|
||||||
@ -304,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);
|
||||||
@ -472,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);
|
||||||
|
|
||||||
|
@ -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)) {
|
||||||
|
@ -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);
|
||||||
|
@ -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){
|
||||||
|
@ -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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,3 +59,5 @@ TODO:
|
|||||||
* kann möglicherweise ASM
|
* kann möglicherweise ASM
|
||||||
* Kann ASM mittesl `cw.visit("name/mit/slashe/Getrennt"..`
|
* Kann ASM mittesl `cw.visit("name/mit/slashe/Getrennt"..`
|
||||||
* wurde bereits erledigt -> TODO: Testen
|
* wurde bereits erledigt -> TODO: Testen
|
||||||
|
|
||||||
|
## Console Interface um Parameter -classpath und -output directory erweitern
|
||||||
|
Loading…
Reference in New Issue
Block a user