From cb2aaacf5c3fd4a745fd708c89feaab18435b0e0 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 16 Mar 2004 09:24:17 +0000 Subject: Fix for Bugzilla Bug 41181 Support SerialVersionUID field if no new fields declared on class (Regenerated with BcweaverJarMaker) --- tests/ajcTests.xml | 171 ++++++++++++++++++++- .../AfterReturningStaticinitializationAdvice.aj | 9 ++ .../AroundClosureExecutionAdvice.aj | 22 +++ .../bugs/serialVersionUID/AroundExecutionAdvice.aj | 14 ++ .../bugs/serialVersionUID/BeforeExecutionAdvice.aj | 9 ++ tests/bugs/serialVersionUID/ClinitTest.java | 16 ++ tests/bugs/serialVersionUID/DeclareExtends.aj | 5 + tests/bugs/serialVersionUID/DeclareImplements.aj | 5 + .../DeclareImplementsSerializable.aj | 7 + tests/bugs/serialVersionUID/ITDField.aj | 5 + tests/bugs/serialVersionUID/ITDField.class | Bin 0 -> 1705 bytes tests/bugs/serialVersionUID/ITDMethod.aj | 7 + .../bugs/serialVersionUID/NonSerializableTest.java | 14 ++ .../PerThisAspect$ajcMightHaveAspect.class | Bin 0 -> 247 bytes tests/bugs/serialVersionUID/PerThisAspect.aj | 10 ++ tests/bugs/serialVersionUID/PerThisAspect.class | Bin 0 -> 2181 bytes tests/bugs/serialVersionUID/PrivilegedAspect.aj | 13 ++ tests/bugs/serialVersionUID/SuidTest.java | 16 ++ tests/bugs/serialVersionUID/TJP.aj | 34 ++++ tests/bugs/serialVersionUID/Test.class | Bin 0 -> 1068 bytes tests/bugs/serialVersionUID/Test.java | 17 ++ tests/bugs/serialVersionUID/Util.class | Bin 0 -> 2609 bytes tests/bugs/serialVersionUID/Util.java | 74 +++++++++ tests/bugs/serialVersionUID/Xlint.properties | 2 + tests/bugs/serialVersionUID/injar.jar | Bin 0 -> 2099 bytes 25 files changed, 446 insertions(+), 4 deletions(-) create mode 100644 tests/bugs/serialVersionUID/AfterReturningStaticinitializationAdvice.aj create mode 100644 tests/bugs/serialVersionUID/AroundClosureExecutionAdvice.aj create mode 100644 tests/bugs/serialVersionUID/AroundExecutionAdvice.aj create mode 100644 tests/bugs/serialVersionUID/BeforeExecutionAdvice.aj create mode 100644 tests/bugs/serialVersionUID/ClinitTest.java create mode 100644 tests/bugs/serialVersionUID/DeclareExtends.aj create mode 100644 tests/bugs/serialVersionUID/DeclareImplements.aj create mode 100644 tests/bugs/serialVersionUID/DeclareImplementsSerializable.aj create mode 100644 tests/bugs/serialVersionUID/ITDField.aj create mode 100644 tests/bugs/serialVersionUID/ITDField.class create mode 100644 tests/bugs/serialVersionUID/ITDMethod.aj create mode 100644 tests/bugs/serialVersionUID/NonSerializableTest.java create mode 100644 tests/bugs/serialVersionUID/PerThisAspect$ajcMightHaveAspect.class create mode 100644 tests/bugs/serialVersionUID/PerThisAspect.aj create mode 100644 tests/bugs/serialVersionUID/PerThisAspect.class create mode 100644 tests/bugs/serialVersionUID/PrivilegedAspect.aj create mode 100644 tests/bugs/serialVersionUID/SuidTest.java create mode 100644 tests/bugs/serialVersionUID/TJP.aj create mode 100644 tests/bugs/serialVersionUID/Test.class create mode 100644 tests/bugs/serialVersionUID/Test.java create mode 100644 tests/bugs/serialVersionUID/Util.class create mode 100644 tests/bugs/serialVersionUID/Util.java create mode 100644 tests/bugs/serialVersionUID/Xlint.properties create mode 100644 tests/bugs/serialVersionUID/injar.jar (limited to 'tests') 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 @@ + @@ -7235,6 +7236,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - @@ -7303,8 +7466,8 @@ - - 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 new file mode 100644 index 000000000..9904cf76e Binary files /dev/null and b/tests/bugs/serialVersionUID/ITDField.class differ 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 new file mode 100644 index 000000000..df5dc53f0 Binary files /dev/null and b/tests/bugs/serialVersionUID/PerThisAspect$ajcMightHaveAspect.class differ 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 new file mode 100644 index 000000000..906edd329 Binary files /dev/null and b/tests/bugs/serialVersionUID/PerThisAspect.class differ 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 new file mode 100644 index 000000000..6b4e2fea1 Binary files /dev/null and b/tests/bugs/serialVersionUID/Test.class differ 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 new file mode 100644 index 000000000..c9ff29160 Binary files /dev/null and b/tests/bugs/serialVersionUID/Util.class differ 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 new file mode 100644 index 000000000..7a8996bb2 Binary files /dev/null and b/tests/bugs/serialVersionUID/injar.jar differ -- cgit v1.2.3