forked from JavaTX/JavaCompilerCore
Fix up bad error handling
This commit is contained in:
parent
3d2c699964
commit
9ad5b76542
@ -121,6 +121,7 @@ public class JavaTXCompiler {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var clazz = classLoader.loadClass(name.toString());
|
var clazz = classLoader.loadClass(name.toString());
|
||||||
|
if (clazz != null)
|
||||||
return ASTFactory.createClass(clazz);
|
return ASTFactory.createClass(clazz);
|
||||||
} catch (ClassNotFoundException ignored) {}
|
} catch (ClassNotFoundException ignored) {}
|
||||||
return null;
|
return null;
|
||||||
@ -418,7 +419,9 @@ public class JavaTXCompiler {
|
|||||||
final ConstraintSet<Pair> cons = getConstraints();
|
final ConstraintSet<Pair> cons = getConstraints();
|
||||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
Set<Set<UnifyPair>> results = new HashSet<>();
|
||||||
try {
|
try {
|
||||||
Writer logFile = log ? new FileWriter(new File(System.getProperty("user.dir") + "/logFiles/" + "log_" + sourceFiles.keySet().iterator().next().getName())) : new OutputStreamWriter(new NullOutputStream());
|
var logFolder = new File(System.getProperty("user.dir") + "/logFiles/");
|
||||||
|
if (log) logFolder.mkdirs();
|
||||||
|
Writer logFile = log ? new FileWriter(new File(logFolder, "log_" + sourceFiles.keySet().iterator().next().getName())) : new OutputStreamWriter(new NullOutputStream());
|
||||||
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses, logFile, classLoader);
|
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);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.factory;
|
package de.dhbwstuttgart.syntaxtree.factory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
@ -45,7 +46,7 @@ public class ASTFactory {
|
|||||||
try {
|
try {
|
||||||
var path = jreClass.getName().replace('.', '/') + ".class";
|
var path = jreClass.getName().replace('.', '/') + ".class";
|
||||||
var classLoader = jreClass.getClassLoader();
|
var classLoader = jreClass.getClassLoader();
|
||||||
if (classLoader != null) {
|
if (classLoader != null && new File(path).exists()) {
|
||||||
var bytes = IOUtils.toByteArray(Objects.requireNonNull(classLoader.getResourceAsStream(path)));
|
var bytes = IOUtils.toByteArray(Objects.requireNonNull(classLoader.getResourceAsStream(path)));
|
||||||
var classReader = new ClassReader(bytes);
|
var classReader = new ClassReader(bytes);
|
||||||
var classVisitor = new ClassVisitor(Opcodes.ASM7) {
|
var classVisitor = new ClassVisitor(Opcodes.ASM7) {
|
||||||
|
Loading…
Reference in New Issue
Block a user