]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for 168063 - incorrectly tagging a field as transient
authoraclement <aclement>
Wed, 10 Jan 2007 16:10:56 +0000 (16:10 +0000)
committeraclement <aclement>
Wed, 10 Jan 2007 16:10:56 +0000 (16:10 +0000)
tests/bugs160/pr168063/A.java [new file with mode: 0644]
tests/features152/synthetic/TheWholeShow.aj
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
tests/src/org/aspectj/systemtest/ajc160/Ajc160Tests.java
tests/src/org/aspectj/systemtest/ajc160/ajc160.xml

diff --git a/tests/bugs160/pr168063/A.java b/tests/bugs160/pr168063/A.java
new file mode 100644 (file)
index 0000000..c4831ff
--- /dev/null
@@ -0,0 +1,40 @@
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+
+public class A {
+  public static void main(String[] args) throws Exception {
+    A obj1 = new A();
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ObjectOutputStream oos = new ObjectOutputStream(baos);
+    oos.writeObject(obj1);
+    oos.close();
+    byte[] data = baos.toByteArray();
+    
+    ByteArrayInputStream bais = new ByteArrayInputStream(data);
+    ObjectInputStream ois = new ObjectInputStream(bais);
+    Object o = ois.readObject();
+    
+    int before = ((Persistable)obj1).getPersistableId();
+    int after = ((Persistable)o).getPersistableId();
+    if (before!=after) 
+       System.out.println("The data was lost! before="+before+" after="+after);
+    else
+       System.out.println("It worked, data preserved!");
+  }
+}
+
+interface Persistable extends Serializable {
+  abstract public int getPersistableId();
+}
+
+aspect PersistableImpl {
+  declare parents: A extends Persistable;
+
+  final public int Persistable.persistableId = 42;
+  public int Persistable.getPersistableId() { return persistableId; }
+}
index 0fa1c664260538ad6e9a1bc31418b8282369084f..bd91561c77620aac7e3bbfb2943f707cbe7ab70f 100644 (file)
@@ -11,7 +11,7 @@ public class TheWholeShow {
   public static void main(String[] args) {
     Field[] twsFields = TheWholeShow.class.getDeclaredFields();
     for (Field f : twsFields) {
-      if (!f.getName().equals("f") && !f.getName().equals("x")) {
+      if (!f.getName().equals("f") && !f.getName().equals("x")  && !f.getName().startsWith("ajc$interField$")) {
         if (!f.isSynthetic()) {
           System.err.println("Found non-synthetic field: " + f.getName());
           throw new IllegalStateException("Found non-synthetic field: " + f.getName());
index 1ca3b4b593e711b8c5c52414ef43d1067fe2f019..cac2835053e6eddac2e923fc4a5e60679b6d4bc5 100644 (file)
@@ -84,7 +84,7 @@
       <run class="Declaration1">
         <stdout>
           <line text="public java.lang.String Test.firstProperty has annotation:true"/>
-          <line text="public transient java.lang.String Test.ajc$interField$Declaration1$TestInterface$secondProperty has annotation:true"/>
+          <line text="public java.lang.String Test.ajc$interField$Declaration1$TestInterface$secondProperty has annotation:true"/>
         </stdout>
       </run>
     </ajc-test>
       <run class="Declaration2">
         <stdout>
           <line text="public java.lang.String Test.firstProperty has annotation:true"/>
-          <line text="public transient java.lang.String Test.ajc$interField$Declaration2$TestInterface$secondProperty has annotation:true"/>
+          <line text="public java.lang.String Test.ajc$interField$Declaration2$TestInterface$secondProperty has annotation:true"/>
         </stdout>
       </run>
     </ajc-test>
index adc134330743f621f85a9c7681799792a127c348..980b1e60117699d1dd9d38a4ac76a3548617331a 100644 (file)
@@ -21,6 +21,7 @@ import junit.framework.Test;
  */
 public class Ajc160Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
        
+  public void testIncorrectlyMarkingFieldTransient_pr168063() { runTest("incorrectly marking field transient");}
   public void testInheritedAnnotations_pr169706() { runTest("inherited annotations");}
   public void testGenericFieldNPE_pr165885() { runTest("generic field npe");}
   public void testIncorrectOptimizationOfIstore_pr166084() { runTest("incorrect optimization of istore"); }
index a8321545277b20e023303f9ef27b535c49212a8c..fcb85ea0ecd57c0e32b068acca8d8140e85b57ab 100644 (file)
          </compile>
     </ajc-test>
     
+    <ajc-test dir="bugs160/pr168063" title="incorrectly marking field transient">
+      <compile files="A.java"/>
+      <run class="A">
+        <stdout>
+          <line text="It worked, data preserved!"/>
+        </stdout>
+      </run>
+    </ajc-test>
+    
     <ajc-test dir="bugs160/pr166084" title="incorrect optimization of istore">
       <compile files="X.java" inpath="simple.jar"/>
          <run class="Simple"/>