Fixes broken serializability of StackTraceElement
Reviewed by robertvawter
Tested via RPCSuite
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@4940 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/rpc/core/java/lang/StackTraceElement_CustomFieldSerializer.java b/user/src/com/google/gwt/user/client/rpc/core/java/lang/StackTraceElement_CustomFieldSerializer.java
new file mode 100644
index 0000000..26184ff
--- /dev/null
+++ b/user/src/com/google/gwt/user/client/rpc/core/java/lang/StackTraceElement_CustomFieldSerializer.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2009 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 com.google.gwt.user.client.rpc.core.java.lang;
+
+import com.google.gwt.user.client.rpc.SerializationException;
+import com.google.gwt.user.client.rpc.SerializationStreamReader;
+import com.google.gwt.user.client.rpc.SerializationStreamWriter;
+
+/**
+ * Custom field serializer for {@link java.lang.StackTraceElement}.
+ */
+public final class StackTraceElement_CustomFieldSerializer {
+
+ public static void deserialize(SerializationStreamReader streamReader,
+ StackTraceElement instance) {
+ // No fields
+ }
+
+ public static StackTraceElement instantiate(SerializationStreamReader streamReader)
+ throws SerializationException {
+ return new StackTraceElement(streamReader.readString(),
+ streamReader.readString(),
+ streamReader.readString(),
+ streamReader.readInt());
+ }
+
+ public static void serialize(SerializationStreamWriter streamWriter,
+ StackTraceElement instance) throws SerializationException {
+ streamWriter.writeString(instance.getClassName());
+ streamWriter.writeString(instance.getMethodName());
+ streamWriter.writeString(instance.getFileName());
+ streamWriter.writeInt(instance.getLineNumber());
+ }
+}
diff --git a/user/test/com/google/gwt/user/client/rpc/CustomFieldSerializerTestSetValidator.java b/user/test/com/google/gwt/user/client/rpc/CustomFieldSerializerTestSetValidator.java
index cee790c..2012fa3 100644
--- a/user/test/com/google/gwt/user/client/rpc/CustomFieldSerializerTestSetValidator.java
+++ b/user/test/com/google/gwt/user/client/rpc/CustomFieldSerializerTestSetValidator.java
@@ -27,11 +27,16 @@
if (manuallySerializedClass == null) {
return false;
}
+
+ StackTraceElement ste = manuallySerializedClass.getStackTraceElement();
return manuallySerializedClass.getA() == 4
&& manuallySerializedClass.getB() == 5
&& manuallySerializedClass.getC() == 6
- && manuallySerializedClass.getString().equals("bye");
+ && manuallySerializedClass.getString().equals("bye")
+ && ste.getClassName().equals("HighClass")
+ && ste.getMethodName().equals("highClassMethod")
+ && ste.getFileName().equals("HighClass.java");
}
// Must be a non-null array with two == elements
diff --git a/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass.java b/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass.java
index 28069e4..22e2099 100644
--- a/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass.java
+++ b/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass.java
@@ -30,6 +30,9 @@
private int c = 3;
private String str = "hello";
+
+ private StackTraceElement ste = new StackTraceElement("FakeClass",
+ "fakeMethod", "FakeClass.java", 1234);
public int getA() {
return a;
@@ -46,6 +49,10 @@
public String getString() {
return str;
}
+
+ public StackTraceElement getStackTraceElement() {
+ return ste;
+ }
public void setA(int a) {
this.a = a;
@@ -62,4 +69,8 @@
public void setString(String str) {
this.str = str;
}
+
+ public void setStackTraceElement(StackTraceElement ste) {
+ this.ste = ste;
+ }
}
\ No newline at end of file
diff --git a/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass_CustomFieldSerializer.java b/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass_CustomFieldSerializer.java
index f251207..70c2495 100644
--- a/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass_CustomFieldSerializer.java
+++ b/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass_CustomFieldSerializer.java
@@ -27,6 +27,7 @@
instance.setB(streamReader.readInt());
instance.setC(streamReader.readInt());
instance.setString(streamReader.readString());
+ instance.setStackTraceElement((StackTraceElement)streamReader.readObject());
}
public static void serialize(SerializationStreamWriter streamWriter,
@@ -35,5 +36,7 @@
streamWriter.writeInt(5);
streamWriter.writeInt(6);
streamWriter.writeString("bye");
+ streamWriter.writeObject(new StackTraceElement("HighClass",
+ "highClassMethod", "HighClass.java", 5789));
}
}
\ No newline at end of file