diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSDependencyListener.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSDependencyListener.java index 78bdf59d1..56c054e95 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSDependencyListener.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSDependencyListener.java @@ -29,6 +29,7 @@ import org.teavm.model.AnnotationValue; import org.teavm.model.CallLocation; import org.teavm.model.ClassReader; import org.teavm.model.ClassReaderSource; +import org.teavm.model.ElementModifier; import org.teavm.model.FieldReader; import org.teavm.model.FieldReference; import org.teavm.model.MethodDescriptor; @@ -145,6 +146,9 @@ class JSDependencyListener extends AbstractDependencyListener { if (addInterface(exposedCls, iface)) { added = true; for (MethodReader method : iface.getMethods()) { + if (method.hasModifier(ElementModifier.STATIC)) { + continue; + } if (!exposedCls.inheritedMethods.containsKey(method.getDescriptor())) { String name = method.getName(); AnnotationReader methodAnnot = method.getAnnotations().get(JSMethod.class.getName()); diff --git a/samples/async/src/main/java/org/teavm/samples/async/AsyncProgram.java b/samples/async/src/main/java/org/teavm/samples/async/AsyncProgram.java index c6890005d..0ac3af060 100644 --- a/samples/async/src/main/java/org/teavm/samples/async/AsyncProgram.java +++ b/samples/async/src/main/java/org/teavm/samples/async/AsyncProgram.java @@ -36,30 +36,21 @@ public final class AsyncProgram { report(""); final Object lock = new Object(); - Thread t = new Thread(new Runnable() { - @Override - public void run() { - try { - doRun(lock); - } catch (InterruptedException ex) { - report("Exception caught: " + ex.getMessage()); - } + new Thread(() -> { + try { + doRun(lock); + } catch (InterruptedException ex) { + report("Exception caught: " + ex.getMessage()); } + }, "Test Thread").start(); - }, "Test Thread"); - t.start(); - - Thread t2 = new Thread(new Runnable() { - @Override - public void run() { - try { - doRun(lock); - } catch (InterruptedException ex) { - report("Exception caught: " + ex.getMessage()); - } + new Thread(() -> { + try { + doRun(lock); + } catch (InterruptedException ex) { + report("Exception caught: " + ex.getMessage()); } - }, "Test Thread 2"); - t2.start(); + }, "Test Thread 2").start(); report("Should be main"); report("Now trying wait..."); diff --git a/samples/async/src/main/webapp/index.html b/samples/async/src/main/webapp/index.html index b0f4ad133..309a28a6c 100644 --- a/samples/async/src/main/webapp/index.html +++ b/samples/async/src/main/webapp/index.html @@ -33,7 +33,7 @@
This application shows how TeaVM can handle multiple threads and synchronization primitives - (see source code on GitHub).
+ (see source code on GitHub).
@@ -59,30 +59,21 @@ public final class AsyncProgram { report(""); final Object lock = new Object(); - Thread t = new Thread(new Runnable() { - @Override - public void run() { - try { - doRun(lock); - } catch (InterruptedException ex) { - report("Exception caught: " + ex.getMessage()); - } + new Thread(() -> { + try { + doRun(lock); + } catch (InterruptedException ex) { + report("Exception caught: " + ex.getMessage()); } + }, "Test Thread").start(); - }, "Test Thread"); - t.start(); - - Thread t2 = new Thread(new Runnable() { - @Override - public void run() { - try { - doRun(lock); - } catch (InterruptedException ex) { - report("Exception caught: " + ex.getMessage()); - } + new Thread(() -> { + try { + doRun(lock); + } catch (InterruptedException ex) { + report("Exception caught: " + ex.getMessage()); } - }, "Test Thread 2"); - t2.start(); + }, "Test Thread 2").start(); report("Should be main"); report("Now trying wait..."); @@ -99,18 +90,18 @@ public final class AsyncProgram { boolean[] prime = new boolean[1000]; prime[2] = true; prime[3] = true; - nextPrime: for (int i = 5; i < prime.length; i += 2) { - int maxPrime = (int)Math.sqrt(i); - for (int j = 3; j <= maxPrime; j += 2) { + nextPrime: for (int i = 5; i < prime.length; i += 2) { + int maxPrime = (int) Math.sqrt(i); + for (int j = 3; j <= maxPrime; j += 2) { Thread.yield(); - if (prime[j] && i % j == 0) { + if (prime[j] && i % j == 0) { continue nextPrime; } } prime[i] = true; } StringBuilder sb = new StringBuilder(); - for (int i = 0; i < 1000; ++i) { + for (int i = 0; i < 1000; ++i) { if (prime[i]) { sb.append(i).append(' '); } @@ -144,9 +135,9 @@ public final class AsyncProgram { private static void withoutAsync() { report("Start sync"); - for (int i = 0; i < 20; ++i) { + for (int i = 0; i < 20; ++i) { StringBuilder sb = new StringBuilder(); - for (int j = 0; j <= i; ++j) { + for (int j = 0; j <= i; ++j) { sb.append(j); sb.append(' '); } @@ -157,9 +148,9 @@ public final class AsyncProgram { private static void withAsync() throws InterruptedException { report("Start async"); - for (int i = 0; i < 20; ++i) { + for (int i = 0; i < 20; ++i) { StringBuilder sb = new StringBuilder(); - for (int j = 0; j <= i; ++j) { + for (int j = 0; j <= i; ++j) { sb.append(j); sb.append(' '); } @@ -187,6 +178,7 @@ public final class AsyncProgram { throw new IllegalStateException(); } } +