Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 30135 Details for
Bug 115252
want xlint message for improper annotation type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
testcase patch
pr115252-tests-patch.txt (text/plain), 18.50 KB, created by
Helen Beeken
on 2005-11-17 08:53:40 EST
(
hide
)
Description:
testcase patch
Filename:
MIME Type:
Creator:
Helen Beeken
Created:
2005-11-17 08:53:40 EST
Size:
18.50 KB
patch
obsolete
>Index: src/org/aspectj/systemtest/ajc150/Ajc150Tests.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java,v >retrieving revision 1.133 >diff -u -r1.133 Ajc150Tests.java >--- src/org/aspectj/systemtest/ajc150/Ajc150Tests.java 17 Nov 2005 12:45:23 -0000 1.133 >+++ src/org/aspectj/systemtest/ajc150/Ajc150Tests.java 17 Nov 2005 13:47:21 -0000 >@@ -713,6 +713,14 @@ > runTest("no StackOverflowError with circular pcd in generic aspect - 2"); > } > >+ public void testXlintMessageForImproperAnnotationType_pr115252_Exact() {runTest("xlint message for improper exact annotation type");} >+ public void testXlintMessageForImproperAnnotationType_pr115252_OR() {runTest("xlint message for improper annotation type inside OR");} >+ public void testXlintMessageForImproperAnnotationType_pr115252_AND() {runTest("xlint message for improper annotation type inside AND");} >+ public void testXlintMessageForImproperAnnotationType_pr115252_Return() {runTest("xlint message for improper annotated return type");} >+ public void testXlintMessageForImproperAnnotationType_pr115252_Declaring() {runTest("xlint message for improper annotated declaring type");} >+ public void testXlintMessageForImproperAnnotationType_pr115252_Parameter() {runTest("xlint message for improper annotated parameter type");} >+ public void testXlintMessageForImproperAnnotationType_pr115252_Throws() {runTest("xlint message for improper annotated throws pattern");} >+ > // helper methods..... > > public SyntheticRepository createRepos(File cpentry) { >Index: src/org/aspectj/systemtest/ajc150/ajc150.xml >=================================================================== >RCS file: /home/technology/org.aspectj/modules/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml,v >retrieving revision 1.212 >diff -u -r1.212 ajc150.xml >--- src/org/aspectj/systemtest/ajc150/ajc150.xml 17 Nov 2005 08:56:15 -0000 1.212 >+++ src/org/aspectj/systemtest/ajc150/ajc150.xml 17 Nov 2005 13:47:26 -0000 >@@ -1024,6 +1024,71 @@ > </compile> > </ajc-test> > >+ <ajc-test dir="bugs150/pr115252" title="xlint message for improper exact annotation type"> >+ <compile files="ExactAnnotationTypePattern.java" options="-1.5"> >+ <message kind="warning" line="20" text="field blah"/> >+ <message kind="warning" line="28" text="does not match because annotation @TypeAnnotation has @Target{ElementType.TYPE} [Xlint:unmatchedTargetKind]"/> >+ <message kind="warning" line="37" text="does not match because annotation @FieldAnnotation has @Target{ElementType.FIELD} [Xlint:unmatchedTargetKind]"/> >+ <message kind="warning" line="46" text="does not match because annotation @MethodAnnotation has @Target{ElementType.METHOD} [Xlint:unmatchedTargetKind]"/> >+ </compile> >+ </ajc-test> >+ >+ <ajc-test dir="bugs150/pr115252" title="xlint message for improper annotation type inside OR"> >+ <compile files="OrTypePattern.java" options="-1.5"> >+ <message kind="warning" line="26" text="does not match because annotation @FieldAnnotation has @Target{ElementType.FIELD} [Xlint:unmatchedTargetKind]"/> >+ <message kind="warning" line="31" text="does not match because annotation @TypeAnnotation has @Target{ElementType.TYPE} [Xlint:unmatchedTargetKind]"/> >+ <message kind="warning" line="31" text="does not match because annotation @FieldAnnotation has @Target{ElementType.FIELD} [Xlint:unmatchedTargetKind]"/> >+ </compile> >+ </ajc-test> >+ >+ <ajc-test dir="bugs150/pr115252" title="xlint message for improper annotation type inside AND"> >+ <compile files="AndTypePattern.java" options="-1.5"> >+ <message kind="warning" line="23" text="does not match because annotation @FieldAnnotation has @Target{ElementType.FIELD} [Xlint:unmatchedTargetKind]"/> >+ </compile> >+ </ajc-test> >+ >+ <ajc-test dir="bugs150/pr115252" title="xlint message for improper annotated return type"> >+ <compile files="AnnotationReturnType.java" options="-1.5"> >+ <!-- warnings coming from matching pointcuts and corresponding declare warnings --> >+ <message kind="warning" line="12" text="(@TypeAnnotation *) *(..)"/> >+ <message kind="warning" line="12" text="(@(TypeAnnotation || MethodAnnotation) *) *(..)"/> >+ <!-- xlint warnings that were put in as part of fix for pr115252 --> >+ <message kind="warning" line="32" text="does not match because annotation @MethodAnnotation has @Target{ElementType.METHOD} [Xlint:unmatchedTargetKind]"/> >+ <message kind="warning" line="37" text="does not match because annotation @MethodAnnotation has @Target{ElementType.METHOD} [Xlint:unmatchedTargetKind]"/> >+ </compile> >+ </ajc-test> >+ >+ <ajc-test dir="bugs150/pr115252" title="xlint message for improper annotated declaring type"> >+ <compile files="AnnotationDeclaringType.java" options="-1.5"> >+ <!-- warning coming from matching pointcuts and corresponding declare warnings --> >+ <message kind="warning" line="13" text="* (@TypeAnnotation *).*(..)"/> >+ <!-- xlint warning that was put in as part of fix for pr115252 --> >+ <message kind="warning" line="27" text="does not match because annotation @MethodAnnotation has @Target{ElementType.METHOD} [Xlint:unmatchedTargetKind]"/> >+ </compile> >+ </ajc-test> >+ >+ <ajc-test dir="bugs150/pr115252" title="xlint message for improper annotated parameter type"> >+ <compile files="AnnotationParameterType.java" options="-1.5"> >+ <!-- warning coming from matching pointcuts and corresponding declare warnings --> >+ <message kind="warning" line="12" text="* *(@TypeAnnotation *)"/> >+ <!-- xlint warning that was put in as part of fix for pr115252 --> >+ <message kind="warning" line="31" text="does not match because annotation @MethodAnnotation has @Target{ElementType.METHOD} [Xlint:unmatchedTargetKind]"/> >+ </compile> >+ </ajc-test> >+ >+ <ajc-test dir="bugs150/pr115252" title="xlint message for improper annotated throws pattern"> >+ <compile files="AnnotationThrowsPattern.java" options="-1.5"> >+ <!-- warnings coming from matching pointcuts and corresponding declare warnings --> >+ <message kind="warning" line="12" text="(* *.*(..) throws (@TypeAnnotation *))"/> >+ <message kind="warning" line="12" text="* *.*(..) throws !(@MethodAnnotation *)"/> >+ <message kind="warning" line="14" text="(* *.*(..) throws !(@TypeAnnotation *))"/> >+ <message kind="warning" line="14" text="* *.*(..) throws !(@MethodAnnotation *)"/> >+ <!-- xlint warnings that were put in as part of fix for pr115252 --> >+ <message kind="warning" line="40" text="does not match because annotation @MethodAnnotation has @Target{ElementType.METHOD} [Xlint:unmatchedTargetKind]"/> >+ <message kind="warning" line="46" text="does not match because annotation @MethodAnnotation has @Target{ElementType.METHOD} [Xlint:unmatchedTargetKind]"/> >+ </compile> >+ </ajc-test> >+ > <!-- ============================================================================ --> > <!-- ============================================================================ --> > >@@ -2870,7 +2935,10 @@ > <compile files="Base.java,Colored.java,WrongTarget.aj" options="-1.5" xlintfile="ignoreTypeNotExposed.properties"> > <message kind="error" line="8" text="The annotation @MethodColoring is disallowed for this location"/> > <message kind="error" line="9" text="The annotation @TypeColoring is disallowed for this location"/> >- </compile> >+ <!-- xlint warnings that were put in as part of fix for pr115252 --> >+ <message kind="warning" line="13" text="does not match because annotation @MethodColoring has @Target{ElementType.METHOD} [Xlint:unmatchedTargetKind]"/> >+ <message kind="warning" line="16" text="does not match because annotation @TypeColoring has @Target{ElementType.TYPE} [Xlint:unmatchedTargetKind]"/> >+ </compile> > </ajc-test> > > <ajc-test dir="java5/annotations/declare/atfield" title="declare @field - right target - source weaving"> >Index: bugs150/pr115252/AndTypePattern.java >=================================================================== >RCS file: bugs150/pr115252/AndTypePattern.java >diff -N bugs150/pr115252/AndTypePattern.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ bugs150/pr115252/AndTypePattern.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+import java.lang.annotation.Target; >+import java.lang.annotation.ElementType; >+ >+@Target({ElementType.METHOD}) >+@interface MethodAnnotation{} >+ >+@Target({ElementType.FIELD}) >+@interface FieldAnnotation{} >+ >+public class AndTypePattern { >+ >+ public void method1() {} >+ >+ @FieldAnnotation >+ int field = 1; >+ >+} >+ >+aspect A { >+ >+ // should display an xlint message because @FieldAnnotation can't be >+ // applied to methods >+ pointcut andPointcut() : execution(@(FieldAnnotation && MethodAnnotation) * *(..)); >+ declare warning : andPointcut() : "andPointcut()"; >+ >+} >Index: bugs150/pr115252/AnnotationDeclaringType.java >=================================================================== >RCS file: bugs150/pr115252/AnnotationDeclaringType.java >diff -N bugs150/pr115252/AnnotationDeclaringType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ bugs150/pr115252/AnnotationDeclaringType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+import java.lang.annotation.Target; >+import java.lang.annotation.ElementType; >+ >+@Target({ElementType.TYPE}) >+@interface TypeAnnotation{} >+ >+@Target({ElementType.METHOD}) >+@interface MethodAnnotation{} >+ >+@TypeAnnotation >+public class AnnotationDeclaringType { >+ >+ public void method1() { >+ } >+ >+} >+ >+aspect A { >+ >+ // matches the execution of any method where the declaring type >+ // has the @TypeAnnotation - should compile ok and get no xlint errors >+ pointcut pc() : execution(* (@TypeAnnotation *).*(..)); >+ declare warning : pc() : "* (@TypeAnnotation *).*(..)"; >+ >+ // should get an xlint warning because declaring types can only >+ // have the default @Target or @Target{ElementType.TYPE} target >+ pointcut pc2() : execution(* (@MethodAnnotation *).*(..)); >+ declare warning : pc2() : "* (@MethodAnnotation *).*(..)"; >+} >Index: bugs150/pr115252/AnnotationParameterType.java >=================================================================== >RCS file: bugs150/pr115252/AnnotationParameterType.java >diff -N bugs150/pr115252/AnnotationParameterType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ bugs150/pr115252/AnnotationParameterType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+import java.lang.annotation.Target; >+import java.lang.annotation.ElementType; >+ >+@Target({ElementType.TYPE}) >+@interface TypeAnnotation{} >+ >+@Target({ElementType.METHOD}) >+@interface MethodAnnotation{} >+ >+public class AnnotationParameterType { >+ >+ public void method1(MyClass m) { >+ } >+ >+} >+ >+@TypeAnnotation >+class MyClass { >+ >+} >+ >+aspect A { >+ >+ // shouldn't get an xlint warning because looking method which >+ // takes an argument that has the @TypeAnnotation >+ pointcut pc() : execution(* *(@TypeAnnotation *)); >+ declare warning : pc() : "* *(@TypeAnnotation *)"; >+ >+ // should get an xlint warning because can only have the default, >+ // or @Target{ElementType.TYPE} as an argument type >+ pointcut incorrectArgumentType() : execution(* *(@MethodAnnotation *)); >+ declare warning : incorrectArgumentType() : "argument type can only have @Target{ElementType.TYPE}"; >+ >+} >Index: bugs150/pr115252/AnnotationReturnType.java >=================================================================== >RCS file: bugs150/pr115252/AnnotationReturnType.java >diff -N bugs150/pr115252/AnnotationReturnType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ bugs150/pr115252/AnnotationReturnType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+import java.lang.annotation.Target; >+import java.lang.annotation.ElementType; >+ >+@Target({ElementType.TYPE}) >+@interface TypeAnnotation{} >+ >+@Target({ElementType.METHOD}) >+@interface MethodAnnotation{} >+ >+public class AnnotationReturnType { >+ >+ public MyClass method1() { >+ return new MyClass(); >+ } >+ >+} >+ >+@TypeAnnotation >+class MyClass { >+ >+} >+ >+aspect A { >+ >+ // shouldn't get an xlint warning because looking for a return type >+ // which has the @TypeAnnotation annotation >+ pointcut pc() : execution((@TypeAnnotation *) *(..)); >+ declare warning : pc() : "(@TypeAnnotation *) *(..)"; >+ >+ // should get an xlint warning because can only have the default, >+ // or @Target{ElementType.TYPE} as a return type >+ pointcut incorrectReturnType() : execution((@MethodAnnotation *) *(..)); >+ declare warning : incorrectReturnType() : "return type can only have @Target{ElementType.TYPE}"; >+ >+ // should get an xlint warning because @MethodAnnotation can never match >+ // but also get a declare warning because the @TypeAnnotation matches >+ pointcut orPointcut() : execution((@(TypeAnnotation || MethodAnnotation) *) *(..)); >+ declare warning : orPointcut() : "(@(TypeAnnotation || MethodAnnotation) *) *(..)"; >+ >+} >Index: bugs150/pr115252/AnnotationThrowsPattern.java >=================================================================== >RCS file: bugs150/pr115252/AnnotationThrowsPattern.java >diff -N bugs150/pr115252/AnnotationThrowsPattern.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ bugs150/pr115252/AnnotationThrowsPattern.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+import java.lang.annotation.Target; >+import java.lang.annotation.ElementType; >+ >+@Target({ElementType.TYPE}) >+@interface TypeAnnotation{} >+ >+@Target({ElementType.METHOD}) >+@interface MethodAnnotation{} >+ >+public class AnnotationThrowsPattern { >+ >+ public void method1() throws MyException {} >+ >+ public void method2() throws MyNonAnnotatedException {} >+ >+} >+ >+@TypeAnnotation >+class MyException extends Exception { >+ >+} >+ >+class MyNonAnnotatedException extends Exception { >+ >+} >+ >+aspect A { >+ >+ // shouldn't get xlint warnings because @TypeAnnotation is allowed >+ pointcut required() : execution(* *.*(..) throws (@TypeAnnotation *)); >+ declare warning : required() : "(* *.*(..) throws (@TypeAnnotation *))"; >+ >+ // shouldn't get xlint warnings because @TypeAnnotation is allowed >+ pointcut forbidden() : execution(* *.*(..) throws !(@TypeAnnotation *)); >+ declare warning : forbidden() : "(* *.*(..) throws !(@TypeAnnotation *))"; >+ >+ // should get an xlint warning here because can only have >+ // annotations with @Target{ElementType.TYPE} or the default >+ // @Target (which is everything) >+ pointcut required1() : execution(* *.*(..) throws (@MethodAnnotation *)); >+ declare warning : required1() : "* *.*(..) throws (@MethodAnnotation *)"; >+ >+ // should get an xlint warning here because can only have >+ // annotations with @Target{ElementType.TYPE} or the default >+ // @Target (which is everything) >+ pointcut forbidden1() : execution(* *.*(..) throws !(@MethodAnnotation *)); >+ declare warning : forbidden1() : "* *.*(..) throws !(@MethodAnnotation *)"; >+ >+} >Index: bugs150/pr115252/ExactAnnotationTypePattern.java >=================================================================== >RCS file: bugs150/pr115252/ExactAnnotationTypePattern.java >diff -N bugs150/pr115252/ExactAnnotationTypePattern.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ bugs150/pr115252/ExactAnnotationTypePattern.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+import java.lang.annotation.Target; >+import java.lang.annotation.ElementType; >+ >+@Target({ElementType.TYPE}) >+@interface TypeAnnotation{} >+ >+@Target({ElementType.METHOD}) >+@interface MethodAnnotation{} >+ >+@Target({ElementType.FIELD}) >+@interface FieldAnnotation{} >+ >+@interface AnyAnnotation{} >+ >+public class ExactAnnotationTypePattern { >+ >+ public void method1() {} >+ >+ @FieldAnnotation >+ int field = 1; >+ >+} >+ >+aspect A { >+ >+ // an xlint message should be displayed because @TypeAnnotation can only >+ // be applied to types, not methods >+ pointcut typePC() : execution(@TypeAnnotation * ExactAnnotationTypePattern.method1(..)); >+ declare warning : typePC() : "blah"; >+ >+ // should compile as normal, since @MethodAnnotation can be applied to methods >+ pointcut methodPC() : execution(@MethodAnnotation * ExactAnnotationTypePattern.method1(..)); >+ declare warning : methodPC() : "blah"; >+ >+ // an xlint message should be displayed because @FieldAnnotation can only >+ // be applied to fields, not methods >+ pointcut matchAll() : execution(@FieldAnnotation * *(..)); >+ declare warning : matchAll() : "blah"; >+ >+ // should compile as normal since @FieldAnnotation can be applied to fields >+ pointcut legalFieldPC() : set(@FieldAnnotation int ExactAnnotationTypePattern.field); >+ declare warning : legalFieldPC() : "field blah"; >+ >+ // an xlint message should be displayed because @MethodAnnotation can >+ // only be applied to methods, not fields >+ pointcut illegalFieldPC() : set(@MethodAnnotation int *); >+ declare warning : illegalFieldPC() : "field blah blah"; >+ >+ // no xlint message should be displayed here because @AnyAnnotation >+ // has the default target >+ pointcut anyAnnotation() : execution(@AnyAnnotation * *(..)); >+ declare warning : anyAnnotation() : "default target is allowed everywhere"; >+ >+} >Index: bugs150/pr115252/OrTypePattern.java >=================================================================== >RCS file: bugs150/pr115252/OrTypePattern.java >diff -N bugs150/pr115252/OrTypePattern.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ bugs150/pr115252/OrTypePattern.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+import java.lang.annotation.Target; >+import java.lang.annotation.ElementType; >+ >+@Target({ElementType.TYPE}) >+@interface TypeAnnotation{} >+ >+@Target({ElementType.METHOD}) >+@interface MethodAnnotation{} >+ >+@Target({ElementType.FIELD}) >+@interface FieldAnnotation{} >+ >+public class OrTypePattern { >+ >+ public void method1() {} >+ >+ @FieldAnnotation >+ int field = 1; >+ >+} >+ >+aspect A { >+ >+ // should display an xlint message because @FieldAnnotation can't be >+ // applied to methods >+ pointcut orPointcut() : execution(@(FieldAnnotation || MethodAnnotation) * *(..)); >+ declare warning : orPointcut() : "orPointcut()"; >+ >+ // two xlint messages should be displayed because neither @FieldAnnotation >+ // or @TypeAnnotation can match methods >+ pointcut orPointcut2() : execution(@(FieldAnnotation || TypeAnnotation) * *(..)); >+ declare warning : orPointcut2() : "orPointcut2()"; >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 115252
:
30135
|
30136
|
30220
|
30222