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.Opcodes;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
@ -506,7 +507,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
String nameAndDesc = field.getName() + "%%" + des;
|
String nameAndDesc = field.getName() + "%%" + des;
|
||||||
|
|
||||||
if(fieldNameAndParamsT.contains(nameAndDesc))
|
if(fieldNameAndParamsT.contains(nameAndDesc))
|
||||||
return;
|
throw new BytecodeGeneratorError("Bytecode generation aborted due to duplicate field name&signature");
|
||||||
|
|
||||||
fieldNameAndParamsT.add(nameAndDesc);
|
fieldNameAndParamsT.add(nameAndDesc);
|
||||||
|
|
||||||
|
@ -781,32 +781,23 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
MethodCallHelper helper = new MethodCallHelper(methodCall, sf, resultSet);
|
MethodCallHelper helper = new MethodCallHelper(methodCall, sf, resultSet);
|
||||||
|
|
||||||
boolean isCreated = false;
|
boolean isCreated = false;
|
||||||
// if(!receiverName.equals(className)) {
|
|
||||||
ClassLoader cLoader = ClassLoader.getSystemClassLoader();
|
ClassLoader cLoader = ClassLoader.getSystemClassLoader();
|
||||||
// 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;
|
||||||
|
|
||||||
String methCallType = resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
String methCallType = resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||||
String[] typesOfParams = getTypes(methodCall.arglist.getArguments());
|
String[] typesOfParams = getTypes(methodCall.arglist.getArguments());
|
||||||
try {
|
try {
|
||||||
if(receiverName.contains("<")) {
|
if (receiverName.contains("<")) {
|
||||||
clazz = clazz.substring(0, receiverName.indexOf("<"));
|
clazz = clazz.substring(0, receiverName.indexOf("<"));
|
||||||
}
|
}
|
||||||
|
|
||||||
java.lang.reflect.Method[] methods = cLoader.loadClass(clazz).getMethods();
|
java.lang.reflect.Method[] methods = cLoader.loadClass(clazz).getMethods();
|
||||||
System.out.println("Methods of " + receiverName + " ");
|
System.out.println("Methods of " + receiverName + " ");
|
||||||
methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methods);
|
methodRefl = getMethod(methodCall.name, methodCall.arglist.getArguments().size(), methods);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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 = "";
|
String superClass = "";
|
||||||
// TODO: Test SubMatrix.jav
|
// TODO: Test SubMatrix.jav
|
||||||
while(true) {
|
while(true) {
|
||||||
@ -838,7 +829,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,7 +856,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
methodCall.receiver.accept(this);
|
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.BytecodeGen;
|
||||||
|
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.SimplifyResult;
|
import de.dhbwstuttgart.bytecode.utilities.SimplifyResult;
|
||||||
import de.dhbwstuttgart.environment.CompilationEnvironment;
|
import de.dhbwstuttgart.environment.CompilationEnvironment;
|
||||||
import de.dhbwstuttgart.parser.JavaTXParser;
|
import de.dhbwstuttgart.parser.JavaTXParser;
|
||||||
@ -651,7 +652,7 @@ public class JavaTXCompiler {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
// um pfad erweitern
|
// 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()) {
|
for(File f : sourceFiles.keySet()) {
|
||||||
HashMap<String,byte[]> classFiles = new HashMap<>();
|
HashMap<String,byte[]> classFiles = new HashMap<>();
|
||||||
SourceFile sf = sourceFiles.get(f);
|
SourceFile sf = sourceFiles.get(f);
|
||||||
|
Loading…
Reference in New Issue
Block a user