Fix Class.initialize. Fix html4j tests

This commit is contained in:
Alexey Andreev 2018-12-11 23:47:47 +03:00
parent d968b20e4c
commit c9c9c15dfe
3 changed files with 36 additions and 2 deletions

View File

@ -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"));

View File

@ -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);

View File

@ -63,6 +63,33 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>hppc</artifactId>
<version>0.7.3</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>