Merge from default branch emul
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 06 Feb 2013 15:09:42 +0100
branchemul
changeset 683327a6da275d6
parent 674 5d9cd8add4c6
parent 681 93196a859fc5
child 684 985535d06cb3
Merge from default branch
emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/lang/System.java
     1.1 --- a/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/lang/System.java	Tue Feb 05 15:32:41 2013 +0100
     1.2 +++ b/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/lang/System.java	Wed Feb 06 15:09:42 2013 +0100
     1.3 @@ -48,6 +48,9 @@
     1.4      @JavaScriptBody(args = {}, body = "new Date().getMilliseconds();")
     1.5      public static native long currentTimeMillis();
     1.6      
     1.7 +    public static long nanoTime() {
     1.8 +        return 1000000L * currentTimeMillis();
     1.9 +    }
    1.10      @JavaScriptBody(args = { "obj" }, body="return vm.java_lang_Object(false).hashCode__I.call(obj);")
    1.11      public static native int identityHashCode(Object obj);
    1.12      
     2.1 --- a/vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/impl/LaunchSetup.java	Tue Feb 05 15:32:41 2013 +0100
     2.2 +++ b/vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/impl/LaunchSetup.java	Wed Feb 06 15:09:42 2013 +0100
     2.3 @@ -31,13 +31,19 @@
     2.4  public final class LaunchSetup {
     2.5      static LaunchSetup INSTANCE = new LaunchSetup();
     2.6      
     2.7 -    private final Launcher js = Launcher.createJavaScript();
     2.8 +    private Launcher js;
     2.9      private final Map<String,Launcher> brwsrs = new LinkedHashMap<>();
    2.10      
    2.11      private LaunchSetup() {
    2.12      }
    2.13      
    2.14 -    public  Launcher javaScript() {
    2.15 +    public Launcher javaScript() {
    2.16 +        return js(true);
    2.17 +    } 
    2.18 +    private synchronized  Launcher js(boolean create) {
    2.19 +        if (js == null && create) {
    2.20 +            js = Launcher.createJavaScript();
    2.21 +        }
    2.22          return js;
    2.23      } 
    2.24      
    2.25 @@ -52,7 +58,9 @@
    2.26  
    2.27      @BeforeGroups("run")
    2.28      public void initializeLauncher() throws IOException {
    2.29 -        js.initialize();
    2.30 +        if (js(false) != null) {
    2.31 +            js(true).initialize();
    2.32 +        }
    2.33          for (Launcher launcher : brwsrs.values()) {
    2.34              launcher.initialize();
    2.35          }
    2.36 @@ -60,7 +68,9 @@
    2.37  
    2.38      @AfterGroups("run")
    2.39      public void shutDownLauncher() throws IOException, InterruptedException {
    2.40 -        js.shutdown();
    2.41 +        if (js(false) != null) {
    2.42 +            js(true).shutdown();
    2.43 +        }
    2.44          for (Launcher launcher : brwsrs.values()) {
    2.45              launcher.shutdown();
    2.46          }