Fix for the RemoteServiceServletTest problem. The issue is that Mozilla only
supports 31-bit ints, so we have to detect that an integer won't fit in 31
bits and instead store it in a double. We do this by making sure the top
two bits are equal, which means the 31-bit value when sign-extended will
result in the same value. The library was then rebuilt on an older Linux
machine so the library will work on such machines.
A new test for this issue was added to HostedTest.
Review by: scottb
mmendez
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@671 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/jni/linux/JsRootedValue.h b/jni/linux/JsRootedValue.h
index 49df6ce..6f8a405 100644
--- a/jni/linux/JsRootedValue.h
+++ b/jni/linux/JsRootedValue.h
@@ -245,7 +245,13 @@
* Returns false on failure.
*/
bool setInt(int val) {
- return setValue(INT_TO_JSVAL(val));
+ // check if it fits in 31 bits (ie top two bits are equal).
+ // if not, store it as a double
+ if ((val & 0x80000000) != ((val << 1) & 0x80000000)) {
+ return setDouble(val);
+ } else {
+ return setValue(INT_TO_JSVAL(val));
+ }
}
/*
diff --git a/jni/linux/prebuilt/libgwt-ll.so b/jni/linux/prebuilt/libgwt-ll.so
index 0842d03..87b842a 100755
--- a/jni/linux/prebuilt/libgwt-ll.so
+++ b/jni/linux/prebuilt/libgwt-ll.so
Binary files differ
diff --git a/user/test/com/google/gwt/dev/jjs/test/HostedTest.java b/user/test/com/google/gwt/dev/jjs/test/HostedTest.java
index 5deb0d1..bae732e 100644
--- a/user/test/com/google/gwt/dev/jjs/test/HostedTest.java
+++ b/user/test/com/google/gwt/dev/jjs/test/HostedTest.java
@@ -88,19 +88,23 @@
private static native Object getStringAsObject() /*-{
return "test";
}-*/;
-
+
private static native void storeFloat(float f) /*-{
myFloatValue = f;
}-*/;
-
+
private static native float getFloat() /*-{
return myFloatValue;
}-*/;
-
+
private static native float getFloatString() /*-{
return Number(myFloatValue.toString());
}-*/;
+ private static native int passThroughInt(int val) /*-{
+ return val;
+ }-*/;
+
private static native JavaScriptObject getsFooFunc() /*-{
return @com.google.gwt.dev.jjs.test.HostedTest::sFoo(Ljava/lang/String;);
}-*/;
@@ -148,7 +152,12 @@
Object oout = getObject(oin);
assertEquals(oin, oout);
}
-
+
+ public void test32BitInt() {
+ assertEquals(Integer.MAX_VALUE, passThroughInt(Integer.MAX_VALUE));
+ assertEquals(Integer.MIN_VALUE, passThroughInt(Integer.MIN_VALUE));
+ }
+
public void testByteMarshalling() {
byte b = 100;
assertEquals(100, byteAsInt(b));