From 9e9f7dbee215c9f4b8fe263da38f2a2e712211a8 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 4 Aug 2015 17:15:39 +0300 Subject: [PATCH] Fix bug in timer support in html4j. Remove obsolete code. Conflicts: teavm-html4j/src/main/java/org/teavm/html4j/HTML4JPlugin.java --- .../org/teavm/html4j/EntryPointGenerator.java | 88 ------------------- .../java/org/teavm/html4j/HTML4JPlugin.java | 6 -- .../main/java/org/teavm/html4j/JCLHacks.java | 16 ---- 3 files changed, 110 deletions(-) delete mode 100644 teavm-html4j/src/main/java/org/teavm/html4j/EntryPointGenerator.java diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/EntryPointGenerator.java b/teavm-html4j/src/main/java/org/teavm/html4j/EntryPointGenerator.java deleted file mode 100644 index c91558fc3..000000000 --- a/teavm-html4j/src/main/java/org/teavm/html4j/EntryPointGenerator.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2014 Alexey Andreev. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.teavm.html4j; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import org.teavm.codegen.SourceWriter; -import org.teavm.dependency.*; -import org.teavm.javascript.Renderer; -import org.teavm.javascript.RenderingContext; -import org.teavm.model.CallLocation; -import org.teavm.vm.BuildTarget; -import org.teavm.vm.spi.AbstractRendererListener; - -/** - * - * @author Alexey Andreev - */ -public class EntryPointGenerator extends AbstractRendererListener implements DependencyListener { - private List classesToLoad = new ArrayList<>(); - private SourceWriter writer; - - public EntryPointGenerator(String classesToLoad) { - for (String className : classesToLoad.split(",| |;")) { - className = className.trim(); - if (!className.isEmpty()) { - this.classesToLoad.add(className); - } - } - } - - @Override - public void begin(RenderingContext context, BuildTarget buildTarget) throws IOException { - writer = context.getWriter(); - } - - @Override - public void complete() throws IOException { - if (classesToLoad.isEmpty()) { - return; - } - writer.append("function VM() {").softNewLine(); - writer.append("}").newLine(); - writer.append("VM.prototype.loadClass = function(className) {").softNewLine().indent(); - writer.append("switch (className) {").indent().softNewLine(); - for (String className : classesToLoad) { - writer.append("case \"").append(Renderer.escapeString(className)).append("\": "); - writer.appendClass(className).append(".$clinit(); break;").softNewLine(); - } - writer.append("default: throw \"Can't load class \" + className;").softNewLine(); - writer.outdent().append("}").softNewLine(); - writer.outdent().append("}").newLine(); - writer.append("function bck2brwsr() { return new VM(); }").newLine(); - } - - @Override - public void started(DependencyAgent agent) { - for (String className : classesToLoad) { - agent.linkClass(className, null).initClass(null); - } - } - - @Override - public void classReached(DependencyAgent agent, String className, CallLocation location) { - } - - @Override - public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) { - } - - @Override - public void fieldReached(DependencyAgent agent, FieldDependency field, CallLocation location) { - } -} diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/HTML4JPlugin.java b/teavm-html4j/src/main/java/org/teavm/html4j/HTML4JPlugin.java index 6a6dad24d..1530d308d 100644 --- a/teavm-html4j/src/main/java/org/teavm/html4j/HTML4JPlugin.java +++ b/teavm-html4j/src/main/java/org/teavm/html4j/HTML4JPlugin.java @@ -15,8 +15,6 @@ */ package org.teavm.html4j; -import org.teavm.dependency.DependencyListener; -import org.teavm.vm.spi.RendererListener; import org.teavm.vm.spi.TeaVMHost; import org.teavm.vm.spi.TeaVMPlugin; @@ -31,9 +29,5 @@ public class HTML4JPlugin implements TeaVMPlugin { host.add(new JavaScriptBodyTransformer()); host.add(new JCLHacks()); host.add(new JavaScriptResourceInterceptor()); - EntryPointGenerator entryPointGen = new EntryPointGenerator(host.getProperties() - .getProperty("html4j.entryPoints", "")); - host.add((DependencyListener) entryPointGen); - host.add((RendererListener) entryPointGen); } } diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/JCLHacks.java b/teavm-html4j/src/main/java/org/teavm/html4j/JCLHacks.java index c73932912..61a4fa0ed 100644 --- a/teavm-html4j/src/main/java/org/teavm/html4j/JCLHacks.java +++ b/teavm-html4j/src/main/java/org/teavm/html4j/JCLHacks.java @@ -34,10 +34,8 @@ public class JCLHacks implements ClassHolderTransformer { private void installThreadMethods(ClassHolder cls) { cls.addMethod(createMethodThrowingSecurityException(new MethodDescriptor("setName", String.class, void.class), false)); - cls.addMethod(createMethodThrowingSecurityException(new MethodDescriptor("start", void.class), false)); cls.addMethod(createMethodThrowingSecurityException(new MethodDescriptor("setDaemon", boolean.class, void.class), false)); - cls.addMethod(createThreadSleep()); } private MethodHolder createMethodThrowingSecurityException(MethodDescriptor desc, boolean staticMethod) { @@ -71,18 +69,4 @@ public class JCLHacks implements ClassHolderTransformer { method.setProgram(program); return method; } - - private MethodHolder createThreadSleep() { - MethodHolder method = new MethodHolder("sleep", ValueType.LONG, ValueType.VOID); - Program program = new Program(); - program.createVariable(); - program.createVariable(); - BasicBlock block = program.createBasicBlock(); - ExitInstruction exit = new ExitInstruction(); - block.getInstructions().add(exit); - method.setProgram(program); - method.setLevel(AccessLevel.PUBLIC); - method.getModifiers().add(ElementModifier.STATIC); - return method; - } }