1.1 --- a/emul/mini/src/main/java/java/lang/Class.java Wed Jan 23 20:39:23 2013 +0100
1.2 +++ b/emul/mini/src/main/java/java/lang/Class.java Wed Jan 23 20:52:11 2013 +0100
1.3 @@ -26,14 +26,14 @@
1.4 package java.lang;
1.5
1.6 import java.io.ByteArrayInputStream;
1.7 -import org.apidesign.bck2brwsr.emul.AnnotationImpl;
1.8 +import org.apidesign.bck2brwsr.emul.reflect.AnnotationImpl;
1.9 import java.io.InputStream;
1.10 import java.lang.annotation.Annotation;
1.11 import java.lang.reflect.Field;
1.12 import java.lang.reflect.Method;
1.13 import java.lang.reflect.TypeVariable;
1.14 import org.apidesign.bck2brwsr.core.JavaScriptBody;
1.15 -import org.apidesign.bck2brwsr.emul.MethodImpl;
1.16 +import org.apidesign.bck2brwsr.emul.reflect.MethodImpl;
1.17
1.18 /**
1.19 * Instances of the class {@code Class} represent classes and
2.1 --- a/emul/mini/src/main/java/java/lang/Number.java Wed Jan 23 20:39:23 2013 +0100
2.2 +++ b/emul/mini/src/main/java/java/lang/Number.java Wed Jan 23 20:52:11 2013 +0100
2.3 @@ -49,7 +49,7 @@
2.4 * @since JDK1.0
2.5 */
2.6 @ExtraJavaScript(
2.7 - resource="/org/apidesign/vm4brwsr/emul/java_lang_Number.js",
2.8 + resource="/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js",
2.9 processByteCode=true
2.10 )
2.11 public abstract class Number implements java.io.Serializable {
3.1 --- a/emul/mini/src/main/java/java/lang/String.java Wed Jan 23 20:39:23 2013 +0100
3.2 +++ b/emul/mini/src/main/java/java/lang/String.java Wed Jan 23 20:52:11 2013 +0100
3.3 @@ -101,7 +101,7 @@
3.4 */
3.5
3.6 @ExtraJavaScript(
3.7 - resource="/org/apidesign/vm4brwsr/emul/java_lang_String.js",
3.8 + resource="/org/apidesign/vm4brwsr/emul/lang/java_lang_String.js",
3.9 processByteCode=true
3.10 )
3.11 @JavaScriptPrototype(container = "String.prototype", prototype = "new String")
4.1 --- a/emul/mini/src/main/java/java/lang/reflect/Method.java Wed Jan 23 20:39:23 2013 +0100
4.2 +++ b/emul/mini/src/main/java/java/lang/reflect/Method.java Wed Jan 23 20:52:11 2013 +0100
4.3 @@ -28,8 +28,8 @@
4.4 import java.lang.annotation.Annotation;
4.5 import java.util.Enumeration;
4.6 import org.apidesign.bck2brwsr.core.JavaScriptBody;
4.7 -import org.apidesign.bck2brwsr.emul.AnnotationImpl;
4.8 -import org.apidesign.bck2brwsr.emul.MethodImpl;
4.9 +import org.apidesign.bck2brwsr.emul.reflect.AnnotationImpl;
4.10 +import org.apidesign.bck2brwsr.emul.reflect.MethodImpl;
4.11
4.12 /**
4.13 * A {@code Method} provides information about, and access to, a single method
5.1 --- a/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/AnnotationImpl.java Wed Jan 23 20:39:23 2013 +0100
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,81 +0,0 @@
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.emul;
5.22 -
5.23 -import java.lang.annotation.Annotation;
5.24 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
5.25 -
5.26 -/**
5.27 - *
5.28 - * @author Jaroslav Tulach <jtulach@netbeans.org>
5.29 - */
5.30 -public final class AnnotationImpl implements Annotation {
5.31 - public Class<? extends Annotation> annotationType() {
5.32 - return getClass();
5.33 - }
5.34 -
5.35 - @JavaScriptBody(args = { "a", "n", "values" }, body = ""
5.36 - + "function f(v, p) {\n"
5.37 - + " var val = v;\n"
5.38 - + " var prop = p;\n"
5.39 - + " return function() {\n"
5.40 - + " return val[prop];\n"
5.41 - + " };\n"
5.42 - + "}\n"
5.43 - + "var props = Object.getOwnPropertyNames(values);\n"
5.44 - + "for (var i = 0; i < props.length; i++) {\n"
5.45 - + " var p = props[i];\n"
5.46 - + " a[p] = new f(values, p);\n"
5.47 - + "}\n"
5.48 - + "a['$instOf_' + n] = true;\n"
5.49 - + "return a;"
5.50 - )
5.51 - private static <T extends Annotation> T create(AnnotationImpl a, String n, Object values) {
5.52 - return null;
5.53 - }
5.54 - public static <T extends Annotation> T create(Class<T> annoClass, Object values) {
5.55 - return create(new AnnotationImpl(), annoClass.getName().replace('.', '_'), values);
5.56 - }
5.57 -
5.58 - public static Annotation[] create(Object anno) {
5.59 - String[] names = findNames(anno);
5.60 - Annotation[] ret = new Annotation[names.length];
5.61 - for (int i = 0; i < names.length; i++) {
5.62 - String n = names[i].substring(1, names[i].length() - 1).replace('/', '_');
5.63 - ret[i] = create(new AnnotationImpl(), n, findData(anno, names[i]));
5.64 - }
5.65 - return ret;
5.66 - }
5.67 - @JavaScriptBody(args = "anno", body =
5.68 - "var arr = new Array();"
5.69 - + "var props = Object.getOwnPropertyNames(anno);\n"
5.70 - + "for (var i = 0; i < props.length; i++) {\n"
5.71 - + " var p = props[i];\n"
5.72 - + " arr.push(p);"
5.73 - + "}"
5.74 - + "return arr;"
5.75 - )
5.76 - private static String[] findNames(Object anno) {
5.77 - throw new UnsupportedOperationException();
5.78 - }
5.79 -
5.80 - @JavaScriptBody(args={ "anno", "p"}, body="return anno[p];")
5.81 - private static Object findData(Object anno, String p) {
5.82 - throw new UnsupportedOperationException();
5.83 - }
5.84 -}
6.1 --- a/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/MethodImpl.java Wed Jan 23 20:39:23 2013 +0100
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,164 +0,0 @@
6.4 -/*
6.5 - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
6.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6.7 - *
6.8 - * This code is free software; you can redistribute it and/or modify it
6.9 - * under the terms of the GNU General Public License version 2 only, as
6.10 - * published by the Free Software Foundation. Oracle designates this
6.11 - * particular file as subject to the "Classpath" exception as provided
6.12 - * by Oracle in the LICENSE file that accompanied this code.
6.13 - *
6.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
6.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6.17 - * version 2 for more details (a copy is included in the LICENSE file that
6.18 - * accompanied this code).
6.19 - *
6.20 - * You should have received a copy of the GNU General Public License version
6.21 - * 2 along with this work; if not, write to the Free Software Foundation,
6.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6.23 - *
6.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6.25 - * or visit www.oracle.com if you need additional information or have any
6.26 - * questions.
6.27 - */
6.28 -package org.apidesign.bck2brwsr.emul;
6.29 -
6.30 -import java.lang.reflect.Method;
6.31 -import java.util.Enumeration;
6.32 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
6.33 -
6.34 -/** Utilities to work on methods.
6.35 - *
6.36 - * @author Jaroslav Tulach <jtulach@netbeans.org>
6.37 - */
6.38 -public abstract class MethodImpl {
6.39 - public static MethodImpl INSTANCE;
6.40 - static {
6.41 - try {
6.42 - Class.forName(Method.class.getName());
6.43 - } catch (ClassNotFoundException ex) {
6.44 - throw new IllegalStateException(ex);
6.45 - }
6.46 - }
6.47 -
6.48 - protected abstract Method create(Class<?> declaringClass, String name, Object data, String sig);
6.49 -
6.50 -
6.51 - //
6.52 - // bck2brwsr implementation
6.53 - //
6.54 -
6.55 - @JavaScriptBody(args = {"clazz", "prefix"},
6.56 - body = ""
6.57 - + "var c = clazz.cnstr.prototype;"
6.58 - + "var arr = new Array();\n"
6.59 - + "for (m in c) {\n"
6.60 - + " if (m.indexOf(prefix) === 0) {\n"
6.61 - + " arr.push(m);\n"
6.62 - + " arr.push(c[m]);\n"
6.63 - + " }"
6.64 - + "}\n"
6.65 - + "return arr;")
6.66 - private static native Object[] findMethodData(
6.67 - Class<?> clazz, String prefix);
6.68 -
6.69 - public static Method findMethod(
6.70 - Class<?> clazz, String name, Class<?>... parameterTypes) {
6.71 - Object[] data = findMethodData(clazz, name + "__");
6.72 - BIG: for (int i = 0; i < data.length; i += 2) {
6.73 - String sig = ((String) data[0]).substring(name.length() + 2);
6.74 - Method tmp = INSTANCE.create(clazz, name, data[1], sig);
6.75 - Class<?>[] tmpParms = tmp.getParameterTypes();
6.76 - if (parameterTypes.length != tmpParms.length) {
6.77 - continue;
6.78 - }
6.79 - for (int j = 0; j < tmpParms.length; j++) {
6.80 - if (!parameterTypes[j].equals(tmpParms[j])) {
6.81 - continue BIG;
6.82 - }
6.83 - }
6.84 - return tmp;
6.85 - }
6.86 - return null;
6.87 - }
6.88 -
6.89 - public static Method[] findMethods(Class<?> clazz, int mask) {
6.90 - Object[] namesAndData = findMethodData(clazz, "");
6.91 - int cnt = 0;
6.92 - for (int i = 0; i < namesAndData.length; i += 2) {
6.93 - String sig = (String) namesAndData[i];
6.94 - Object data = namesAndData[i + 1];
6.95 - int middle = sig.indexOf("__");
6.96 - if (middle == -1) {
6.97 - continue;
6.98 - }
6.99 - String name = sig.substring(0, middle);
6.100 - sig = sig.substring(middle + 2);
6.101 - final Method m = INSTANCE.create(clazz, name, data, sig);
6.102 - if ((m.getModifiers() & mask) == 0) {
6.103 - continue;
6.104 - }
6.105 - namesAndData[cnt++] = m;
6.106 - }
6.107 - Method[] arr = new Method[cnt];
6.108 - for (int i = 0; i < cnt; i++) {
6.109 - arr[i] = (Method) namesAndData[i];
6.110 - }
6.111 - return arr;
6.112 - }
6.113 -
6.114 - public static int signatureElements(String sig) {
6.115 - Enumeration<Class> en = signatureParser(sig);
6.116 - int cnt = 0;
6.117 - while (en.hasMoreElements()) {
6.118 - en.nextElement();
6.119 - cnt++;
6.120 - }
6.121 - return cnt;
6.122 - }
6.123 -
6.124 - public static Enumeration<Class> signatureParser(final String sig) {
6.125 - class E implements Enumeration<Class> {
6.126 - int pos;
6.127 -
6.128 - public boolean hasMoreElements() {
6.129 - return pos < sig.length();
6.130 - }
6.131 -
6.132 - public Class nextElement() {
6.133 - switch (sig.charAt(pos++)) {
6.134 - case 'I':
6.135 - return Integer.TYPE;
6.136 - case 'J':
6.137 - return Long.TYPE;
6.138 - case 'D':
6.139 - return Double.TYPE;
6.140 - case 'F':
6.141 - return Float.TYPE;
6.142 - case 'B':
6.143 - return Byte.TYPE;
6.144 - case 'Z':
6.145 - return Boolean.TYPE;
6.146 - case 'S':
6.147 - return Short.TYPE;
6.148 - case 'V':
6.149 - return Void.TYPE;
6.150 - case 'C':
6.151 - return Character.TYPE;
6.152 - case 'L':
6.153 - try {
6.154 - int up = sig.indexOf("_2");
6.155 - String type = sig.substring(1, up);
6.156 - pos = up + 2;
6.157 - return Class.forName(type);
6.158 - } catch (ClassNotFoundException ex) {
6.159 - // should not happen
6.160 - }
6.161 - }
6.162 - throw new UnsupportedOperationException(sig + " at " + pos);
6.163 - }
6.164 - }
6.165 - return new E();
6.166 - }
6.167 -}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/reflect/AnnotationImpl.java Wed Jan 23 20:52:11 2013 +0100
7.3 @@ -0,0 +1,81 @@
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 +package org.apidesign.bck2brwsr.emul.reflect;
7.22 +
7.23 +import java.lang.annotation.Annotation;
7.24 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
7.25 +
7.26 +/**
7.27 + *
7.28 + * @author Jaroslav Tulach <jtulach@netbeans.org>
7.29 + */
7.30 +public final class AnnotationImpl implements Annotation {
7.31 + public Class<? extends Annotation> annotationType() {
7.32 + return getClass();
7.33 + }
7.34 +
7.35 + @JavaScriptBody(args = { "a", "n", "values" }, body = ""
7.36 + + "function f(v, p) {\n"
7.37 + + " var val = v;\n"
7.38 + + " var prop = p;\n"
7.39 + + " return function() {\n"
7.40 + + " return val[prop];\n"
7.41 + + " };\n"
7.42 + + "}\n"
7.43 + + "var props = Object.getOwnPropertyNames(values);\n"
7.44 + + "for (var i = 0; i < props.length; i++) {\n"
7.45 + + " var p = props[i];\n"
7.46 + + " a[p] = new f(values, p);\n"
7.47 + + "}\n"
7.48 + + "a['$instOf_' + n] = true;\n"
7.49 + + "return a;"
7.50 + )
7.51 + private static <T extends Annotation> T create(AnnotationImpl a, String n, Object values) {
7.52 + return null;
7.53 + }
7.54 + public static <T extends Annotation> T create(Class<T> annoClass, Object values) {
7.55 + return create(new AnnotationImpl(), annoClass.getName().replace('.', '_'), values);
7.56 + }
7.57 +
7.58 + public static Annotation[] create(Object anno) {
7.59 + String[] names = findNames(anno);
7.60 + Annotation[] ret = new Annotation[names.length];
7.61 + for (int i = 0; i < names.length; i++) {
7.62 + String n = names[i].substring(1, names[i].length() - 1).replace('/', '_');
7.63 + ret[i] = create(new AnnotationImpl(), n, findData(anno, names[i]));
7.64 + }
7.65 + return ret;
7.66 + }
7.67 + @JavaScriptBody(args = "anno", body =
7.68 + "var arr = new Array();"
7.69 + + "var props = Object.getOwnPropertyNames(anno);\n"
7.70 + + "for (var i = 0; i < props.length; i++) {\n"
7.71 + + " var p = props[i];\n"
7.72 + + " arr.push(p);"
7.73 + + "}"
7.74 + + "return arr;"
7.75 + )
7.76 + private static String[] findNames(Object anno) {
7.77 + throw new UnsupportedOperationException();
7.78 + }
7.79 +
7.80 + @JavaScriptBody(args={ "anno", "p"}, body="return anno[p];")
7.81 + private static Object findData(Object anno, String p) {
7.82 + throw new UnsupportedOperationException();
7.83 + }
7.84 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/reflect/MethodImpl.java Wed Jan 23 20:52:11 2013 +0100
8.3 @@ -0,0 +1,164 @@
8.4 +/*
8.5 + * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8.7 + *
8.8 + * This code is free software; you can redistribute it and/or modify it
8.9 + * under the terms of the GNU General Public License version 2 only, as
8.10 + * published by the Free Software Foundation. Oracle designates this
8.11 + * particular file as subject to the "Classpath" exception as provided
8.12 + * by Oracle in the LICENSE file that accompanied this code.
8.13 + *
8.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
8.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8.17 + * version 2 for more details (a copy is included in the LICENSE file that
8.18 + * accompanied this code).
8.19 + *
8.20 + * You should have received a copy of the GNU General Public License version
8.21 + * 2 along with this work; if not, write to the Free Software Foundation,
8.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8.23 + *
8.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8.25 + * or visit www.oracle.com if you need additional information or have any
8.26 + * questions.
8.27 + */
8.28 +package org.apidesign.bck2brwsr.emul.reflect;
8.29 +
8.30 +import java.lang.reflect.Method;
8.31 +import java.util.Enumeration;
8.32 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
8.33 +
8.34 +/** Utilities to work on methods.
8.35 + *
8.36 + * @author Jaroslav Tulach <jtulach@netbeans.org>
8.37 + */
8.38 +public abstract class MethodImpl {
8.39 + public static MethodImpl INSTANCE;
8.40 + static {
8.41 + try {
8.42 + Class.forName(Method.class.getName());
8.43 + } catch (ClassNotFoundException ex) {
8.44 + throw new IllegalStateException(ex);
8.45 + }
8.46 + }
8.47 +
8.48 + protected abstract Method create(Class<?> declaringClass, String name, Object data, String sig);
8.49 +
8.50 +
8.51 + //
8.52 + // bck2brwsr implementation
8.53 + //
8.54 +
8.55 + @JavaScriptBody(args = {"clazz", "prefix"},
8.56 + body = ""
8.57 + + "var c = clazz.cnstr.prototype;"
8.58 + + "var arr = new Array();\n"
8.59 + + "for (m in c) {\n"
8.60 + + " if (m.indexOf(prefix) === 0) {\n"
8.61 + + " arr.push(m);\n"
8.62 + + " arr.push(c[m]);\n"
8.63 + + " }"
8.64 + + "}\n"
8.65 + + "return arr;")
8.66 + private static native Object[] findMethodData(
8.67 + Class<?> clazz, String prefix);
8.68 +
8.69 + public static Method findMethod(
8.70 + Class<?> clazz, String name, Class<?>... parameterTypes) {
8.71 + Object[] data = findMethodData(clazz, name + "__");
8.72 + BIG: for (int i = 0; i < data.length; i += 2) {
8.73 + String sig = ((String) data[0]).substring(name.length() + 2);
8.74 + Method tmp = INSTANCE.create(clazz, name, data[1], sig);
8.75 + Class<?>[] tmpParms = tmp.getParameterTypes();
8.76 + if (parameterTypes.length != tmpParms.length) {
8.77 + continue;
8.78 + }
8.79 + for (int j = 0; j < tmpParms.length; j++) {
8.80 + if (!parameterTypes[j].equals(tmpParms[j])) {
8.81 + continue BIG;
8.82 + }
8.83 + }
8.84 + return tmp;
8.85 + }
8.86 + return null;
8.87 + }
8.88 +
8.89 + public static Method[] findMethods(Class<?> clazz, int mask) {
8.90 + Object[] namesAndData = findMethodData(clazz, "");
8.91 + int cnt = 0;
8.92 + for (int i = 0; i < namesAndData.length; i += 2) {
8.93 + String sig = (String) namesAndData[i];
8.94 + Object data = namesAndData[i + 1];
8.95 + int middle = sig.indexOf("__");
8.96 + if (middle == -1) {
8.97 + continue;
8.98 + }
8.99 + String name = sig.substring(0, middle);
8.100 + sig = sig.substring(middle + 2);
8.101 + final Method m = INSTANCE.create(clazz, name, data, sig);
8.102 + if ((m.getModifiers() & mask) == 0) {
8.103 + continue;
8.104 + }
8.105 + namesAndData[cnt++] = m;
8.106 + }
8.107 + Method[] arr = new Method[cnt];
8.108 + for (int i = 0; i < cnt; i++) {
8.109 + arr[i] = (Method) namesAndData[i];
8.110 + }
8.111 + return arr;
8.112 + }
8.113 +
8.114 + public static int signatureElements(String sig) {
8.115 + Enumeration<Class> en = signatureParser(sig);
8.116 + int cnt = 0;
8.117 + while (en.hasMoreElements()) {
8.118 + en.nextElement();
8.119 + cnt++;
8.120 + }
8.121 + return cnt;
8.122 + }
8.123 +
8.124 + public static Enumeration<Class> signatureParser(final String sig) {
8.125 + class E implements Enumeration<Class> {
8.126 + int pos;
8.127 +
8.128 + public boolean hasMoreElements() {
8.129 + return pos < sig.length();
8.130 + }
8.131 +
8.132 + public Class nextElement() {
8.133 + switch (sig.charAt(pos++)) {
8.134 + case 'I':
8.135 + return Integer.TYPE;
8.136 + case 'J':
8.137 + return Long.TYPE;
8.138 + case 'D':
8.139 + return Double.TYPE;
8.140 + case 'F':
8.141 + return Float.TYPE;
8.142 + case 'B':
8.143 + return Byte.TYPE;
8.144 + case 'Z':
8.145 + return Boolean.TYPE;
8.146 + case 'S':
8.147 + return Short.TYPE;
8.148 + case 'V':
8.149 + return Void.TYPE;
8.150 + case 'C':
8.151 + return Character.TYPE;
8.152 + case 'L':
8.153 + try {
8.154 + int up = sig.indexOf("_2");
8.155 + String type = sig.substring(1, up);
8.156 + pos = up + 2;
8.157 + return Class.forName(type);
8.158 + } catch (ClassNotFoundException ex) {
8.159 + // should not happen
8.160 + }
8.161 + }
8.162 + throw new UnsupportedOperationException(sig + " at " + pos);
8.163 + }
8.164 + }
8.165 + return new E();
8.166 + }
8.167 +}
9.1 --- a/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_Number.js Wed Jan 23 20:39:23 2013 +0100
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,9 +0,0 @@
9.4 -// empty line needed here
9.5 -Number.prototype.add32 = function(x) { return (this + x) | 0; };
9.6 -Number.prototype.sub32 = function(x) { return (this - x) | 0; };
9.7 -Number.prototype.mul32 = function(x) {
9.8 - return (((this * (x >> 16)) << 16) + this * (x & 0xFFFF)) | 0;
9.9 -};
9.10 -
9.11 -Number.prototype.toInt8 = function() { return (this << 24) >> 24; };
9.12 -Number.prototype.toInt16 = function() { return (this << 16) >> 16; };
9.13 \ No newline at end of file
10.1 --- a/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_String.js Wed Jan 23 20:39:23 2013 +0100
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,26 +0,0 @@
10.4 -// initialize methods on arrays and String constants
10.5 -vm.java_lang_reflect_Array(false);
10.6 -vm.java_lang_String(false);
10.7 -
10.8 -Array.prototype.at = function(indx, value) {
10.9 - if (indx < 0 || indx > this.length) {
10.10 - var e = vm.java_lang_ArrayIndexOutOfBoundsException(true);
10.11 - e.constructor.cons__VLjava_lang_String_2.call(e, indx.toString());
10.12 - throw e;
10.13 - }
10.14 - if (arguments.length === 2) {
10.15 - this[indx] = value;
10.16 - }
10.17 - return this[indx];
10.18 -};
10.19 -Array.prototype.getClass__Ljava_lang_Class_2 = function() {
10.20 - return vm.java_lang_Class(false).defineArray__Ljava_lang_Class_2Ljava_lang_String_2(this.jvmName);
10.21 -};
10.22 -Array.prototype.clone__Ljava_lang_Object_2 = function() {
10.23 - var s = this.length;
10.24 - var ret = new Array(s);
10.25 - for (var i = 0; i < s; i++) {
10.26 - ret[i] = this[i];
10.27 - }
10.28 - return ret;
10.29 -};
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Wed Jan 23 20:52:11 2013 +0100
11.3 @@ -0,0 +1,9 @@
11.4 +// empty line needed here
11.5 +Number.prototype.add32 = function(x) { return (this + x) | 0; };
11.6 +Number.prototype.sub32 = function(x) { return (this - x) | 0; };
11.7 +Number.prototype.mul32 = function(x) {
11.8 + return (((this * (x >> 16)) << 16) + this * (x & 0xFFFF)) | 0;
11.9 +};
11.10 +
11.11 +Number.prototype.toInt8 = function() { return (this << 24) >> 24; };
11.12 +Number.prototype.toInt16 = function() { return (this << 16) >> 16; };
11.13 \ No newline at end of file
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_String.js Wed Jan 23 20:52:11 2013 +0100
12.3 @@ -0,0 +1,26 @@
12.4 +// initialize methods on arrays and String constants
12.5 +vm.java_lang_reflect_Array(false);
12.6 +vm.java_lang_String(false);
12.7 +
12.8 +Array.prototype.at = function(indx, value) {
12.9 + if (indx < 0 || indx > this.length) {
12.10 + var e = vm.java_lang_ArrayIndexOutOfBoundsException(true);
12.11 + e.constructor.cons__VLjava_lang_String_2.call(e, indx.toString());
12.12 + throw e;
12.13 + }
12.14 + if (arguments.length === 2) {
12.15 + this[indx] = value;
12.16 + }
12.17 + return this[indx];
12.18 +};
12.19 +Array.prototype.getClass__Ljava_lang_Class_2 = function() {
12.20 + return vm.java_lang_Class(false).defineArray__Ljava_lang_Class_2Ljava_lang_String_2(this.jvmName);
12.21 +};
12.22 +Array.prototype.clone__Ljava_lang_Object_2 = function() {
12.23 + var s = this.length;
12.24 + var ret = new Array(s);
12.25 + for (var i = 0; i < s; i++) {
12.26 + ret[i] = this[i];
12.27 + }
12.28 + return ret;
12.29 +};