forked from JavaTX/JavaCompilerCore
Bug 122 gefixt. MatrixTest und OLTest funktionieren
This commit is contained in:
parent
d27e0af57c
commit
0ceae1ebb7
@ -677,7 +677,8 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
ClassLoader cLoader2;
|
||||
java.lang.reflect.Method methodRefl = null;
|
||||
String clazz = receiverName.replace("/", ".");
|
||||
|
||||
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("<"));
|
||||
@ -688,15 +689,15 @@ 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(),methods);
|
||||
}catch (Exception e2) {
|
||||
// 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) {
|
||||
@ -732,8 +733,22 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
if(methodRefl == null) {
|
||||
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) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
methodCall.receiver.accept(this);
|
||||
|
||||
@ -795,7 +810,17 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
|
||||
}
|
||||
|
||||
private String[] getTypes(List<Expression> arguments) {
|
||||
String[] types = new String[arguments.size()];
|
||||
for(int i = 0; i<arguments.size(); ++i) {
|
||||
String t = getResolvedType(arguments.get(i).getType());
|
||||
types[i] = t;
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
* For API methods
|
||||
* @param name name of a method
|
||||
* @param i number of parameters
|
||||
* @param methods all methods of a class
|
||||
@ -810,6 +835,38 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name name of a method
|
||||
* @param i number of parameters
|
||||
* @param methCallType return type of method
|
||||
* @param typesOfParams
|
||||
* @param methods all methods of a class
|
||||
* @return the method in the class file which its name equals the given methode name
|
||||
*/
|
||||
private java.lang.reflect.Method getMethod(String name, int i, String methCallType, String[] typesOfParams, java.lang.reflect.Method[] methods) {
|
||||
// if(methCallType.equals("void")) {
|
||||
// methCallType = "V";
|
||||
// } else {
|
||||
// methCallType = "L"+methCallType+";";
|
||||
// }
|
||||
for(java.lang.reflect.Method m : methods) {
|
||||
if(name.equals(m.getName()) && i == m.getParameterCount() && methCallType.equals(m.getReturnType().getName().replace(".", "/"))) {
|
||||
boolean typesEqual = true;
|
||||
Class<?>[] pTypes = m.getParameterTypes();
|
||||
for(int j = 0; j<typesOfParams.length; ++j) {
|
||||
if(!typesOfParams[j].equals(pTypes[j])) {
|
||||
typesEqual = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(typesEqual)
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getMethodDesc(java.lang.reflect.Method methodRefl) {
|
||||
StringBuilder sb = new StringBuilder("(");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user