aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs152/pr148007/purejava
diff options
context:
space:
mode:
authoracolyer <acolyer>2006-06-22 04:49:26 +0000
committeracolyer <acolyer>2006-06-22 04:49:26 +0000
commit426cbdccfdf8fcfcda07b86d8e524d1034b2d0b7 (patch)
tree86e17625eadc66a8d7c6d908d5db6c7c746c7eec /tests/bugs152/pr148007/purejava
parent497dcf1140b7ec4eab3aab80fa5a22c8259bae48 (diff)
downloadaspectj-426cbdccfdf8fcfcda07b86d8e524d1034b2d0b7.tar.gz
aspectj-426cbdccfdf8fcfcda07b86d8e524d1034b2d0b7.zip
tests and "fix" for pr148007 - workaround JRockit "goto" bug by generating code closer to that produced by javac when weaving after and after returning. In particular: avoid adding a goto that branches to the next instruction (now replaces that return opcode with a nop instead), and store the return value on the top of the stack in a temp before branching to the after advice dispatch and restore it afterwards.
Diffstat (limited to 'tests/bugs152/pr148007/purejava')
-rw-r--r--tests/bugs152/pr148007/purejava/test/BooleanUnitTest.java71
-rw-r--r--tests/bugs152/pr148007/purejava/test/LoggingAspect.java32
2 files changed, 103 insertions, 0 deletions
diff --git a/tests/bugs152/pr148007/purejava/test/BooleanUnitTest.java b/tests/bugs152/pr148007/purejava/test/BooleanUnitTest.java
new file mode 100644
index 000000000..0d4ee3e45
--- /dev/null
+++ b/tests/bugs152/pr148007/purejava/test/BooleanUnitTest.java
@@ -0,0 +1,71 @@
+package test;
+
+/**
+ * Understands . . .
+ *
+ * @author Randy Stearns
+ */
+public class BooleanUnitTest {
+
+ public static void main(String[] args) {
+ new BooleanUnitTest().test1();
+ }
+
+ public void test1() {
+ assertEquals("1a WRONG!", false, invert1a());
+ assertEquals("1b WRONG!", true, invert1b());
+ assertEquals("2 WRONG!", false, invert2());
+ assertEquals("3 WRONG!", true, invert3());
+ assertEquals("4 WRONG!", true, invert4());
+ assertEquals("5 WRONG!", false, invert5());
+ }
+
+ private void assertEquals(String msg, boolean a, boolean b) {
+ if (a != b) {
+ throw new RuntimeException(msg);
+ }
+ }
+
+ private boolean invert1a() {
+ return ! true;
+ }
+
+ private boolean invert1b() {
+ return ! false;
+ }
+
+ private boolean invert2() {
+ boolean ret = false;
+ try {
+ ret = ! isTrue();
+ }
+ catch (RuntimeException t) {
+ LoggingAspect.aspectOf().ajc$afterReturning$test_LoggingAspect$1$188fbb36();
+ throw t;
+ }
+ LoggingAspect.aspectOf().ajc$afterReturning$test_LoggingAspect$1$188fbb36();
+ return ret;
+ }
+
+ private boolean invert3() {
+ return ! isFalse();
+ }
+
+ private boolean invert4() {
+ boolean temp = isFalse();
+ return ! temp;
+ }
+
+ private boolean invert5() {
+ boolean temp = isTrue();
+ return ! temp;
+ }
+
+ private boolean isTrue() {
+ return true;
+ }
+
+ private boolean isFalse() {
+ return false;
+ }
+}
diff --git a/tests/bugs152/pr148007/purejava/test/LoggingAspect.java b/tests/bugs152/pr148007/purejava/test/LoggingAspect.java
new file mode 100644
index 000000000..4b265eb6d
--- /dev/null
+++ b/tests/bugs152/pr148007/purejava/test/LoggingAspect.java
@@ -0,0 +1,32 @@
+package test;
+
+import org.aspectj.lang.NoAspectBoundException;
+
+public class LoggingAspect {
+
+ private static LoggingAspect ajc$perSingletonInstance;
+ private static Throwable ajc$initFailureCause;
+
+ static {
+ try {
+ ajc$postClinit();
+ }
+ catch (Throwable t) {
+ ajc$initFailureCause = t;
+ }
+ }
+
+ public static LoggingAspect aspectOf() {
+ if (ajc$perSingletonInstance == null) {
+ throw new NoAspectBoundException("test_LoggingAspect",ajc$initFailureCause);
+ }
+ return ajc$perSingletonInstance;
+ }
+
+ public void ajc$afterReturning$test_LoggingAspect$1$188fbb36() {
+ }
+
+ private static void ajc$postClinit() {
+ ajc$perSingletonInstance = new LoggingAspect();
+ }
+}