Browse Source

Fix for Bugzilla Bug 67774

	  	Nullpointer-exception in pointcuts using withincode() clause
tags/for_ajdt1_1_12
aclement 20 years ago
parent
commit
7f19ab47a3

+ 8
- 0
tests/ajcTests.xml View File

@@ -7832,4 +7832,12 @@
</compile>
</ajc-test>
<ajc-test dir="bugs"
pr="67774" title="Nullpointer-Exception when defining a withincode() pointcut">
<compile files="WithincodeNPE01.java">
<!-- there are 3 join points that result in decw match, but 2 are on the same line! -->
<message kind="warning" line="2" text="In String ctor"/>
<message kind="warning" line="11" text="In String ctor"/>
</compile>
</ajc-test>
</suite>

+ 13
- 0
tests/bugs/WithincodeNPE01.java View File

@@ -0,0 +1,13 @@
aspect B {
public A.new(String s) { }
public void A.foo() { int i = 1; }
declare warning: withincode(void main(..)): "X"; // Would NPE without the fix for PR67774
declare warning: withincode(A.new(String)): "In String ctor";
}

class A {
private final static String name = A.class.getName();
}

+ 4
- 0
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java View File

@@ -1015,6 +1015,10 @@ public class BcelShadow extends Shadow {
public Member getEnclosingCodeSignature() {
if (getKind().isEnclosingKind()) {
return getSignature();
} else if (getKind() == Shadow.PreInitialization) {
// PreInit doesn't enclose code but its signature
// is correctly the signature of the ctor.
return getSignature();
} else if (enclosingShadow == null) {
return getEnclosingMethod().getMemberView();
} else {

Loading…
Cancel
Save