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) {