Wenn ein Attribut mehrere Loesungen bekommt, wird die Bytecodeerzeugung

abgebrochen und ensprechende Exception geworfen.
This commit is contained in:
Fayez Abu Alia 2019-04-26 10:27:15 +02:00
parent 5950fcc0a9
commit 9ffc74467b
4 changed files with 39 additions and 29 deletions

View File

@ -17,6 +17,7 @@ import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
@ -506,7 +507,7 @@ public class BytecodeGen implements ASTVisitor {
String nameAndDesc = field.getName() + "%%" + des;
if(fieldNameAndParamsT.contains(nameAndDesc))
return;
throw new BytecodeGeneratorError("Bytecode generation aborted due to duplicate field name&signature");
fieldNameAndParamsT.add(nameAndDesc);

View File

@ -781,7 +781,7 @@ public class BytecodeGenMethod implements StatementVisitor {
MethodCallHelper helper = new MethodCallHelper(methodCall, sf, resultSet);
boolean isCreated = false;
// if(!receiverName.equals(className)) {
ClassLoader cLoader = ClassLoader.getSystemClassLoader();
// This will be used if the class is not standard class (not in API)
ClassLoader cLoader2;
@ -798,15 +798,6 @@ public class BytecodeGenMethod implements StatementVisitor {
methodRefl = getMethod(methodCall.name, methodCall.arglist.getArguments().size(), methods);
} catch (Exception e) {
// try {
// cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)});
// java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
// System.out.println("Methods of " + receiverName + " ");
// for(int i = 0; i<methods.length; i++) {
// System.out.println(methods[i]);
// }
// methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methCallType, typesOfParams,methods);
// }catch (Exception e2) {
String superClass = "";
// TODO: Test SubMatrix.jav
while(true) {
@ -838,7 +829,6 @@ public class BytecodeGenMethod implements StatementVisitor {
}
}
// }
}
@ -866,7 +856,6 @@ public class BytecodeGenMethod implements StatementVisitor {
}
}
// }
methodCall.receiver.accept(this);

View File

@ -0,0 +1,19 @@
/**
*
*/
package de.dhbwstuttgart.bytecode.Exception;
/**
* @author fayez
*
*/
public class BytecodeGeneratorError extends RuntimeException {
/**
* @param message
*/
public BytecodeGeneratorError(String message) {
super(message);
}
}

View File

@ -3,6 +3,7 @@ package de.dhbwstuttgart.core;
import de.dhbwstuttgart.bytecode.BytecodeGen;
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
import de.dhbwstuttgart.bytecode.utilities.SimplifyResult;
import de.dhbwstuttgart.environment.CompilationEnvironment;
import de.dhbwstuttgart.parser.JavaTXParser;
@ -651,7 +652,7 @@ public class JavaTXCompiler {
return ret;
}
// um pfad erweitern
public void generateBytecode(String path) throws ClassNotFoundException, IOException {
public void generateBytecode(String path) throws ClassNotFoundException, IOException, BytecodeGeneratorError {
for(File f : sourceFiles.keySet()) {
HashMap<String,byte[]> classFiles = new HashMap<>();
SourceFile sf = sourceFiles.get(f);