Author: [email protected]
Date: Thu Mar  5 09:20:03 2009
New Revision: 4940

Added:
     
trunk/user/src/com/google/gwt/user/client/rpc/core/java/lang/StackTraceElement_CustomFieldSerializer.java
Modified:
     
trunk/user/test/com/google/gwt/user/client/rpc/CustomFieldSerializerTestSetValidator.java
     
trunk/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass.java
     
trunk/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass_CustomFieldSerializer.java

Log:
Fixes broken serializability of StackTraceElement

Reviewed by robertvawter
Tested via RPCSuite




Added:  
trunk/user/src/com/google/gwt/user/client/rpc/core/java/lang/StackTraceElement_CustomFieldSerializer.java
==============================================================================
--- (empty file)
+++  
trunk/user/src/com/google/gwt/user/client/rpc/core/java/lang/StackTraceElement_CustomFieldSerializer.java
        
Thu Mar  5 09:20:03 2009
@@ -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());
+  }
+}

Modified:  
trunk/user/test/com/google/gwt/user/client/rpc/CustomFieldSerializerTestSetValidator.java
==============================================================================
---  
trunk/user/test/com/google/gwt/user/client/rpc/CustomFieldSerializerTestSetValidator.java
        
(original)
+++  
trunk/user/test/com/google/gwt/user/client/rpc/CustomFieldSerializerTestSetValidator.java
        
Thu Mar  5 09:20:03 2009
@@ -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

Modified:  
trunk/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass.java
==============================================================================
---  
trunk/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass.java     
 
(original)
+++  
trunk/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass.java     
 
Thu Mar  5 09:20:03 2009
@@ -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;
@@ -61,5 +68,9 @@

    public void setString(String str) {
      this.str = str;
+  }
+
+  public void setStackTraceElement(StackTraceElement ste) {
+    this.ste = ste;
    }
  }

Modified:  
trunk/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass_CustomFieldSerializer.java
==============================================================================
---  
trunk/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass_CustomFieldSerializer.java
        
(original)
+++  
trunk/user/test/com/google/gwt/user/client/rpc/ManuallySerializedClass_CustomFieldSerializer.java
        
Thu Mar  5 09:20:03 2009
@@ -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));
    }
  }

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to