Make sure os.name property is defined javac
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 30 Sep 2013 17:11:18 +0200
branchjavac
changeset 13281d1d70f6828b
parent 1323 5d2341f16b4f
child 1329 c1893bd50f35
Make sure os.name property is defined
rt/emul/compact/src/main/java/java/lang/System.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/SystemTest.java
     1.1 --- a/rt/emul/compact/src/main/java/java/lang/System.java	Sat Sep 28 20:54:50 2013 +0200
     1.2 +++ b/rt/emul/compact/src/main/java/java/lang/System.java	Mon Sep 30 17:11:18 2013 +0200
     1.3 @@ -44,9 +44,15 @@
     1.4      }
     1.5  
     1.6      public static String getProperty(String name) {
     1.7 +        if ("os.name".equals(name)) {
     1.8 +            return userAgent();
     1.9 +        }
    1.10          return null;
    1.11      }
    1.12      
    1.13 +    @JavaScriptBody(args = {}, body = "return navigator.userAgent;")
    1.14 +    private static native String userAgent();
    1.15 +    
    1.16      public static String getProperty(String key, String def) {
    1.17          return def;
    1.18      }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/SystemTest.java	Mon Sep 30 17:11:18 2013 +0200
     2.3 @@ -0,0 +1,36 @@
     2.4 +/**
     2.5 + * Back 2 Browser Bytecode Translator
     2.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     2.7 + *
     2.8 + * This program is free software: you can redistribute it and/or modify
     2.9 + * it under the terms of the GNU General Public License as published by
    2.10 + * the Free Software Foundation, version 2 of the License.
    2.11 + *
    2.12 + * This program is distributed in the hope that it will be useful,
    2.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.15 + * GNU General Public License for more details.
    2.16 + *
    2.17 + * You should have received a copy of the GNU General Public License
    2.18 + * along with this program. Look for COPYING file in the top folder.
    2.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
    2.20 + */
    2.21 +package org.apidesign.bck2brwsr.tck;
    2.22 +
    2.23 +import org.apidesign.bck2brwsr.vmtest.Compare;
    2.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
    2.25 +import org.testng.annotations.Factory;
    2.26 +
    2.27 +/**
    2.28 + *
    2.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    2.30 + */
    2.31 +public class SystemTest {
    2.32 +    @Compare public boolean nonNullOSName() {
    2.33 +        return System.getProperty("os.name") != null;
    2.34 +    }
    2.35 +
    2.36 +    @Factory public static Object[] create() {
    2.37 +        return VMTest.create(SystemTest.class);
    2.38 +    }
    2.39 +}