Browse Source

fix for parser crash on erroneous perthis() - see pr115788

tags/V1_5_0RC1
aclement 18 years ago
parent
commit
563ab1bc76

+ 4
- 0
tests/bugs150/pr115788/AAA.java View File

@@ -0,0 +1,4 @@
package a;

public aspect AAA perthis(this(Screen)) { }


+ 1
- 0
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java View File

@@ -49,6 +49,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void testGenericITDsAndAbstractMethodError_pr102357() { runTest("generic itds and abstract method error");}
*/
public void testParserException_pr115788() { runTest("parser exception");}
public void testPossibleStaticImports_pr113066_1() { runTest("possible static imports bug - 1");}
public void testPossibleStaticImports_pr113066_2() { runTest("possible static imports bug - 2");}
public void testPossibleStaticImports_pr113066_3() { runTest("possible static imports bug - 3");}

+ 6
- 0
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml View File

@@ -57,6 +57,12 @@
<compile files="Consts.java,TestNPE.java" options="-1.5"/>
</ajc-test>
<ajc-test dir="bugs150/pr115788" title="parser exception">
<compile files="AAA.java">
<message kind="warning" line="3" text="no match for this type name: Screen"/>
</compile>
</ajc-test>
<ajc-test dir="bugs150/pr113066" title="possible static imports bug - 2">
<compile files="Consts2.java,TestNPE2.java" options="-1.5">
<message kind="error" line="2" text="The import a.Consts2.A_CONST cannot be resolved"/>

+ 7
- 1
weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java View File

@@ -134,10 +134,16 @@ public class PerThisOrTargetPointcutVisitor extends IdentityPointcutVisitor {
public Object visit(ThisOrTargetPointcut node, Object data) {
if ((m_isTarget && !node.isThis())
|| (!m_isTarget && node.isThis())) {
String pointcutString = node.getType().toString();
// see pr115788 "<nothing>" means there was a problem resolving types - that will be reported so dont blow up
// the parser here..
if (pointcutString.equals("<nothing>")) {
return new NoTypePattern();
}
//pertarget(target(Foo)) => Foo+ for type pattern matching
//perthis(this(Foo)) => Foo+ for type pattern matching
// TODO AV - we do like a deep copy by parsing it again.. quite dirty, would need a clean deep copy
TypePattern copy = new PatternParser(node.getType().toString().replace('$', '.')).parseTypePattern();
TypePattern copy = new PatternParser(pointcutString.replace('$', '.')).parseTypePattern();
// TODO AV - see dirty replace from $ to . here as inner classes are with $ instead (#108488)
copy.includeSubtypes = true;
return copy;

Loading…
Cancel
Save