--- /dev/null
+package test;
+
+import test.Test;
+
+public privileged aspect ITDAspect {
+ public void Test.itdFunction() {
+ System.out.println("ITD function");
+ privateMethod();
+ publicMethod();
+ }
+}
--- /dev/null
+package test;
+
+public class Test {
+
+ public Test() {
+ }
+
+ public static void main(String[] args) {
+ Test t = new Test();
+ t.function();
+ t.itdFunction();
+ }
+
+ public void function() {
+ System.out.println("Normal function");
+ privateMethod();
+ publicMethod();
+ }
+
+ private void privateMethod() {
+ System.out.println("private method");
+ }
+
+ public void publicMethod() {
+ System.out.println("public method");
+ }
+
+}
--- /dev/null
+package test;
+
+public aspect TestAspect {
+ Object around(): call(* Test.*(..)) {
+ System.out.println("Around " + thisJoinPoint.toString());
+ return proceed();
+ }
+}
--- /dev/null
+package test;
+
+import test.Test;
+
+public privileged aspect ITDAspect {
+ public void Test.itdFunction() {
+ System.out.println("ITD function");
+ privateMethod("Foo");
+ }
+}
--- /dev/null
+package test;
+
+public class Test {
+
+ public Test() {
+ }
+
+ public static void main(String[] args) {
+ Test t = new Test();
+ t.itdFunction();
+ }
+
+ private void privateMethod(String xxx) {
+ System.out.println("hello "+xxx);
+ }
+}
--- /dev/null
+package test;
+
+public aspect TestAspect {
+ Object around(String s): call(* Test.*(..)) && args(s) {
+ System.out.println("Around " + thisJoinPoint.toString());
+ System.out.println("Captured "+s);
+ return proceed(s.toUpperCase());
+ }
+}
*/
public class Ajc187Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+ public void testMissingJoinpoint_307147() throws Exception {
+ runTest("missing joinpoint");
+ }
+
+ public void testMissingJoinpoint_307147_2() throws Exception {
+ runTest("missing joinpoint 2");
+ }
+
public void testInfiniteLoop_475152() throws Exception {
runTest("infinite loop");
}
<suite>
+<ajc-test dir="bugs187/307147" title="missing joinpoint">
+<compile files="Test.java TestAspect.aj ITDAspect.aj" options="-1.8"/>
+<run class="test.Test">
+<stdout>
+<line text="Around call(void test.Test.function())"/>
+<line text="Normal function"/>
+<line text="Around call(void test.Test.privateMethod())"/>
+<line text="private method"/>
+<line text="Around call(void test.Test.publicMethod())"/>
+<line text="public method"/>
+<line text="Around call(void test.Test.itdFunction())"/>
+<line text="ITD function"/>
+<line text="Around call(void test.Test.privateMethod())"/>
+<line text="private method"/>
+<line text="Around call(void test.Test.publicMethod())"/>
+<line text="public method"/>
+</stdout></run>
+</ajc-test>
+
+<ajc-test dir="bugs187/307147_2" title="missing joinpoint 2">
+<compile files="Test.java TestAspect.aj ITDAspect.aj" options="-1.8"/>
+<run class="test.Test">
+<stdout>
+<line text="ITD function"/>
+<line text="Around call(void test.Test.privateMethod(String))"/>
+<line text="Captured Foo"/>
+<line text="hello FOO"/>
+</stdout></run>
+</ajc-test>
+
<ajc-test dir="bugs187/475152" title="infinite loop">
<compile files="AbstractAspect.aj, BaseAspect.aj, TestClass.java, AjTarget.java, TestAspect.aj" options="-1.8"/>
</ajc-test>
if (canMatch(Shadow.FieldGet) || canMatch(Shadow.FieldSet)) {
match(BcelShadow.makeShadowForMethodCall(world, mg, ih, enclosingShadow, kind, declaredSig), shadowAccumulator);
}
+ } else if (!declaredSig.getName().startsWith(NameMangler.PREFIX)) {
+ // 307147 - resolution above may have found the real method directly rather
+ // than needing to go through the effective signature attribute
+ if (canMatch(Shadow.MethodCall)) {
+ match(BcelShadow.makeShadowForMethodCall(world, mg, ih, enclosingShadow, Shadow.MethodCall, declaredSig),
+ shadowAccumulator);
+ }
} else {
AjAttribute.EffectiveSignatureAttribute effectiveSig = declaredSig.getEffectiveSignature();
if (effectiveSig == null) {
import org.aspectj.bridge.WeaveMessage;
import org.aspectj.bridge.context.CompilationAndWeavingContext;
import org.aspectj.bridge.context.ContextToken;
+import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.AnnotationAJ;
import org.aspectj.weaver.AnnotationOnTypeMunger;
UnresolvedType declaringType = null;
String signature = ii.getSignature(cpg);
+
+ // 307147
+ if (name.startsWith("ajc$privMethod$")) {
+ // The invoke is on a privileged accessor. These may be created for different
+ // kinds of target, not necessarily just private methods. In bug 307147 it is
+ // for a private method. This code is identifying the particular case in 307147
+ try {
+ declaringType = UnresolvedType.forName(declaring);
+ String typeNameAsFoundInAccessorName = declaringType.getName().replace('.', '_');
+ int indexInAccessorName = name.lastIndexOf(typeNameAsFoundInAccessorName);
+ if (indexInAccessorName != -1) {
+ String methodName = name.substring(indexInAccessorName+typeNameAsFoundInAccessorName.length()+1);
+ ResolvedType resolvedDeclaringType = declaringType.resolve(this);
+ ResolvedMember[] methods = resolvedDeclaringType.getDeclaredMethods();
+ for (ResolvedMember method: methods) {
+ if (method.getName().equals(methodName) && method.getSignature().equals(signature) && Modifier.isPrivate(method.getModifiers())) {
+ return method;
+ }
+ }
+ }
+ } catch (Exception e) {
+ // Remove this once confident above code isn't having unexpected side effects
+ // Added 1.8.7
+ e.printStackTrace();
+ }
+ }
int modifier = (ii instanceof INVOKEINTERFACE) ? Modifier.INTERFACE
: (ii.opcode == Constants.INVOKESTATIC) ? Modifier.STATIC : (ii.opcode == Constants.INVOKESPECIAL && !name