Updating to recent changes in html.java.net APIs
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 12 Sep 2013 14:15:47 +0200
changeset 12828d29792a09c6
parent 1281 8ed05565a481
child 1283 1d0e583ac981
Updating to recent changes in html.java.net APIs
ko/fx/src/test/java/org/apidesign/bck2brwsr/kofx/KnockoutFXTest.java
launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/JVMBridge.java
launcher/fx/src/test/java/org/apidesign/bck2brwsr/launcher/fximpl/JsClassLoaderTest.java
pom.xml
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotations.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotationsTest.java
rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js
rt/vm/src/main/java/org/apidesign/vm4brwsr/VMLazy.java
rt/vm/src/test/java/org/apidesign/vm4brwsr/HtmlAnnotations.java
rt/vm/src/test/java/org/apidesign/vm4brwsr/HtmlAnnotationsTest.java
rt/vm/src/test/resources/org/apidesign/vm4brwsr/htmlannotations.js
     1.1 --- a/ko/fx/src/test/java/org/apidesign/bck2brwsr/kofx/KnockoutFXTest.java	Thu Sep 12 12:26:23 2013 +0200
     1.2 +++ b/ko/fx/src/test/java/org/apidesign/bck2brwsr/kofx/KnockoutFXTest.java	Thu Sep 12 14:15:47 2013 +0200
     1.3 @@ -28,6 +28,7 @@
     1.4  import net.java.html.BrwsrCtx;
     1.5  import net.java.html.js.JavaScriptBody;
     1.6  import org.apidesign.bck2brwsr.vmtest.VMTest;
     1.7 +import org.apidesign.html.boot.impl.FnUtils;
     1.8  import org.apidesign.html.context.spi.Contexts;
     1.9  import org.apidesign.html.json.spi.Technology;
    1.10  import org.apidesign.html.json.spi.Transfer;
    1.11 @@ -59,7 +60,7 @@
    1.12  
    1.13      @Override
    1.14      public BrwsrCtx createContext() {
    1.15 -        FXContext fx = new FXContext();
    1.16 +        FXContext fx = new FXContext(FnUtils.currentPresenter());
    1.17          TyrusContext tc = new TyrusContext();
    1.18          Contexts.Builder b = Contexts.newBuilder().
    1.19              register(Technology.class, fx, 10).
     2.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/JVMBridge.java	Thu Sep 12 12:26:23 2013 +0200
     2.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/JVMBridge.java	Thu Sep 12 14:15:47 2013 +0200
     2.3 @@ -39,6 +39,7 @@
     2.4  public final class JVMBridge {
     2.5      private final WebEngine engine;
     2.6      private final ClassLoader cl;
     2.7 +    private final WebPresenter presenter;
     2.8      
     2.9      private static ClassLoader[] ldrs;
    2.10      private static ChangeListener<Void> onBck2BrwsrLoad;
    2.11 @@ -46,8 +47,8 @@
    2.12      JVMBridge(WebEngine eng) {
    2.13          this.engine = eng;
    2.14          final ClassLoader p = JVMBridge.class.getClassLoader().getParent();
    2.15 -        WebClassLoader wcl = new WebClassLoader();
    2.16 -        this.cl = FnUtils.newLoader(wcl, wcl, p);
    2.17 +        this.presenter = new WebPresenter();
    2.18 +        this.cl = FnUtils.newLoader(presenter, presenter, p);
    2.19      }
    2.20          
    2.21      public static void registerClassLoaders(ClassLoader[] loaders) {
    2.22 @@ -69,10 +70,11 @@
    2.23      }
    2.24      
    2.25      public Class<?> loadClass(String name) throws ClassNotFoundException {
    2.26 +        FnUtils.currentPresenter(presenter);
    2.27          return Class.forName(name, true, cl);
    2.28      }
    2.29      
    2.30 -    private final class WebClassLoader implements FindResources, Fn.Presenter {
    2.31 +    private final class WebPresenter implements FindResources, Fn.Presenter {
    2.32          @Override
    2.33          public void findResources(String name, Collection<? super URL> results, boolean oneIsEnough) {
    2.34              if (ldrs != null) for (ClassLoader l : ldrs) {
    2.35 @@ -99,7 +101,7 @@
    2.36              sb.append("})()");
    2.37              
    2.38              JSObject x = (JSObject) engine.executeScript(sb.toString());
    2.39 -            return new JSFn(x);
    2.40 +            return new JSFn(this, x);
    2.41          }
    2.42  
    2.43          @Override
    2.44 @@ -125,10 +127,11 @@
    2.45      private static final class JSFn extends Fn {
    2.46          private final JSObject fn;
    2.47  
    2.48 -        public JSFn(JSObject fn) {
    2.49 +        private JSFn(WebPresenter cl, JSObject fn) {
    2.50 +            super(cl);
    2.51              this.fn = fn;
    2.52          }
    2.53 -        
    2.54 +
    2.55          @Override
    2.56          public Object invoke(Object thiz, Object... args) throws Exception {
    2.57              try {
     3.1 --- a/launcher/fx/src/test/java/org/apidesign/bck2brwsr/launcher/fximpl/JsClassLoaderTest.java	Thu Sep 12 12:26:23 2013 +0200
     3.2 +++ b/launcher/fx/src/test/java/org/apidesign/bck2brwsr/launcher/fximpl/JsClassLoaderTest.java	Thu Sep 12 14:15:47 2013 +0200
     3.3 @@ -35,6 +35,7 @@
     3.4  import org.apidesign.html.boot.impl.FnUtils;
     3.5  import static org.testng.Assert.*;
     3.6  import org.testng.annotations.BeforeClass;
     3.7 +import org.testng.annotations.BeforeMethod;
     3.8  import org.testng.annotations.Test;
     3.9  
    3.10  /**
    3.11 @@ -44,6 +45,7 @@
    3.12  public class JsClassLoaderTest {
    3.13      private static ClassLoader loader;
    3.14      private static Class<?> methodClass;
    3.15 +    private static Fn.Presenter presenter;
    3.16      
    3.17      public JsClassLoaderTest() {
    3.18      }
    3.19 @@ -82,7 +84,7 @@
    3.20                  sb.append("})()");
    3.21                  try {
    3.22                      final Object val = eng.eval(sb.toString());
    3.23 -                    return new Fn() {
    3.24 +                    return new Fn(this) {
    3.25                          @Override
    3.26                          public Object invoke(Object thiz, Object... args) throws Exception {
    3.27                              List<Object> all = new ArrayList<Object>(args.length + 1);
    3.28 @@ -109,10 +111,16 @@
    3.29              }
    3.30          }
    3.31          
    3.32 -        loader = FnUtils.newLoader(new Fr(), new Fr(), parent);
    3.33 +        Fr fr = new Fr();
    3.34 +        presenter = fr;
    3.35 +        loader = FnUtils.newLoader(fr, fr, parent);
    3.36          methodClass = loader.loadClass(JsMethods.class.getName());
    3.37      }
    3.38      
    3.39 +    @BeforeMethod public void registerPresenter() {
    3.40 +        FnUtils.currentPresenter(presenter);
    3.41 +    }
    3.42 +    
    3.43      @Test public void noParamMethod() throws Throwable {
    3.44          Method plus = methodClass.getMethod("fortyTwo");
    3.45          try {
     4.1 --- a/pom.xml	Thu Sep 12 12:26:23 2013 +0200
     4.2 +++ b/pom.xml	Thu Sep 12 14:15:47 2013 +0200
     4.3 @@ -15,7 +15,7 @@
     4.4        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     4.5        <netbeans.version>RELEASE73</netbeans.version>
     4.6        <license>COPYING</license>
     4.7 -      <net.java.html.version>0.5</net.java.html.version>
     4.8 +      <net.java.html.version>0.6-SNAPSHOT</net.java.html.version>
     4.9    </properties>
    4.10    <modules>
    4.11      <module>dew</module>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotations.java	Thu Sep 12 14:15:47 2013 +0200
     5.3 @@ -0,0 +1,86 @@
     5.4 +/**
     5.5 + * Back 2 Browser Bytecode Translator
     5.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     5.7 + *
     5.8 + * This program is free software: you can redistribute it and/or modify
     5.9 + * it under the terms of the GNU General Public License as published by
    5.10 + * the Free Software Foundation, version 2 of the License.
    5.11 + *
    5.12 + * This program is distributed in the hope that it will be useful,
    5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.15 + * GNU General Public License for more details.
    5.16 + *
    5.17 + * You should have received a copy of the GNU General Public License
    5.18 + * along with this program. Look for COPYING file in the top folder.
    5.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    5.20 + */
    5.21 +package org.apidesign.bck2brwsr.vmtest.impl;
    5.22 +
    5.23 +import net.java.html.js.JavaScriptBody;
    5.24 +import net.java.html.js.JavaScriptResource;
    5.25 +
    5.26 +/**
    5.27 + *
    5.28 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    5.29 + */
    5.30 +@JavaScriptResource("htmlannotations.js")
    5.31 +public class HtmlAnnotations {
    5.32 +    private Object callback;
    5.33 +    
    5.34 +    
    5.35 +    @JavaScriptBody(args = {}, body = "return 42;")
    5.36 +    public static int fourtyTwo() {
    5.37 +        return -1;
    5.38 +    }
    5.39 +    
    5.40 +    @JavaScriptBody(args = { "x", "y" }, body = "return mul(x, y);")
    5.41 +    public static native int useExternalMul(int x, int y);
    5.42 +    
    5.43 +    public static int callback() {
    5.44 +        final int[] arr = { 0 };
    5.45 +        callback(new Runnable() {
    5.46 +            @Override
    5.47 +            public void run() {
    5.48 +                arr[0]++;
    5.49 +            }
    5.50 +        });
    5.51 +        return arr[0];
    5.52 +    }
    5.53 +    
    5.54 +    @JavaScriptBody(args = { "r" }, javacall=true, body = "r.@java.lang.Runnable::run()()")
    5.55 +    private static native void callback(Runnable r);
    5.56 +
    5.57 +    @JavaScriptBody(args = {  }, javacall = true, body = "return @org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::callback()();")
    5.58 +    public static native int staticCallback();
    5.59 +    
    5.60 +    
    5.61 +    protected long chooseLong(boolean takeFirst, boolean takeSecond, long first, long second) {
    5.62 +        long l = 0;
    5.63 +        if (takeFirst) l += first;
    5.64 +        if (takeSecond) l += second;
    5.65 +        return l;
    5.66 +    }
    5.67 +    
    5.68 +    protected void onError(Object obj) throws Exception {
    5.69 +        callback = obj;
    5.70 +    }
    5.71 +    
    5.72 +    Object getError() {
    5.73 +        return callback;
    5.74 +    }
    5.75 +    
    5.76 +    public static Object create() {
    5.77 +        return new HtmlAnnotations();
    5.78 +    }
    5.79 +    @JavaScriptBody(args = { "impl", "a", "b" }, javacall = true, body = 
    5.80 +        "return impl.@org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::chooseLong(ZZJJ)(true, false, a, b);"
    5.81 +    )
    5.82 +    public static native long first(Object impl, long a, long b);
    5.83 +    
    5.84 +    @JavaScriptBody(args = { "impl", "d" }, javacall = true, body = 
    5.85 +        "impl.@org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::onError(Ljava/lang/Object;)(d);" +
    5.86 +        "return impl.@org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::getError()();"
    5.87 +    )
    5.88 +    public static native Double onError(Object impl, Double d);
    5.89 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotationsTest.java	Thu Sep 12 14:15:47 2013 +0200
     6.3 @@ -0,0 +1,71 @@
     6.4 +/**
     6.5 + * Back 2 Browser Bytecode Translator
     6.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     6.7 + *
     6.8 + * This program is free software: you can redistribute it and/or modify
     6.9 + * it under the terms of the GNU General Public License as published by
    6.10 + * the Free Software Foundation, version 2 of the License.
    6.11 + *
    6.12 + * This program is distributed in the hope that it will be useful,
    6.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.15 + * GNU General Public License for more details.
    6.16 + *
    6.17 + * You should have received a copy of the GNU General Public License
    6.18 + * along with this program. Look for COPYING file in the top folder.
    6.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    6.20 + */
    6.21 +package org.apidesign.bck2brwsr.vmtest.impl;
    6.22 +
    6.23 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
    6.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    6.25 +import org.testng.annotations.Factory;
    6.26 +
    6.27 +/** Verify cooperation with net.java.html.js annotations.
    6.28 + *
    6.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    6.30 + */
    6.31 +public class HtmlAnnotationsTest {
    6.32 +    @BrwsrTest public void fourtyTwo() throws Exception {
    6.33 +        assertEquals(HtmlAnnotations.fourtyTwo(), 42);
    6.34 +    }
    6.35 +    
    6.36 +    @BrwsrTest public void externalMul() throws Exception {
    6.37 +        assertEquals(HtmlAnnotations.useExternalMul(7, 6), 42);
    6.38 +    }
    6.39 +
    6.40 +    @BrwsrTest public void callRunnableFromJS() throws Exception {
    6.41 +        assertEquals(HtmlAnnotations.callback(), 1);
    6.42 +    }
    6.43 +
    6.44 +    @BrwsrTest public void callStaticMethodFromJS() throws Exception {
    6.45 +        assertEquals(HtmlAnnotations.staticCallback(), 1);
    6.46 +    }
    6.47 +
    6.48 +    @BrwsrTest public void callbackWithFourParamsAndReturnType() throws Exception {
    6.49 +        Object instance = HtmlAnnotations.create();
    6.50 +        assertNotNull(instance, "Instance created");
    6.51 +        assertEquals(HtmlAnnotations.first(instance, 42, 31), 42);
    6.52 +    }
    6.53 +
    6.54 +    @BrwsrTest public void callbackWithObjectParamsAndReturnType() throws Exception {
    6.55 +        Object instance = HtmlAnnotations.create();
    6.56 +        assertNotNull(instance, "Instance created");
    6.57 +        assertEquals(HtmlAnnotations.onError(instance, 42.0), 42.0);
    6.58 +    }
    6.59 +    
    6.60 +    private static void assertEquals(double real, double exp) {
    6.61 +        if (real - exp < 0.01) {
    6.62 +            return;
    6.63 +        }
    6.64 +        assert false : "Expecting " + exp + " but was " + real;
    6.65 +    }
    6.66 +
    6.67 +    private static void assertNotNull(Object obj, String msg) {
    6.68 +        assert obj != null : msg;
    6.69 +    }
    6.70 +    
    6.71 +    @Factory public static Object[] create() {
    6.72 +        return VMTest.create(HtmlAnnotationsTest.class);
    6.73 +    }
    6.74 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js	Thu Sep 12 14:15:47 2013 +0200
     7.3 @@ -0,0 +1,20 @@
     7.4 +/*
     7.5 + * Back 2 Browser Bytecode Translator
     7.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     7.7 + *
     7.8 + * This program is free software: you can redistribute it and/or modify
     7.9 + * it under the terms of the GNU General Public License as published by
    7.10 + * the Free Software Foundation, version 2 of the License.
    7.11 + *
    7.12 + * This program is distributed in the hope that it will be useful,
    7.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.15 + * GNU General Public License for more details.
    7.16 + *
    7.17 + * You should have received a copy of the GNU General Public License
    7.18 + * along with this program. Look for COPYING file in the top folder.
    7.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    7.20 + */
    7.21 +
    7.22 +function mul(x, y) { return x * y; }
    7.23 +window.mul = mul;
     8.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/VMLazy.java	Thu Sep 12 12:26:23 2013 +0200
     8.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/VMLazy.java	Thu Sep 12 14:15:47 2013 +0200
     8.3 @@ -130,6 +130,14 @@
     8.4  
     8.5          @Override
     8.6          protected void requireScript(String resourcePath) throws IOException {
     8.7 +            if (!resourcePath.startsWith("/")) {
     8.8 +                resourcePath = "/" + resourcePath;
     8.9 +            }
    8.10 +            String code = readCode(resourcePath);
    8.11 +            applyCode(lazy.loader, null, code, false);
    8.12 +        }
    8.13 +
    8.14 +        private String readCode(String resourcePath) throws IOException {
    8.15              InputStream is = getClass().getResourceAsStream(resourcePath);
    8.16              StringBuilder sb = new StringBuilder();
    8.17              for (;;) {
    8.18 @@ -139,7 +147,7 @@
    8.19                  }
    8.20                  sb.append((char)ch);
    8.21              }
    8.22 -            applyCode(lazy.loader, null, sb.toString(), false);
    8.23 +            return sb.toString();
    8.24          }
    8.25  
    8.26          @Override
     9.1 --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/HtmlAnnotations.java	Thu Sep 12 12:26:23 2013 +0200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,86 +0,0 @@
     9.4 -/**
     9.5 - * Back 2 Browser Bytecode Translator
     9.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     9.7 - *
     9.8 - * This program is free software: you can redistribute it and/or modify
     9.9 - * it under the terms of the GNU General Public License as published by
    9.10 - * the Free Software Foundation, version 2 of the License.
    9.11 - *
    9.12 - * This program is distributed in the hope that it will be useful,
    9.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.15 - * GNU General Public License for more details.
    9.16 - *
    9.17 - * You should have received a copy of the GNU General Public License
    9.18 - * along with this program. Look for COPYING file in the top folder.
    9.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    9.20 - */
    9.21 -package org.apidesign.vm4brwsr;
    9.22 -
    9.23 -import net.java.html.js.JavaScriptBody;
    9.24 -import net.java.html.js.JavaScriptResource;
    9.25 -
    9.26 -/**
    9.27 - *
    9.28 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    9.29 - */
    9.30 -@JavaScriptResource("htmlannotations.js")
    9.31 -public class HtmlAnnotations {
    9.32 -    private Object callback;
    9.33 -    
    9.34 -    
    9.35 -    @JavaScriptBody(args = {}, body = "return 42;")
    9.36 -    public static int fourtyTwo() {
    9.37 -        return -1;
    9.38 -    }
    9.39 -    
    9.40 -    @JavaScriptBody(args = { "x", "y" }, body = "return mul(x, y);")
    9.41 -    public static native int useExternalMul(int x, int y);
    9.42 -    
    9.43 -    public static int callback() {
    9.44 -        final int[] arr = { 0 };
    9.45 -        callback(new Runnable() {
    9.46 -            @Override
    9.47 -            public void run() {
    9.48 -                arr[0]++;
    9.49 -            }
    9.50 -        });
    9.51 -        return arr[0];
    9.52 -    }
    9.53 -    
    9.54 -    @JavaScriptBody(args = { "r" }, javacall=true, body = "r.@java.lang.Runnable::run()()")
    9.55 -    private static native void callback(Runnable r);
    9.56 -
    9.57 -    @JavaScriptBody(args = {  }, javacall = true, body = "return @org.apidesign.vm4brwsr.HtmlAnnotations::callback()();")
    9.58 -    public static native int staticCallback();
    9.59 -    
    9.60 -    
    9.61 -    protected long chooseLong(boolean takeFirst, boolean takeSecond, long first, long second) {
    9.62 -        long l = 0;
    9.63 -        if (takeFirst) l += first;
    9.64 -        if (takeSecond) l += second;
    9.65 -        return l;
    9.66 -    }
    9.67 -    
    9.68 -    protected void onError(Object obj) throws Exception {
    9.69 -        callback = obj;
    9.70 -    }
    9.71 -    
    9.72 -    Object getError() {
    9.73 -        return callback;
    9.74 -    }
    9.75 -    
    9.76 -    public static Object create() {
    9.77 -        return new HtmlAnnotations();
    9.78 -    }
    9.79 -    @JavaScriptBody(args = { "impl", "a", "b" }, javacall = true, body = 
    9.80 -        "return impl.@org.apidesign.vm4brwsr.HtmlAnnotations::chooseLong(ZZJJ)(true, false, a, b);"
    9.81 -    )
    9.82 -    public static native long first(Object impl, long a, long b);
    9.83 -    
    9.84 -    @JavaScriptBody(args = { "impl", "d" }, javacall = true, body = 
    9.85 -        "impl.@org.apidesign.vm4brwsr.HtmlAnnotations::onError(Ljava/lang/Object;)(d);" +
    9.86 -        "return impl.@org.apidesign.vm4brwsr.HtmlAnnotations::getError()();"
    9.87 -    )
    9.88 -    public static native Double onError(Object impl, Double d);
    9.89 -}
    10.1 --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/HtmlAnnotationsTest.java	Thu Sep 12 12:26:23 2013 +0200
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,91 +0,0 @@
    10.4 -/**
    10.5 - * Back 2 Browser Bytecode Translator
    10.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    10.7 - *
    10.8 - * This program is free software: you can redistribute it and/or modify
    10.9 - * it under the terms of the GNU General Public License as published by
   10.10 - * the Free Software Foundation, version 2 of the License.
   10.11 - *
   10.12 - * This program is distributed in the hope that it will be useful,
   10.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10.15 - * GNU General Public License for more details.
   10.16 - *
   10.17 - * You should have received a copy of the GNU General Public License
   10.18 - * along with this program. Look for COPYING file in the top folder.
   10.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   10.20 - */
   10.21 -package org.apidesign.vm4brwsr;
   10.22 -
   10.23 -import static org.testng.Assert.assertNotNull;
   10.24 -import org.testng.annotations.AfterClass;
   10.25 -import org.testng.annotations.BeforeClass;
   10.26 -import org.testng.annotations.Test;
   10.27 -
   10.28 -/** Verify cooperation with net.java.html.js annotations.
   10.29 - *
   10.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
   10.31 - */
   10.32 -public class HtmlAnnotationsTest {
   10.33 -    @Test public void fourtyTwo() throws Exception {
   10.34 -        assertExec("Annotation used", HtmlAnnotations.class, 
   10.35 -            "fourtyTwo__I",
   10.36 -            Double.valueOf(42)
   10.37 -        );
   10.38 -    }
   10.39 -    
   10.40 -    @Test public void externalMul() throws Exception {
   10.41 -        assertExec("mul function is loaded", HtmlAnnotations.class, 
   10.42 -            "useExternalMul__III",
   10.43 -            Double.valueOf(42),
   10.44 -            7, 6
   10.45 -        );
   10.46 -    }
   10.47 -
   10.48 -    @Test public void callRunnableFromJS() throws Exception {
   10.49 -        assertExec("runnable called", HtmlAnnotations.class, 
   10.50 -            "callback__I",
   10.51 -            Double.valueOf(1)
   10.52 -        );
   10.53 -    }
   10.54 -
   10.55 -    @Test public void callStaticMethodFromJS() throws Exception {
   10.56 -        assertExec("runnable called", HtmlAnnotations.class, 
   10.57 -            "staticCallback__I",
   10.58 -            Double.valueOf(1)
   10.59 -        );
   10.60 -    }
   10.61 -
   10.62 -    @Test public void callbackWithFourParamsAndReturnType() throws Exception {
   10.63 -        Object instance = code.execCode("Get an HtmlAnnotations instance", HtmlAnnotations.class, "create__Ljava_lang_Object_2", null);
   10.64 -        assertNotNull(instance, "Instance created");
   10.65 -        assertExec("runnable called", HtmlAnnotations.class, 
   10.66 -            "first__JLjava_lang_Object_2JJ",
   10.67 -            Double.valueOf(42), instance, 42, 31
   10.68 -        );
   10.69 -    }
   10.70 -
   10.71 -    @Test public void callbackWithObjectParamsAndReturnType() throws Exception {
   10.72 -        Object instance = code.execCode("Get an HtmlAnnotations instance", HtmlAnnotations.class, "create__Ljava_lang_Object_2", null);
   10.73 -        assertNotNull(instance, "Instance created");
   10.74 -        assertExec("called back and forth", HtmlAnnotations.class, 
   10.75 -            "onError__Ljava_lang_Double_2Ljava_lang_Object_2Ljava_lang_Double_2",
   10.76 -            Double.valueOf(42), instance, 42
   10.77 -        );
   10.78 -    }
   10.79 -    
   10.80 -    private static TestVM code;
   10.81 -    
   10.82 -    @BeforeClass 
   10.83 -    public void compileTheCode() throws Exception {
   10.84 -        code = TestVM.compileClass("org/apidesign/vm4brwsr/HtmlAnnotations");
   10.85 -    }
   10.86 -    @AfterClass
   10.87 -    public static void releaseTheCode() {
   10.88 -        code = null;
   10.89 -    }
   10.90 -    private static void assertExec(String msg, Class clazz, String method, Object expRes, Object... args) throws Exception {
   10.91 -        code.assertExec(msg, clazz, method, expRes, args);
   10.92 -    }
   10.93 -    
   10.94 -}
    11.1 --- a/rt/vm/src/test/resources/org/apidesign/vm4brwsr/htmlannotations.js	Thu Sep 12 12:26:23 2013 +0200
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,19 +0,0 @@
    11.4 -/*
    11.5 - * Back 2 Browser Bytecode Translator
    11.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    11.7 - *
    11.8 - * This program is free software: you can redistribute it and/or modify
    11.9 - * it under the terms of the GNU General Public License as published by
   11.10 - * the Free Software Foundation, version 2 of the License.
   11.11 - *
   11.12 - * This program is distributed in the hope that it will be useful,
   11.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11.15 - * GNU General Public License for more details.
   11.16 - *
   11.17 - * You should have received a copy of the GNU General Public License
   11.18 - * along with this program. Look for COPYING file in the top folder.
   11.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   11.20 - */
   11.21 -
   11.22 -function mul(x, y) { return x * y; }