aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Clement <aclement@gopivotal.com>2015-03-23 12:54:54 -0700
committerAndy Clement <aclement@gopivotal.com>2015-03-23 12:54:54 -0700
commita1cfe944a602101d144c8efd7df217ab20e4b9ee (patch)
treeddb06c095990717713c90a2efb7cf0c0ab49f194
parent3869f363bc6e473f4063faf2c296825283a21f1a (diff)
downloadaspectj-a1cfe944a602101d144c8efd7df217ab20e4b9ee.tar.gz
aspectj-a1cfe944a602101d144c8efd7df217ab20e4b9ee.zip
462821: invokedynamic detection in hierarchy of aspects
-rw-r--r--tests/bugs186/462821/AbstractLoggerAspect.java59
-rw-r--r--tests/bugs186/462821/FooService.java10
-rw-r--r--tests/bugs186/462821/FooServiceLoggerAspect.java23
-rw-r--r--tests/bugs186/462821/java1
-rw-r--r--tests/src/org/aspectj/systemtest/AllTests18.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java39
-rw-r--r--tests/src/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java27
-rw-r--r--tests/src/org/aspectj/systemtest/ajc186/ajc186.xml10
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java27
9 files changed, 192 insertions, 6 deletions
diff --git a/tests/bugs186/462821/AbstractLoggerAspect.java b/tests/bugs186/462821/AbstractLoggerAspect.java
new file mode 100644
index 000000000..5b9e3c14b
--- /dev/null
+++ b/tests/bugs186/462821/AbstractLoggerAspect.java
@@ -0,0 +1,59 @@
+//package no.kantega;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+@Aspect
+public abstract class AbstractLoggerAspect {
+
+ @Pointcut
+ public abstract void debugJoinPoints();
+
+ @Pointcut
+ public abstract void infoJoinPoints();
+
+ @Pointcut
+ public abstract void excludedJoinPoints();
+
+
+ @Pointcut("execution(public String Object+.toString()) || call(public String Object.toString())"
+ + "|| call(public int Object.hashCode()) || call(public boolean Object.equals())"
+ + "|| execution(public static void Object+.main(String[])) ")
+ public void defaultExcludedJoinPoints() {}
+
+ @Pointcut("(infoJoinPoints() && !defaultExcludedJoinPoints() && !excludedJoinPoints())")
+ public void infoJoinPointsToLog() {}
+
+/*
+ @Pointcut("(debugJoinPoints() && !defaultExcludedJoinPoints() && !infoJoinPointsToLog() && !excludedJoinPoints())")
+ public void debugJoinPointsToLog() {}
+
+
+ @Around("debugJoinPointsToLog()")
+ public Object handleDebugJoinPointsToLog(ProceedingJoinPoint thisJoinPoint)
+ {
+ // do stuff
+ try {
+ return thisJoinPoint.proceed();
+ } catch (Throwable throwable) {
+ throw new RuntimeException("foo");
+ }
+ // then do other stuff
+ }
+*/
+
+ @Around("infoJoinPoints()")
+ public Object handleInfoJoinPointsToLog(ProceedingJoinPoint thisJoinPoint)
+ {
+ // first do stuff
+ try {
+ return thisJoinPoint.proceed();
+ } catch (Throwable throwable) {
+ throw new RuntimeException("foo");
+ }
+ // then do other stuff
+ }
+}
+
diff --git a/tests/bugs186/462821/FooService.java b/tests/bugs186/462821/FooService.java
new file mode 100644
index 000000000..5d9ab18bf
--- /dev/null
+++ b/tests/bugs186/462821/FooService.java
@@ -0,0 +1,10 @@
+//package no.kantega;
+
+public class FooService {
+
+ /** Adviced method */
+ public String doSomething() {
+ return "foo";
+ }
+
+}
diff --git a/tests/bugs186/462821/FooServiceLoggerAspect.java b/tests/bugs186/462821/FooServiceLoggerAspect.java
new file mode 100644
index 000000000..f471694e1
--- /dev/null
+++ b/tests/bugs186/462821/FooServiceLoggerAspect.java
@@ -0,0 +1,23 @@
+//package no.kantega;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+@Aspect
+public class FooServiceLoggerAspect extends AbstractLoggerAspect {
+
+ @Pointcut
+ @Override
+ public void debugJoinPoints() {
+ }
+
+ @Pointcut("execution(public * FooService.*(..)) && !debugJoinPoints()")
+ @Override
+ public void infoJoinPoints() {
+ }
+
+ @Pointcut
+ @Override
+ public void excludedJoinPoints() {
+ }
+}
diff --git a/tests/bugs186/462821/java b/tests/bugs186/462821/java
new file mode 100644
index 000000000..f1d45a49f
--- /dev/null
+++ b/tests/bugs186/462821/java
@@ -0,0 +1 @@
+[?25l[?12l[?25h[?1049h[?1h=[?12;25h[?12l[?25h[?25l~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ VIM - Vi IMprovedversion 7.3by Bram Moolenaar et al.Vim is open source and freely distributableBecome a registered Vim user!type :help register<Enter> for information type :q<Enter> to exit type :help<Enter> or <F1> for on-line helptype :help version7<Enter> for version infoRunning in Vi compatible modetype :set nocp<Enter> for Vim defaultstype :help cp-default<Enter> for info on this[?12l[?25h[?25lType :quit<Enter> to exit Vim[?12l[?25h[?25l[?12l[?25h \ No newline at end of file
diff --git a/tests/src/org/aspectj/systemtest/AllTests18.java b/tests/src/org/aspectj/systemtest/AllTests18.java
index 80e113ce2..ae57ece04 100644
--- a/tests/src/org/aspectj/systemtest/AllTests18.java
+++ b/tests/src/org/aspectj/systemtest/AllTests18.java
@@ -19,12 +19,14 @@ import org.aspectj.systemtest.ajc182.AllTestsAspectJ182;
import org.aspectj.systemtest.ajc183.AllTestsAspectJ183;
import org.aspectj.systemtest.ajc184.AllTestsAspectJ184;
import org.aspectj.systemtest.ajc185.AllTestsAspectJ185;
+import org.aspectj.systemtest.ajc186.AllTestsAspectJ186;
public class AllTests18 {
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8");
// $JUnit-BEGIN$
+ suite.addTest(AllTestsAspectJ186.suite());
suite.addTest(AllTestsAspectJ185.suite());
suite.addTest(AllTestsAspectJ184.suite());
suite.addTest(AllTestsAspectJ183.suite());
diff --git a/tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java b/tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java
new file mode 100644
index 000000000..dc12ab3e4
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc186;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Andy Clement
+ */
+public class Ajc186Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+ public void testMissingMethod_462821() throws Exception {
+ runTest("missing method");
+ }
+
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Ajc186Tests.class);
+ }
+
+ @Override
+ protected File getSpecFile() {
+ return getClassResource("ajc186.xml");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java b/tests/src/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java
new file mode 100644
index 000000000..4e533d0d5
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc186/AllTestsAspectJ186.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc186;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.aspectj.systemtest.apt.AptTests;
+
+public class AllTestsAspectJ186 {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("AspectJ 1.8.6 tests");
+ // $JUnit-BEGIN$
+ suite.addTest(Ajc186Tests.suite());
+ suite.addTest(AptTests.suite());
+ // $JUnit-END$
+ return suite;
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc186/ajc186.xml b/tests/src/org/aspectj/systemtest/ajc186/ajc186.xml
new file mode 100644
index 000000000..ff2e1511b
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc186/ajc186.xml
@@ -0,0 +1,10 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+<ajc-test dir="bugs186/462821" title="missing method">
+<compile files="FooService.java AbstractLoggerAspect.java FooServiceLoggerAspect.java" options="-1.8">
+</compile>
+</ajc-test>
+
+</suite>
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
index 668a0b2dc..64d6a1054 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
@@ -241,12 +241,27 @@ class BcelAdvice extends Advice {
if (boType.javaClass.getMajor() == Constants.MAJOR_1_8) {
if (containsInvokedynamic == 0) {
containsInvokedynamic = 1;
- LazyMethodGen lmg = boType.getLazyClassGen().getLazyMethodGen(this.signature);
- InstructionList ilist = lmg.getBody();
- for (InstructionHandle src = ilist.getStart(); src != null; src = src.getNext()) {
- if (src.getInstruction().opcode == Constants.INVOKEDYNAMIC) {
- containsInvokedynamic = 2;
- break;
+ LazyMethodGen lmg = boType.getLazyClassGen().getLazyMethodGen(this.signature.getName(), this.signature.getSignature(), true);
+ // Check Java8 supertypes
+ while (lmg == null) {
+ ResolvedType superType = boType.getSuperclass();
+ if (superType == null) break;
+ ReferenceTypeDelegate rtd = ((ReferenceType)superType).getDelegate();
+ if (rtd instanceof BcelObjectType) {
+ BcelObjectType bot = (BcelObjectType)rtd;
+ if (bot.javaClass.getMajor() < Constants.MAJOR_1_8) {
+ break;
+ }
+ lmg = bot.getLazyClassGen().getLazyMethodGen(this.signature.getName(), this.signature.getSignature(), true);
+ }
+ }
+ if (lmg != null) {
+ InstructionList ilist = lmg.getBody();
+ for (InstructionHandle src = ilist.getStart(); src != null; src = src.getNext()) {
+ if (src.getInstruction().opcode == Constants.INVOKEDYNAMIC) {
+ containsInvokedynamic = 2;
+ break;
+ }
}
}
}