Fixes dependency checker bugs

This commit is contained in:
Alexey Andreev 2013-12-12 16:35:12 +04:00
parent 181e69f72d
commit d9b7a87784
2 changed files with 8 additions and 4 deletions

View File

@ -43,7 +43,7 @@ public class ObjectNativeGenerator implements Generator, DependencyPlugin {
achieveClone(checker, method); achieveClone(checker, method);
break; break;
case "getClass": case "getClass":
achieveGetClass(checker); achieveGetClass(checker, method);
break; break;
case "wrap": case "wrap":
achieveWrap(checker, method); achieveWrap(checker, method);
@ -60,11 +60,12 @@ public class ObjectNativeGenerator implements Generator, DependencyPlugin {
writer.append("return $rt_cls(").append(thisArg).append(".$class);").softNewLine(); writer.append("return $rt_cls(").append(thisArg).append(".$class);").softNewLine();
} }
private void achieveGetClass(DependencyChecker checker) { private void achieveGetClass(DependencyChecker checker, MethodReference method) {
String classClass = "java.lang.Class"; String classClass = "java.lang.Class";
MethodReference method = new MethodReference(classClass, new MethodDescriptor("createNew", MethodReference initMethod = new MethodReference(classClass, new MethodDescriptor("createNew",
ValueType.object(classClass))); ValueType.object(classClass)));
checker.addEntryPoint(method); checker.addEntryPoint(initMethod);
checker.attachMethodGraph(method).getResultNode().propagate("java.lang.Class");
} }
private void generateHashCode(GeneratorContext context, SourceWriter writer) { private void generateHashCode(GeneratorContext context, SourceWriter writer) {

View File

@ -75,6 +75,9 @@ class DependencyGraphBuilder {
System.out.println("Virtual call of " + methodDesc + " detected on " + node.getTag() + ". " + System.out.println("Virtual call of " + methodDesc + " detected on " + node.getTag() + ". " +
"Target class is " + className); "Target class is " + className);
} }
if (className.startsWith("[")) {
className = "java.lang.Object";
}
MethodReference methodRef = new MethodReference(className, methodDesc); MethodReference methodRef = new MethodReference(className, methodDesc);
MethodHolder method = findMethod(methodRef, checker.getClassSource()); MethodHolder method = findMethod(methodRef, checker.getClassSource());
if (method == null) { if (method == null) {