Fixes some problems in the JRE numeric emulation and adds the missing Void type.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1453 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/super/com/google/gwt/emul/java/lang/Double.java b/user/super/com/google/gwt/emul/java/lang/Double.java
index dfce6c4..bd13405 100644
--- a/user/super/com/google/gwt/emul/java/lang/Double.java
+++ b/user/super/com/google/gwt/emul/java/lang/Double.java
@@ -58,6 +58,10 @@
return String.valueOf(b);
}
+ public static Double valueOf(double d) {
+ return new Double(d);
+ }
+
public static Double valueOf(String s) throws NumberFormatException {
return new Double(Double.parseDouble(s));
}
diff --git a/user/super/com/google/gwt/emul/java/lang/Float.java b/user/super/com/google/gwt/emul/java/lang/Float.java
index 9c2258b..8dd73fe 100644
--- a/user/super/com/google/gwt/emul/java/lang/Float.java
+++ b/user/super/com/google/gwt/emul/java/lang/Float.java
@@ -51,13 +51,17 @@
}-*/;
public static float parseFloat(String s) throws NumberFormatException {
- return (float)__parseAndValidateDouble(s);
+ return (float) __parseAndValidateDouble(s);
}
public static String toString(float b) {
return String.valueOf(b);
}
+ public static Float valueOf(float f) {
+ return new Float(f);
+ }
+
public static Float valueOf(String s) throws NumberFormatException {
return new Float(Float.parseFloat(s));
}
diff --git a/user/super/com/google/gwt/emul/java/lang/Integer.java b/user/super/com/google/gwt/emul/java/lang/Integer.java
index 3b2299d..d21d1f0 100644
--- a/user/super/com/google/gwt/emul/java/lang/Integer.java
+++ b/user/super/com/google/gwt/emul/java/lang/Integer.java
@@ -71,7 +71,7 @@
}
public static Integer valueOf(int i) {
- if (i > -129 || i < 128) {
+ if (i > -129 && i < 128) {
int rebase = i + 128;
if (boxedValues[rebase] == null) {
boxedValues[rebase] = new Integer(i);
diff --git a/user/super/com/google/gwt/emul/java/lang/Long.java b/user/super/com/google/gwt/emul/java/lang/Long.java
index 4a03cb5..ba8e9e7 100644
--- a/user/super/com/google/gwt/emul/java/lang/Long.java
+++ b/user/super/com/google/gwt/emul/java/lang/Long.java
@@ -1,12 +1,12 @@
/*
* Copyright 2007 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -22,6 +22,9 @@
public static final long MIN_VALUE = 0x8000000000000000L;
public static final long MAX_VALUE = 0x7fffffffffffffffL;
+ // Box values according to JLS - between -128 and 127
+ private static Long[] boxedValues = new Long[256];
+
public static Long decode(String s) throws NumberFormatException {
return new Long(__decodeAndValidateLong(s, MIN_VALUE, MAX_VALUE));
}
@@ -72,6 +75,17 @@
return String.valueOf(b);
}
+ public static Long valueOf(long i) {
+ if (i > -129 && i < 128) {
+ int rebase = (int) i + 128;
+ if (boxedValues[rebase] == null) {
+ boxedValues[rebase] = new Long(i);
+ }
+ return boxedValues[rebase];
+ }
+ return new Long(i);
+ }
+
public static Long valueOf(String s) throws NumberFormatException {
return new Long(Long.parseLong(s));
}
diff --git a/user/super/com/google/gwt/emul/java/lang/Short.java b/user/super/com/google/gwt/emul/java/lang/Short.java
index 180edb3..20f7197 100644
--- a/user/super/com/google/gwt/emul/java/lang/Short.java
+++ b/user/super/com/google/gwt/emul/java/lang/Short.java
@@ -51,7 +51,7 @@
}
public static Short valueOf(short s) {
- if (s > -129 || s < 128) {
+ if (s > -129 && s < 128) {
int rebase = s + 128;
if (boxedValues[rebase] == null) {
boxedValues[rebase] = new Short(s);
diff --git a/user/super/com/google/gwt/emul/java/lang/Void.java b/user/super/com/google/gwt/emul/java/lang/Void.java
new file mode 100644
index 0000000..66a7830
--- /dev/null
+++ b/user/super/com/google/gwt/emul/java/lang/Void.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package java.lang;
+
+/**
+ * For JRE compatibility.
+ */
+public final class Void {
+
+ /**
+ * Not instantiable.
+ */
+ private Void() {
+ }
+
+}