forked from JavaTX/JavaCompilerCore
Wenn ein Attribut mehrere Loesungen bekommt, wird die Bytecodeerzeugung
abgebrochen und ensprechende Exception geworfen.
This commit is contained in:
parent
5950fcc0a9
commit
9ffc74467b
@ -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);
|
||||
|
||||
|
@ -781,32 +781,23 @@ 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;
|
||||
|
||||
String methCallType = resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
String[] typesOfParams = getTypes(methodCall.arglist.getArguments());
|
||||
try {
|
||||
if(receiverName.contains("<")) {
|
||||
clazz = clazz.substring(0, receiverName.indexOf("<"));
|
||||
}
|
||||
|
||||
java.lang.reflect.Method[] methods = cLoader.loadClass(clazz).getMethods();
|
||||
System.out.println("Methods of " + receiverName + " ");
|
||||
methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methods);
|
||||
|
||||
|
||||
ClassLoader cLoader = ClassLoader.getSystemClassLoader();
|
||||
// This will be used if the class is not standard class (not in API)
|
||||
ClassLoader cLoader2;
|
||||
|
||||
String methCallType = resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
String[] typesOfParams = getTypes(methodCall.arglist.getArguments());
|
||||
try {
|
||||
if (receiverName.contains("<")) {
|
||||
clazz = clazz.substring(0, receiverName.indexOf("<"));
|
||||
}
|
||||
|
||||
java.lang.reflect.Method[] methods = cLoader.loadClass(clazz).getMethods();
|
||||
System.out.println("Methods of " + receiverName + " ");
|
||||
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);
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package de.dhbwstuttgart.bytecode.Exception;
|
||||
|
||||
/**
|
||||
* @author fayez
|
||||
*
|
||||
*/
|
||||
public class BytecodeGeneratorError extends RuntimeException {
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public BytecodeGeneratorError(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user