Reasonable TYPE for primitive types launcher
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 18 Dec 2012 16:04:37 +0100
branchlauncher
changeset 353fd38bdad7fb5
parent 350 12debda84e3c
child 354 002b7c3d5157
Reasonable TYPE for primitive types
emul/src/main/java/java/lang/Class.java
vm/src/test/java/org/apidesign/vm4brwsr/ClassTest.java
vm/src/test/java/org/apidesign/vm4brwsr/Classes.java
     1.1 --- a/emul/src/main/java/java/lang/Class.java	Tue Dec 18 13:25:32 2012 +0100
     1.2 +++ b/emul/src/main/java/java/lang/Class.java	Tue Dec 18 16:04:37 2012 +0100
     1.3 @@ -1090,10 +1090,12 @@
     1.4          throw new UnsupportedOperationException();
     1.5      }
     1.6  
     1.7 -    static Class getPrimitiveClass(String type) {
     1.8 -        // XXX
     1.9 -        return Object.class;
    1.10 -    }
    1.11 +    @JavaScriptBody(args = "type", body = ""
    1.12 +        + "var c = vm.java_lang_Class(true);"
    1.13 +        + "c.jvmName = type;"
    1.14 +        + "return c;"
    1.15 +    )
    1.16 +    native static Class getPrimitiveClass(String type);
    1.17  
    1.18      public boolean desiredAssertionStatus() {
    1.19          return false;
     2.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/ClassTest.java	Tue Dec 18 13:25:32 2012 +0100
     2.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/ClassTest.java	Tue Dec 18 16:04:37 2012 +0100
     2.3 @@ -117,6 +117,13 @@
     2.4          );
     2.5      }
     2.6      
     2.7 +    @Test public void integerType() throws Exception {
     2.8 +        assertExec("Computes the type", Classes.class, 
     2.9 +            "intType__Ljava_lang_String_2", 
    2.10 +            Classes.intType()
    2.11 +        );
    2.12 +    }
    2.13 +    
    2.14      private static CharSequence codeSeq;
    2.15      private static Invocable code;
    2.16      
     3.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/Classes.java	Tue Dec 18 13:25:32 2012 +0100
     3.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/Classes.java	Tue Dec 18 16:04:37 2012 +0100
     3.3 @@ -88,6 +88,10 @@
     3.4          return null;
     3.5      }
     3.6      
     3.7 +    public static String intType() {
     3.8 +        return Integer.TYPE.getName();
     3.9 +    }
    3.10 +    
    3.11      @JavaScriptBody(args = "msg", body = "throw msg;")
    3.12      private static native void thrw(String msg);
    3.13