Browse Source

fix for Bugzilla Bug 91858

	  	NullPointerException when declare @type is spelt with capital letter

patch submitted by Andrew Huff
tags/PRE_ANDY
acolyer 19 years ago
parent
commit
78abc76610

+ 3
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java View File

@@ -80,7 +80,9 @@ public class DeclareAnnotationDeclaration extends DeclareDeclaration {
public void postParse(TypeDeclaration typeDec) {
super.postParse(typeDec);
((DeclareAnnotation)declareDecl).setAnnotationMethod(new String(selector));
if (declareDecl != null){
((DeclareAnnotation)declareDecl).setAnnotationMethod(new String(selector));
}
}
}

+ 7
- 0
tests/java5/annotations/declare/DeathByPoorSpelling.aj View File

@@ -0,0 +1,7 @@
// "declare @Type (should be @type)"

@interface myInterface {}

aspect A{
declare @Type: A : @myInterface;
}

+ 5
- 0
tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java View File

@@ -322,4 +322,9 @@ public class DeclareAnnotationTests extends XMLBasedAjcTestCase {
assertTrue("Should have a relationship but does not ",l.size()>0);
}
}
public void testDeclareTypeMisspelled() {
runTest("declare @Type (should be @type)");
}

}

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

@@ -125,11 +125,6 @@
<ajc-test dir="bugs150" title="bad asm for enums" vm="1.5">
<compile files="Rainbow.java" options="-emacssym,-1.5"/>
</ajc-test>

<ajc-test dir="bugs150" pr="83645" title="pertypewithin({interface}) illegal field modifier">
<compile files="PR83645.java"/>
<run class="PR83645"/>
</ajc-test>
<ajc-test dir="../docs/dist/doc/examples/introduction" title="introduction sample" vm="1.5">
<compile files="CloneablePoint.java,ComparablePoint.java,HashablePoint.java,Point.java" options="-1.5"/>
@@ -545,6 +540,12 @@
</run>
</ajc-test>

<ajc-test dir="java5/annotations/declare" pr="91858" title="declare @Type (should be @type)">
<compile files="DeathByPoorSpelling.aj" options="-1.5">
<message kind="error" line="6" text="Syntax error on token &quot;:&quot;, &quot;one of type, method, field, constructor&quot; expected"/>
</compile>
</ajc-test>
<!-- ======================================================================================= -->
<!-- Autoboxing tests -->
<!-- ======================================================================================= -->

+ 1
- 2
weaver/src/org/aspectj/weaver/patterns/PatternParser.java View File

@@ -139,8 +139,7 @@ public class PatternParser {
} else if (kind.equals("constructor")) {
ret = parseDeclareAtMethod(false);
} else {
throw new ParserException("expected one of type, method, field, constructor",
tokenSource.peek(-1));
throw new ParserException("one of type, method, field, constructor",tokenSource.peek(-1));
}
eat(";");
int endPos = tokenSource.peek(-1).getEnd();

Loading…
Cancel
Save