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;
|
ClassLoader cLoader2;
|
||||||
java.lang.reflect.Method methodRefl = null;
|
java.lang.reflect.Method methodRefl = null;
|
||||||
String clazz = receiverName.replace("/", ".");
|
String clazz = receiverName.replace("/", ".");
|
||||||
|
String methCallType = resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||||
|
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("<"));
|
||||||
@ -688,15 +689,15 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
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 {
|
// try {
|
||||||
cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)});
|
// cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)});
|
||||||
java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
|
// java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
|
||||||
System.out.println("Methods of " + receiverName + " ");
|
// System.out.println("Methods of " + receiverName + " ");
|
||||||
for(int i = 0; i<methods.length; i++) {
|
// for(int i = 0; i<methods.length; i++) {
|
||||||
System.out.println(methods[i]);
|
// System.out.println(methods[i]);
|
||||||
}
|
// }
|
||||||
methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methods);
|
// methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methCallType, typesOfParams,methods);
|
||||||
}catch (Exception e2) {
|
// }catch (Exception e2) {
|
||||||
String superClass = "";
|
String superClass = "";
|
||||||
// TODO: Test SubMatrix.jav
|
// TODO: Test SubMatrix.jav
|
||||||
while(true) {
|
while(true) {
|
||||||
@ -732,9 +733,23 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
continue;
|
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);
|
methodCall.receiver.accept(this);
|
||||||
|
|
||||||
System.out.println("Methodcall type : " + resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()));
|
System.out.println("Methodcall type : " + resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()));
|
||||||
@ -795,9 +810,19 @@ 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 name name of a method
|
||||||
* @param i number of parameters
|
* @param i number of parameters
|
||||||
* @param methods all methods of a class
|
* @param methods all methods of a class
|
||||||
* @return the method in the class file which its name equals the given methode name
|
* @return the method in the class file which its name equals the given methode name
|
||||||
*/
|
*/
|
||||||
@ -809,6 +834,38 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
}
|
}
|
||||||
return null;
|
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) {
|
private String getMethodDesc(java.lang.reflect.Method methodRefl) {
|
||||||
StringBuilder sb = new StringBuilder("(");
|
StringBuilder sb = new StringBuilder("(");
|
||||||
|
Loading…
Reference in New Issue
Block a user