diff options
author | aclement <aclement> | 2004-03-16 09:24:17 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-03-16 09:24:17 +0000 |
commit | cb2aaacf5c3fd4a745fd708c89feaab18435b0e0 (patch) | |
tree | 23597914033f16f59a3de81fec41d92f0318cd9d /tests | |
parent | e6894a62dae5857568da40762c4f6daa6111fdb3 (diff) | |
download | aspectj-cb2aaacf5c3fd4a745fd708c89feaab18435b0e0.tar.gz aspectj-cb2aaacf5c3fd4a745fd708c89feaab18435b0e0.zip |
Fix for Bugzilla Bug 41181
Support SerialVersionUID field if no new fields declared on class
(Regenerated with BcweaverJarMaker)
Diffstat (limited to 'tests')
25 files changed, 446 insertions, 4 deletions
diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index 06585a262..a3050d48b 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -5493,6 +5493,7 @@ <compile files="DeclareSoftCf.java" options="-Xlint:warning"> <message kind="warning" line="28"/> <message kind="error" line="29"/> + <message kind="warning"/> </compile> </ajc-test> @@ -7235,6 +7236,168 @@ </compile> </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Before execution advice" pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, BeforeExecutionAdvice.aj" options="-Xlint:warning"/> + <run class="Util"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Around execution advice" comment="OK because around_body private" pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, AroundExecutionAdvice.aj" options="-Xlint:warning"/> + <run class="Util"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Around closure execution advice (-Xlint:ignore)" comment="OK because ignoring warnings" + pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, AroundClosureExecutionAdvice.aj" options="-Xlint:ignore"/> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Around closure execution advice" comment="Warning because around_body non-private" + pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, AroundClosureExecutionAdvice.aj" + xlintfile="Xlint.properties"> + <message kind="warning" line="9"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: thisJoinPoint" comment="Warning because of introduced clinit" pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile + files="Test.java, Util.java, TJP.aj" options="-Xlint:warning"> + <message kind="warning" line="6"/> + <message kind="warning" line="13"/> + <message kind="warning" line="17"/> + <message kind="warning" line="24"/> + <message kind="warning" line="31"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: thisJoinPoint with clinit method" comment="OK if tjp private and existing clinit" + pr="41181"> + <compile files="ClinitTest.java, Util.java"/> + <run class="ClinitTest"/> + <compile files="ClinitTest.java, Util.java, TJP.aj" options="-Xlint:warning"/> + <run class="Util" options="-read"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: After returning staticinitialization advice" comment="Warning because of added clinit" + pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile + files="Test.java, Util.java, AfterReturningStaticinitializationAdvice.aj" options="-Xlint:warning"> + <message kind="warning" line="6"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: After returning staticinitialization advice with serialVersionUID field" + comment="OK because of serialVersionUID field" pr="41181"> + <compile files="SuidTest.java, Util.java" /> + <run class="SuidTest"/> + <compile files="SuidTest.java, Util.java, AfterReturningStaticinitializationAdvice.aj" options="-Xlint:warning"/> + <run class="Util"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: ITD field" comment="Error because added field may not be initialized" pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, ITDField.aj" options="-Xlint:error"> + <message kind="error" line="0"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: ITD method" comment="Warning because of added method" pr="41181"> + <compile files="Test.java, Util.java" /> + <run class="Test"/> + <compile files="Test.java, Util.java, ITDMethod.aj" options="-Xlint:warning"> + <message kind="warning" line="3"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Declare extends" comment="OK" pr="41181"> + <compile files="Test.java, Util.java" /> + <run class="Test"/> + <compile files="Test.java, Util.java, DeclareExtends.aj" options="-Xlint:warning"/> + <run class="Util"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Declare implements (compile)" comment="Warning because of added interface" pr="41181"> + <compile files="Test.java, Util.java" /> + <run class="Test"/> + <compile files="Test.java, Util.java, DeclareImplements.aj" options="-Xlint:warning"> + <message kind="warning"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Declare implements non-Serializable (compile)" comment="OK because not Serializable" + pr="41181"> + <compile files="NonSerializableTest.java, DeclareImplements.aj" options="-Xlint:warning"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Declare implements Serializable (compile)" comment="OK because adding Serializable" + pr="41181"> + <compile files="NonSerializableTest.java, DeclareImplementsSerializable.aj" options="-Xlint:warning"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Declare implements (weave)" comment="Warning because of added interface" pr="41181"> + <compile files="Test.java, Util.java" /> + <run class="Test"/> + <compile files="injar.jar, DeclareImplements.aj" options="-Xlint:warning"> + <message kind="warning" line="0"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" title="SUID: Priviliged aspect" pr="41181"> + <compile files="Test.java, Util.java"/> + <run class="Test"/> + <compile files="Test.java, Util.java, PrivilegedAspect.aj" options="-Xlint:warning"> + <message kind="warning" line="1"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> + + <ajc-test dir="bugs/serialVersionUID" + title="SUID: Perthis aspect" + comment="Warning because added of added interface MightHaveAspect. Added field is private transient" + pr="41181"> + <compile files="Test.java, Util.java" /> + <run class="Test"/> + <compile files="Test.java, Util.java, PerThisAspect.aj" options="-Xlint:warning"> + <message kind="warning" line="0"/> + </compile> + <run class="Util" options="-fail"/> + </ajc-test> <ajc-test dir="bugs/fieldsOnInterfaces" pr="52107" @@ -7267,8 +7430,8 @@ title="fail in compiling aspect with overriding method introduction with different throws clause "> <compile files="IntertypeDifferentThrows.java" /> </ajc-test> - - <ajc-test dir="new" + + <ajc-test dir="new" comment="in ajc 1.1.1, VerifyError Illegal use of nonvirtual function call" title="super call in anonymous class created in around advice"> <compile files="SuperClosure.java" /> @@ -7303,8 +7466,8 @@ <message kind="error" line="6"/> </compile> </ajc-test> - - <ajc-test dir="bugs" pr="51322" + + <ajc-test dir="bugs" pr="51322" title="Introduce Unknown Type to class causes Null pointer exception" > <compile files="Pr51322.java"> <message kind="error" line="5"/> diff --git a/tests/bugs/serialVersionUID/AfterReturningStaticinitializationAdvice.aj b/tests/bugs/serialVersionUID/AfterReturningStaticinitializationAdvice.aj new file mode 100644 index 000000000..0415a4b20 --- /dev/null +++ b/tests/bugs/serialVersionUID/AfterReturningStaticinitializationAdvice.aj @@ -0,0 +1,9 @@ +public aspect AfterReturningStaticinitializationAdvice {
+
+ pointcut staticInit () :
+ staticinitialization(*Test);
+
+ after () returning : staticInit() {
+ System.out.println("? AfterReturningStaticinitializationAdvice.staticInit()");
+ }
+}
diff --git a/tests/bugs/serialVersionUID/AroundClosureExecutionAdvice.aj b/tests/bugs/serialVersionUID/AroundClosureExecutionAdvice.aj new file mode 100644 index 000000000..43211d6ec --- /dev/null +++ b/tests/bugs/serialVersionUID/AroundClosureExecutionAdvice.aj @@ -0,0 +1,22 @@ +import java.io.InvalidClassException;
+import org.aspectj.testing.Tester;
+
+public aspect AroundClosureExecutionAdvice {
+
+ pointcut run () :
+ execution(public void run());
+
+ void around () : run () {
+ Runnable runnable = new Runnable() {
+ public void run () {
+ System.out.println("> AroundClosureExecutionAdvice.run()");
+
+ proceed();
+
+ System.out.println("< AroundClosureExecutionAdvice.run()");
+ }
+ };
+ runnable.run();
+ }
+
+}
diff --git a/tests/bugs/serialVersionUID/AroundExecutionAdvice.aj b/tests/bugs/serialVersionUID/AroundExecutionAdvice.aj new file mode 100644 index 000000000..6da62e42a --- /dev/null +++ b/tests/bugs/serialVersionUID/AroundExecutionAdvice.aj @@ -0,0 +1,14 @@ +public aspect AroundExecutionAdvice {
+
+ pointcut run () :
+ execution(public void run());
+
+ void around () : run () {
+ System.out.println("> AroundExecutionAdvice.run()");
+
+ proceed();
+
+ System.out.println("< AroundExecutionAdvice.run()");
+ }
+
+}
diff --git a/tests/bugs/serialVersionUID/BeforeExecutionAdvice.aj b/tests/bugs/serialVersionUID/BeforeExecutionAdvice.aj new file mode 100644 index 000000000..109cddc37 --- /dev/null +++ b/tests/bugs/serialVersionUID/BeforeExecutionAdvice.aj @@ -0,0 +1,9 @@ +public aspect BeforeExecutionAdvice {
+
+ pointcut run (Test test) :
+ execution(public void run()) && this(test);
+
+ before (Test test) : run (test) {
+ System.out.println("? BeforeExecutionAdvice.run() test=" + test);
+ }
+}
\ No newline at end of file diff --git a/tests/bugs/serialVersionUID/ClinitTest.java b/tests/bugs/serialVersionUID/ClinitTest.java new file mode 100644 index 000000000..367f35b51 --- /dev/null +++ b/tests/bugs/serialVersionUID/ClinitTest.java @@ -0,0 +1,16 @@ +import java.io.Serializable; + +public class ClinitTest implements Serializable { + + private int i; + private static boolean b = true; + + public void run () { + System.out.println("? Clinit.run()"); + } + + public static void main(String[] args) throws Exception { + ClinitTest test = new ClinitTest(); + Util.write(Util.DEFAULT_NAME,test); + } +}
\ No newline at end of file diff --git a/tests/bugs/serialVersionUID/DeclareExtends.aj b/tests/bugs/serialVersionUID/DeclareExtends.aj new file mode 100644 index 000000000..e2114ed1a --- /dev/null +++ b/tests/bugs/serialVersionUID/DeclareExtends.aj @@ -0,0 +1,5 @@ +public aspect DeclareExtends {
+
+ declare parents : Test extends Thread;
+
+}
diff --git a/tests/bugs/serialVersionUID/DeclareImplements.aj b/tests/bugs/serialVersionUID/DeclareImplements.aj new file mode 100644 index 000000000..9f311793f --- /dev/null +++ b/tests/bugs/serialVersionUID/DeclareImplements.aj @@ -0,0 +1,5 @@ +public aspect DeclareImplements {
+
+ declare parents : *Test implements Runnable;
+
+}
diff --git a/tests/bugs/serialVersionUID/DeclareImplementsSerializable.aj b/tests/bugs/serialVersionUID/DeclareImplementsSerializable.aj new file mode 100644 index 000000000..7c0daa130 --- /dev/null +++ b/tests/bugs/serialVersionUID/DeclareImplementsSerializable.aj @@ -0,0 +1,7 @@ +import java.io.Serializable;
+
+public aspect DeclareImplementsSerializable {
+
+ declare parents : NonSerializableTest implements Serializable;
+
+}
diff --git a/tests/bugs/serialVersionUID/ITDField.aj b/tests/bugs/serialVersionUID/ITDField.aj new file mode 100644 index 000000000..26d4e52a0 --- /dev/null +++ b/tests/bugs/serialVersionUID/ITDField.aj @@ -0,0 +1,5 @@ +public aspect ITDField {
+
+ private long Test.longField = 999999999L;
+
+}
diff --git a/tests/bugs/serialVersionUID/ITDField.class b/tests/bugs/serialVersionUID/ITDField.class Binary files differnew file mode 100644 index 000000000..9904cf76e --- /dev/null +++ b/tests/bugs/serialVersionUID/ITDField.class diff --git a/tests/bugs/serialVersionUID/ITDMethod.aj b/tests/bugs/serialVersionUID/ITDMethod.aj new file mode 100644 index 000000000..a7a635a1f --- /dev/null +++ b/tests/bugs/serialVersionUID/ITDMethod.aj @@ -0,0 +1,7 @@ +public aspect ITDMethod {
+
+ private void Test.voidMethod () {
+ System.out.println("? ITDMethod.voidMethod()");
+ }
+
+}
diff --git a/tests/bugs/serialVersionUID/NonSerializableTest.java b/tests/bugs/serialVersionUID/NonSerializableTest.java new file mode 100644 index 000000000..b321495f2 --- /dev/null +++ b/tests/bugs/serialVersionUID/NonSerializableTest.java @@ -0,0 +1,14 @@ +public class NonSerializableTest { + + private int i; + + public void run () { + System.out.println("NonSerializableTest.run()"); + i++; + } + + public static void main (String[] args) throws Exception { + NonSerializableTest test = new NonSerializableTest(); + test.run(); + } +}
\ No newline at end of file diff --git a/tests/bugs/serialVersionUID/PerThisAspect$ajcMightHaveAspect.class b/tests/bugs/serialVersionUID/PerThisAspect$ajcMightHaveAspect.class Binary files differnew file mode 100644 index 000000000..df5dc53f0 --- /dev/null +++ b/tests/bugs/serialVersionUID/PerThisAspect$ajcMightHaveAspect.class diff --git a/tests/bugs/serialVersionUID/PerThisAspect.aj b/tests/bugs/serialVersionUID/PerThisAspect.aj new file mode 100644 index 000000000..df31e0253 --- /dev/null +++ b/tests/bugs/serialVersionUID/PerThisAspect.aj @@ -0,0 +1,10 @@ +public aspect PerThisAspect perthis(this(Test)) {
+
+ pointcut run (Test test) :
+ execution(public void run()) && this(test);
+
+ before (Test test) : run (test) {
+ System.out.println("? PerThisAspect.run() test=" + test + " this=" + this);
+ }
+
+}
diff --git a/tests/bugs/serialVersionUID/PerThisAspect.class b/tests/bugs/serialVersionUID/PerThisAspect.class Binary files differnew file mode 100644 index 000000000..906edd329 --- /dev/null +++ b/tests/bugs/serialVersionUID/PerThisAspect.class diff --git a/tests/bugs/serialVersionUID/PrivilegedAspect.aj b/tests/bugs/serialVersionUID/PrivilegedAspect.aj new file mode 100644 index 000000000..0a959f7e6 --- /dev/null +++ b/tests/bugs/serialVersionUID/PrivilegedAspect.aj @@ -0,0 +1,13 @@ +import java.io.InvalidClassException;
+import org.aspectj.testing.Tester;
+
+public privileged aspect PrivilegedAspect {
+
+ pointcut run (Test test) :
+ execution(public void run()) && this(test);
+
+ before (Test test) : run (test) {
+ System.out.println("? PrivilegedAspect.run() i=" + test.i);
+ }
+
+}
diff --git a/tests/bugs/serialVersionUID/SuidTest.java b/tests/bugs/serialVersionUID/SuidTest.java new file mode 100644 index 000000000..9e93283ed --- /dev/null +++ b/tests/bugs/serialVersionUID/SuidTest.java @@ -0,0 +1,16 @@ +import java.io.Serializable; + +public class SuidTest implements Serializable { + + static final long serialVersionUID = 8904684881596717140L; + private int i; + + public void run () { + System.out.println("? SuidTest.run()"); + } + + public static void main(String[] args) throws Exception { + SuidTest test = new SuidTest(); + Util.write(Util.DEFAULT_NAME,test); + } +}
\ No newline at end of file diff --git a/tests/bugs/serialVersionUID/TJP.aj b/tests/bugs/serialVersionUID/TJP.aj new file mode 100644 index 000000000..585426042 --- /dev/null +++ b/tests/bugs/serialVersionUID/TJP.aj @@ -0,0 +1,34 @@ +public aspect TJP {
+
+ pointcut run () :
+ execution(public void *.run());
+
+ before () : run () {
+ System.out.println("? TJP.execRun() thisJoinPointStaticPart=" + thisJoinPointStaticPart);
+ }
+
+ pointcut write () :
+ call(public void *.run());
+
+ before () : write () {
+ System.out.println("? TJP.callRun() thisJoinPointStaticPart=" + thisJoinPointStaticPart);
+ }
+
+ before () : write () {
+ System.out.println("? TJP.callRun() thisEnclosingJoinPointStaticPart=" + thisEnclosingJoinPointStaticPart);
+ }
+
+ pointcut getI () :
+ get(int i);
+
+ before () : getI () {
+ System.out.println("? TJP.getI() thisJoinPoint=" + thisJoinPoint);
+ }
+
+ pointcut setI () :
+ set(int i);
+
+ before () : setI () {
+ System.out.println("? TJP.setI() thisJoinPoint=" + thisJoinPoint);
+ }
+}
\ No newline at end of file diff --git a/tests/bugs/serialVersionUID/Test.class b/tests/bugs/serialVersionUID/Test.class Binary files differnew file mode 100644 index 000000000..6b4e2fea1 --- /dev/null +++ b/tests/bugs/serialVersionUID/Test.class diff --git a/tests/bugs/serialVersionUID/Test.java b/tests/bugs/serialVersionUID/Test.java new file mode 100644 index 000000000..2e267b3b3 --- /dev/null +++ b/tests/bugs/serialVersionUID/Test.java @@ -0,0 +1,17 @@ +import java.io.Serializable; + +public class Test implements Serializable { + + private int i; + + public void run () { + System.out.println("Test.run()"); + i++; + } + + public static void main (String[] args) throws Exception { + Test test = new Test(); + test.run(); + Util.write(Util.DEFAULT_NAME,test); + } +} diff --git a/tests/bugs/serialVersionUID/Util.class b/tests/bugs/serialVersionUID/Util.class Binary files differnew file mode 100644 index 000000000..c9ff29160 --- /dev/null +++ b/tests/bugs/serialVersionUID/Util.class diff --git a/tests/bugs/serialVersionUID/Util.java b/tests/bugs/serialVersionUID/Util.java new file mode 100644 index 000000000..ec98bd149 --- /dev/null +++ b/tests/bugs/serialVersionUID/Util.java @@ -0,0 +1,74 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InvalidClassException; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamClass; +//import java.util.Arrays; +//import java.util.List; + +import org.aspectj.testing.Tester; + +public class Util { + + public final static String DEFAULT_COMMAND = "-read"; + public final static String DEFAULT_NAME = "test.ser"; + + public static void fail (String name) throws Exception { + try { + Object obj = read(name); + Tester.checkFailed("java.io.InvalidClassException"); + } + catch (InvalidClassException ex) { + System.out.println("? Util.fail() ex=" + ex); + } + } + + public static Object read (String name) throws Exception { + Object obj; + File file = new File(name); + file.deleteOnExit(); + ObjectInputStream in = null; + + try { + in = new ObjectInputStream(new FileInputStream(file)); + obj = in.readObject(); + System.out.println("? Util.read() obj=" + obj); + } + finally { + in.close(); + } + + return obj; + } + + public static void write (String name, Object obj) throws IOException { + + File file = new File(name); +// File file = File.createTempFile(name,null); + ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file)); + out.writeObject(obj); + out.close(); + + System.out.println("? Util.write() suid=" + ObjectStreamClass.lookup(obj.getClass())); + } + + public static void main (String[] args) throws Exception { + String command = (args.length > 0)? args[0] : DEFAULT_COMMAND; + String name = (args.length > 1)? args[1] : DEFAULT_NAME; + + if (command.equals("-read")) { + Object obj = read(name); + } + else if (command.equals("-fail")) { + fail(name); + } +// if (args.length > 0) { +// } +// else { +// System.out.println("Usage: Util -fail | -read [name]"); +// } + } +} diff --git a/tests/bugs/serialVersionUID/Xlint.properties b/tests/bugs/serialVersionUID/Xlint.properties new file mode 100644 index 000000000..79715ef12 --- /dev/null +++ b/tests/bugs/serialVersionUID/Xlint.properties @@ -0,0 +1,2 @@ +shadowNotInStructure = ignore +needsSerialVersionUIDField = warning diff --git a/tests/bugs/serialVersionUID/injar.jar b/tests/bugs/serialVersionUID/injar.jar Binary files differnew file mode 100644 index 000000000..7a8996bb2 --- /dev/null +++ b/tests/bugs/serialVersionUID/injar.jar |