From d9b7a87784376d3b307217f8e69946503113ba22 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 12 Dec 2013 16:35:12 +0400 Subject: [PATCH] Fixes dependency checker bugs --- .../teavm/classlib/java/lang/ObjectNativeGenerator.java | 9 +++++---- .../org/teavm/dependency/DependencyGraphBuilder.java | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/ObjectNativeGenerator.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/ObjectNativeGenerator.java index 5d5ce32bb..3bf139735 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/ObjectNativeGenerator.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/ObjectNativeGenerator.java @@ -43,7 +43,7 @@ public class ObjectNativeGenerator implements Generator, DependencyPlugin { achieveClone(checker, method); break; case "getClass": - achieveGetClass(checker); + achieveGetClass(checker, method); break; case "wrap": achieveWrap(checker, method); @@ -60,11 +60,12 @@ public class ObjectNativeGenerator implements Generator, DependencyPlugin { 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"; - MethodReference method = new MethodReference(classClass, new MethodDescriptor("createNew", + MethodReference initMethod = new MethodReference(classClass, new MethodDescriptor("createNew", ValueType.object(classClass))); - checker.addEntryPoint(method); + checker.addEntryPoint(initMethod); + checker.attachMethodGraph(method).getResultNode().propagate("java.lang.Class"); } private void generateHashCode(GeneratorContext context, SourceWriter writer) { diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java index 4104a6dbf..eeab37d2d 100644 --- a/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java +++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java @@ -75,6 +75,9 @@ class DependencyGraphBuilder { System.out.println("Virtual call of " + methodDesc + " detected on " + node.getTag() + ". " + "Target class is " + className); } + if (className.startsWith("[")) { + className = "java.lang.Object"; + } MethodReference methodRef = new MethodReference(className, methodDesc); MethodHolder method = findMethod(methodRef, checker.getClassSource()); if (method == null) {