From c9c9c15dfe4c229d19e9b47ff776dae366410896 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 11 Dec 2018 23:47:47 +0300 Subject: [PATCH] Fix Class.initialize. Fix html4j tests --- .../java/lang/ClassDependencyListener.java | 9 ++++++- .../java/org/teavm/dependency/TypeSet.java | 2 +- html4j/pom.xml | 27 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/ClassDependencyListener.java b/classlib/src/main/java/org/teavm/classlib/java/lang/ClassDependencyListener.java index 19ab518da..3731d985f 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/ClassDependencyListener.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/ClassDependencyListener.java @@ -15,16 +15,23 @@ */ package org.teavm.classlib.java.lang; +import org.teavm.dependency.ClassDependency; import org.teavm.dependency.DependencyAgent; import org.teavm.dependency.DependencyPlugin; import org.teavm.dependency.MethodDependency; +import org.teavm.model.CallLocation; public class ClassDependencyListener implements DependencyPlugin { @Override public void methodReached(DependencyAgent agent, MethodDependency method) { switch (method.getMethod().getName()) { case "initialize": - method.getVariable(0).getClassValueNode().addConsumer(type -> agent.linkClass(type.getName())); + method.getVariable(0).getClassValueNode().addConsumer(type -> { + ClassDependency classDep = agent.linkClass(type.getName()); + if (classDep != null) { + classDep.initClass(new CallLocation(method.getReference())); + } + }); break; case "getSimpleNameCacheLowLevel": method.getResult().propagate(agent.getType("java.lang.String")); diff --git a/core/src/main/java/org/teavm/dependency/TypeSet.java b/core/src/main/java/org/teavm/dependency/TypeSet.java index b75588620..200331dae 100644 --- a/core/src/main/java/org/teavm/dependency/TypeSet.java +++ b/core/src/main/java/org/teavm/dependency/TypeSet.java @@ -71,7 +71,7 @@ class TypeSet { DependencyType[] getTypes() { if (this.types != null) { - DependencyType[] types = new DependencyType[typesCount]; + DependencyType[] types = new DependencyType[this.types.cardinality()]; int j = 0; for (int index = this.types.nextSetBit(0); index >= 0; index = this.types.nextSetBit(index + 1)) { DependencyType type = dependencyAnalyzer.types.get(index); diff --git a/html4j/pom.xml b/html4j/pom.xml index 0e5d9778b..a3e66bb2d 100644 --- a/html4j/pom.xml +++ b/html4j/pom.xml @@ -63,6 +63,33 @@ ${project.version} test + + + commons-io + commons-io + true + + + org.ow2.asm + asm-commons + true + + + org.ow2.asm + asm-util + true + + + com.carrotsearch + hppc + 0.7.3 + true + + + org.mozilla + rhino + true +