diff options
author | pfullbright | 2011-06-23 17:12:59 +0000 |
---|---|---|
committer | pfullbright | 2011-06-23 17:12:59 +0000 |
commit | cf130b5341a2df3cb36d442f572795c93beb02f2 (patch) | |
tree | 8dd14f23b723187e69fda8874767e04ca10b0eec /jaxb | |
parent | eb0de6e28acb146d247f09900fe913fcfe2ab83a (diff) | |
download | webtools.dali-cf130b5341a2df3cb36d442f572795c93beb02f2.tar.gz webtools.dali-cf130b5341a2df3cb36d442f572795c93beb02f2.tar.xz webtools.dali-cf130b5341a2df3cb36d442f572795c93beb02f2.zip |
bug 345031 - catch CCE and avoid creating annotation in improper location
Diffstat (limited to 'jaxb')
-rw-r--r-- | jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotatedElement.java | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotatedElement.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotatedElement.java index f92161e939..16bc7bd06b 100644 --- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotatedElement.java +++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAnnotatedElement.java @@ -80,9 +80,17 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> if (jdtAnnotationName != null) { if (this.annotationIsValid(jdtAnnotationName)) { if (this.selectAnnotationNamed(this.annotations, jdtAnnotationName) == null) { // ignore duplicates - Annotation annotation = this.buildAnnotation(jdtAnnotationName); - annotation.initialize((CompilationUnit) node.getRoot()); - this.annotations.add(annotation); + // TODO - remove and replace with API post 3.0 + try { + Annotation annotation = this.buildAnnotation(jdtAnnotationName); + annotation.initialize((CompilationUnit) node.getRoot()); + this.annotations.add(annotation); + } + catch (ClassCastException cce) { + // an annotation has been placed on a java member to which it is not been targetted, + // and an exception has occurred in the annotation construction/initialization, + // which is expecting only a certain subset of members + } } } else if(this.annotationIsValidNestable(jdtAnnotationName)) { @@ -283,9 +291,17 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement> annotation.synchronizeWith((CompilationUnit) node.getRoot()); annotationsToRemove.remove(annotation); } else { - annotation = this.buildAnnotation(jdtAnnotationName); - annotation.initialize((CompilationUnit) node.getRoot()); - this.addItemToCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION); + // TODO - remove and replace with API post 3.0 + try { + annotation = this.buildAnnotation(jdtAnnotationName); + annotation.initialize((CompilationUnit) node.getRoot()); + this.addItemToCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION); + } + catch (ClassCastException cce) { + // an annotation has been placed on a java member to which it is not been targetted, + // and an exception has occurred in the annotation construction/initialization, + // which is expecting only a certain subset of members + } } } |