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 120937 Details for
Bug 258906
[jsr269] Package annotations not visible to Java 6 APT processors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Test case
testcase.txt (text/plain), 4.87 KB, created by
Vladimir Piskarev
on 2008-12-19 08:52:38 EST
(
hide
)
Description:
Test case
Filename:
MIME Type:
Creator:
Vladimir Piskarev
Created:
2008-12-19 08:52:38 EST
Size:
4.87 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.compiler.apt.tests >Index: processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java,v >retrieving revision 1.17 >diff -u -r1.17 ElementProc.java >--- processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java 8 Apr 2008 01:19:59 -0000 1.17 >+++ processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java 19 Dec 2008 13:45:57 -0000 >@@ -68,6 +68,7 @@ > private TypeElement _elementDChild; > private TypeElement _elementAnnoZ; > private TypeElement _elementString; >+ private PackageElement _elementPD; > > // Initialized in examineDMethods() > private ExecutableElement _methodDvoid; >@@ -136,6 +137,10 @@ > return false; > } > >+ if (!examinePDAnnotations()) { >+ return false; >+ } >+ > reportSuccess(); > return false; > } >@@ -208,6 +213,17 @@ > reportError("DChild claims to not be a class"); > return false; > } >+ >+ _elementPD = _elementUtils.getPackageElement("targets.model.pd"); >+ if (_elementPD == null) { >+ reportError("element PD was not found"); >+ return false; >+ } >+ if (_elementPD.getKind() != ElementKind.PACKAGE) { >+ reportError("PD claims to not be a package"); >+ return false; >+ } >+ > _elementString = _elementUtils.getTypeElement("java.lang.String"); > return true; > } >@@ -857,4 +873,75 @@ > } > return true; > } >+ >+ private boolean examinePDAnnotations() { >+ // Examine annotation on package declaration >+ List<? extends AnnotationMirror> annotsPD = _elementPD.getAnnotationMirrors(); >+ if (null == annotsPD || annotsPD.isEmpty()) { >+ reportError("element PD reports no annotations"); >+ return false; >+ } >+ for (AnnotationMirror annotPD : annotsPD) { >+ DeclaredType annotPDType = annotPD.getAnnotationType(); >+ if (null == annotPDType) { >+ reportError("annotation mirror of AnnoZ on element PD reports null type"); >+ return false; >+ } >+ Element annotPDElem = annotPDType.asElement(); >+ if (!(annotPDElem instanceof TypeElement) || >+ !"targets.model.pa.AnnoZ".equals(((TypeElement)annotPDElem).getQualifiedName().toString())) { >+ reportError("annotation on element PD is not TypeElement targets.model.pa.AnnoZ"); >+ return false; >+ } >+ Map<? extends ExecutableElement, ? extends AnnotationValue> values = annotPD.getElementValues(); >+ if (null == values || values.isEmpty()) { >+ reportError("@AnnoZ on element PD reports no values"); >+ return false; >+ } >+ boolean foundStringMethod = false; >+ for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : values.entrySet()) { >+ String methodName = entry.getKey().getSimpleName().toString(); >+ if ("annoZString".equals(methodName)) { >+ foundStringMethod = true; >+ Object value = entry.getValue().getValue(); >+ if (!"annoZOnPD".equals(value)) { >+ reportError("Value of annoZString param on element PD is not \"annoZOnPD\""); >+ return false; >+ } >+ } >+ } >+ if (!foundStringMethod) { >+ reportError("Failed to find method annoZString on @AnnoZ on element PD"); >+ return false; >+ } >+ >+ // Check Elements.getElementValuesWithDefaults() >+ Map<? extends ExecutableElement, ? extends AnnotationValue> defaults = >+ _elementUtils.getElementValuesWithDefaults(annotPD); >+ if (null == defaults) { >+ reportError("Element.getElementValuesWithDefaults(annotPD) returned null"); >+ return false; >+ } >+ for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : defaults.entrySet()) { >+ String methodName = entry.getKey().getSimpleName().toString(); >+ if ("annoZString".equals(methodName)) { >+ foundStringMethod = true; >+ Object value = entry.getValue().getValue(); >+ if (!"annoZOnPD".equals(value)) { >+ reportError("Explicit value of AnnoZ.annoZString is not \"annoZOnPD\""); >+ return false; >+ } >+ } >+ else if ("annoZint".equals(methodName)) { >+ foundStringMethod = true; >+ Object value = entry.getValue().getValue(); >+ if (null == value || !value.equals(17)) { >+ reportError("Default value of AnnoZ.annoZint() is not 17"); >+ return false; >+ } >+ } >+ } >+ } >+ return true; >+ } > } >Index: resources/targets/model/pd/package-info.java >=================================================================== >RCS file: resources/targets/model/pd/package-info.java >diff -N resources/targets/model/pd/package-info.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ resources/targets/model/pd/package-info.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,2 @@ >+@targets.model.pa.AnnoZ(annoZString = "annoZOnPD") >+package targets.model.pd;
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 258906
:
120549
|
120550
| 120937 |
121339
|
121392
|
121550
|
121822