aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2006-08-22 07:34:46 +0000
committeraclement <aclement>2006-08-22 07:34:46 +0000
commit8b393cc90d5d63171154713e5a73044a1a2fddaf (patch)
treeaaabfb93b35ba91a8343191af1574c020c36cda8
parent0185a0214f790c6611b48b986e01ef97a399b6ae (diff)
downloadaspectj-8b393cc90d5d63171154713e5a73044a1a2fddaf.tar.gz
aspectj-8b393cc90d5d63171154713e5a73044a1a2fddaf.zip
oops! fix for serial version uid calculation (abstract class problem)
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java13
-rw-r--r--lib/bcel/bcel-src.zipbin879912 -> 879933 bytes
-rw-r--r--lib/bcel/bcel.jarbin610327 -> 610339 bytes
-rw-r--r--tests/features151/serialveruid/ATest.java7
-rw-r--r--tests/features151/serialveruid/Test.java7
-rw-r--r--tests/features151/serialveruid/TwoTypes.java57
-rw-r--r--tests/src/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc151/serialversionuid.xml14
8 files changed, 97 insertions, 3 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java
index cbac21479..ee0c7d1bc 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java
@@ -84,7 +84,7 @@ import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
* existing java class (file).
*
* @see JavaClass
- * @version $Id: ClassGen.java,v 1.7 2006/03/16 11:01:53 aclement Exp $
+ * @version $Id: ClassGen.java,v 1.8 2006/08/22 07:34:50 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*
* Upgraded, Andy Clement 9th Mar 06 - calculates SUID
@@ -567,9 +567,16 @@ public class ClassGen extends AccessFlags implements Cloneable {
classmods|=(isPublic()?Constants.ACC_PUBLIC:0);
classmods|=(isFinal()?Constants.ACC_FINAL:0);
classmods|=(isInterface()?Constants.ACC_INTERFACE:0);
- if (isInterface() && isAbstract()) { // remove abstract if we have it but have no methods
- if (methods.length>0) classmods|=Constants.ACC_ABSTRACT;
+
+ if (isAbstract()) {
+ // if an interface then abstract is only set if it has methods
+ if (isInterface()) {
+ if (methods.length>0) classmods|=Constants.ACC_ABSTRACT;
+ } else {
+ classmods|=Constants.ACC_ABSTRACT;
+ }
}
+
dos.writeInt(classmods);
// 3. ordered list of interfaces
diff --git a/lib/bcel/bcel-src.zip b/lib/bcel/bcel-src.zip
index c1115a886..de585c8e5 100644
--- a/lib/bcel/bcel-src.zip
+++ b/lib/bcel/bcel-src.zip
Binary files differ
diff --git a/lib/bcel/bcel.jar b/lib/bcel/bcel.jar
index 7df53e540..6841232ce 100644
--- a/lib/bcel/bcel.jar
+++ b/lib/bcel/bcel.jar
Binary files differ
diff --git a/tests/features151/serialveruid/ATest.java b/tests/features151/serialveruid/ATest.java
new file mode 100644
index 000000000..70dee2a38
--- /dev/null
+++ b/tests/features151/serialveruid/ATest.java
@@ -0,0 +1,7 @@
+package com.testware.ejb.common;
+import java.io.Serializable;
+
+// ATest: static final long serialVersionUID = -7843094187906014027L;
+public abstract class ATest implements Serializable{
+ abstract void getid();
+} \ No newline at end of file
diff --git a/tests/features151/serialveruid/Test.java b/tests/features151/serialveruid/Test.java
new file mode 100644
index 000000000..767715369
--- /dev/null
+++ b/tests/features151/serialveruid/Test.java
@@ -0,0 +1,7 @@
+package com.testware.ejb.common;
+
+// Test: static final long serialVersionUID = 2486685186022095906L;
+public class Test extends ATest {
+ void getid() {
+ }
+} \ No newline at end of file
diff --git a/tests/features151/serialveruid/TwoTypes.java b/tests/features151/serialveruid/TwoTypes.java
new file mode 100644
index 000000000..c61ffac27
--- /dev/null
+++ b/tests/features151/serialveruid/TwoTypes.java
@@ -0,0 +1,57 @@
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import com.testware.ejb.common.*;
+
+// when in a package, AJ worked out:
+//Test SerialVersionUID is 8593816477552447372
+//ATest SerialVersionUID is -5439116922937363745
+// atest serialveruid: -5439116922937363745L
+// test serialveruid: 8593816477552447372L
+
+
+//ATest: static final long serialVersionUID = 9091955077097551023L;
+//Test: static final long serialVersionUID = 1583992244946994789L;
+
+//ATest SerialVersionUID is 9091955077097551023
+//Test SerialVersionUID is 1583992244946994789
+//
+aspect X {
+ before(): staticinitialization(*Test) {}
+}
+
+public class TwoTypes implements Serializable {
+ public static void main(String[] args) {
+ try {
+ Test c = (Test)Test.class.newInstance();
+ Field f = Test.class.getDeclaredField("serialVersionUID");
+ f.setAccessible(true);
+ long l = f.getLong(c);
+ System.err.println("Test SerialVersionUID is "+l);
+
+
+ // ATest b = (ATest)ATest.class.newInstance();
+ f = ATest.class.getDeclaredField("serialVersionUID");
+ f.setAccessible(true);
+ l = f.getLong(Test.class.getSuperclass());
+ System.err.println("ATest SerialVersionUID is "+l);
+
+
+ } catch (Exception e) {
+ System.err.println("Problem: "+e.toString());
+ e.printStackTrace();
+ }
+ }
+//
+// public int anInt;
+//
+// public static boolean aBoolean = false;
+//
+// public long foo = 376;
+//
+// public void m() {}
+// public int compareTo(Object o) { return 0;}
+// public String m2(boolean b,long l, String s) { return "";}
+//
+// public static transient short fo2 = 3;
+
+} \ No newline at end of file
diff --git a/tests/src/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java b/tests/src/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java
index 1df5bd4f8..876792242 100644
--- a/tests/src/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc151/SerialVersionUIDTests.java
@@ -23,6 +23,8 @@ public class SerialVersionUIDTests extends XMLBasedAjcTestCase {
public void testTheBasicsWithLint() { runTest("basic - lint"); }
public void testHorrible() { runTest("horrible"); }
+ public void testAbstractClass() { runTest("abstract class");}
+
//
public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(SerialVersionUIDTests.class);
diff --git a/tests/src/org/aspectj/systemtest/ajc151/serialversionuid.xml b/tests/src/org/aspectj/systemtest/ajc151/serialversionuid.xml
index c18adaed7..544b976a8 100644
--- a/tests/src/org/aspectj/systemtest/ajc151/serialversionuid.xml
+++ b/tests/src/org/aspectj/systemtest/ajc151/serialversionuid.xml
@@ -34,4 +34,18 @@
</run>
</ajc-test>
+ <ajc-test dir="features151/serialveruid" title="abstract class">
+ <compile files="TwoTypes.java,Test.java,ATest.java" options="-1.5 -XaddSerialVersionUID -Xlint:warning">
+ <message kind="warning" text="calculated SerialVersionUID for type TwoTypes"/>
+ <message kind="warning" text="calculated SerialVersionUID for type com.testware.ejb.common.Test to be -1674849842374764518L"/>
+ <message kind="warning" text="calculated SerialVersionUID for type com.testware.ejb.common.ATest to be -7300724421810308152L"/>
+ </compile>
+ <run class="TwoTypes">
+ <stderr>
+ <line text="Test SerialVersionUID is -1674849842374764518"/>
+ <line text="ATest SerialVersionUID is -7300724421810308152"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
</suite> \ No newline at end of file