Bug 166 - Wenn Fehlermeldung "Bytecode generation aborted due to
duplicate field name&signature" ... dann die bereits (on the fly) erzeugten Bytecode-Files wieder löschen
This commit is contained in:
parent
48a12fdc57
commit
b025d376fd
@ -18,7 +18,7 @@
|
|||||||
<classpathentry kind="lib" path="lib/icu4j.jar"/>
|
<classpathentry kind="lib" path="lib/icu4j.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/j2objc-annotations.jar"/>
|
<classpathentry kind="lib" path="lib/j2objc-annotations.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/javassist.jar"/>
|
<classpathentry kind="lib" path="lib/javassist.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/JavaTXcompiler.jar"/>
|
<classpathentry kind="lib" path="lib/JavaTXcompiler.jar" sourcepath="/JavaTXcompiler/src/main/java"/>
|
||||||
<classpathentry kind="lib" path="lib/javax.json.jar"/>
|
<classpathentry kind="lib" path="lib/javax.json.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/jsr305.jar"/>
|
<classpathentry kind="lib" path="lib/jsr305.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/listenablefuture.jar"/>
|
<classpathentry kind="lib" path="lib/listenablefuture.jar"/>
|
||||||
|
@ -30,6 +30,7 @@ import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
|||||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
@ -103,6 +104,7 @@ public class Typinferenz {
|
|||||||
} catch (BytecodeGeneratorError | IOException ex) {
|
} catch (BytecodeGeneratorError | IOException ex) {
|
||||||
ErrorMarker toAdd = new ErrorMarker(ex.getMessage(), new CodePoint(sf.getOffset()));
|
ErrorMarker toAdd = new ErrorMarker(ex.getMessage(), new CodePoint(sf.getOffset()));
|
||||||
ret.add(toAdd);
|
ret.add(toAdd);
|
||||||
|
deleteClassFileIfExists(outputDirectory, sf.getClasses());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,25 +186,11 @@ public class Typinferenz {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeClassFile(String outputDirectory, HashMap<String, byte[]> classFiles) {
|
public void deleteClassFileIfExists(String outputDirectory, List<ClassOrInterface> clazzes) {
|
||||||
FileOutputStream output;
|
for (ClassOrInterface clazz : clazzes) {
|
||||||
for (String name : classFiles.keySet()) {
|
File toDelete = new File(outputDirectory + clazz.getClassName() + ".class");
|
||||||
byte[] bytecode = classFiles.get(name);
|
toDelete.delete();
|
||||||
try {
|
|
||||||
System.out.println("generating" + name + ".class file");
|
|
||||||
// output = new FileOutputStream(new File(System.getProperty("user.dir") +
|
|
||||||
// "/testBytecode/generatedBC/" +name+".class"));
|
|
||||||
output = new FileOutputStream(new File(outputDirectory + name + ".class"));
|
|
||||||
output.write(bytecode);
|
|
||||||
output.close();
|
|
||||||
System.out.println(name + ".class file generated");
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceFile getSourceFile() {
|
public SourceFile getSourceFile() {
|
||||||
|
Loading…
Reference in New Issue
Block a user