Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-08-23 17:07:51 +0000
committerkmoore2010-08-23 17:07:51 +0000
commit5efe124b3997bc992419ffe24c812deb04e8f328 (patch)
treeee47176742dc3fa518e8a88579ab8303e080d593
parentc6157db37e3da23320e3d5bad580a2867c492d05 (diff)
downloadwebtools.dali-5efe124b3997bc992419ffe24c812deb04e8f328.tar.gz
webtools.dali-5efe124b3997bc992419ffe24c812deb04e8f328.tar.xz
webtools.dali-5efe124b3997bc992419ffe24c812deb04e8f328.zip
323005 - NPE in AnnotationContainerTools with invalid nested annotation name
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java27
2 files changed, 26 insertions, 3 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java
index 2510e2128a..b3ddfd6fd8 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java
@@ -136,7 +136,7 @@ public final class AnnotationContainerTools {
private static <T extends NestableAnnotation> ArrayList<Annotation> getNestedAstAnnotations(CompilationUnit astRoot, AnnotationContainer<T> annotationContainer) {
ArrayList<Annotation> result = new ArrayList<Annotation>();
Annotation astContainerAnnotation = annotationContainer.getAstAnnotation(astRoot);
- if (astContainerAnnotation.isMarkerAnnotation()) {
+ if (astContainerAnnotation == null || astContainerAnnotation.isMarkerAnnotation()) {
// no nested annotations
}
else if (astContainerAnnotation.isSingleMemberAnnotation()) {
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
index ad7e948029..70952952a4 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java
@@ -103,6 +103,21 @@ public class JavaEntityTests extends ContextModelTestCase
}
});
}
+
+ private ICompilationUnit createTestEntityInvalidNamedQueries() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.NAMED_QUERIES);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity");
+ sb.append(CR);
+ sb.append("@NamedQueries(value={@NamedQuery(query=\"asdf\", name=\"foo\"), @NamedQuer})");
+ }
+ });
+ }
private void createTestAbstractEntity() throws Exception {
SourceWriter sourceWriter = new SourceWriter() {
@@ -2835,7 +2850,15 @@ public class JavaEntityTests extends ContextModelTestCase
entity.getQueryContainer().addNamedNativeQuery(0).setName("foo");
}
-
+
+ public void testInvalidNamedQueries() throws Exception {
+ createTestEntityInvalidNamedQueries();
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+
+ JavaEntity entity = getJavaEntity();
+ assertEquals(2, entity.getQueryContainer().namedQueriesSize());
+ }
+
public void testRemoveNamedQuery() throws Exception {
createTestEntity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
@@ -3304,7 +3327,7 @@ public class JavaEntityTests extends ContextModelTestCase
JavaAttributeOverride javaAttributeOverride = virtualAttributeOverrides.next();
assertEquals("id", javaAttributeOverride.getName());
- javaAttributeOverride = (JavaAttributeOverride) javaAttributeOverride.setVirtual(false);
+ javaAttributeOverride = javaAttributeOverride.setVirtual(false);
javaAttributeOverride.getColumn().setSpecifiedName("ID");
assertEquals("ID", javaEntity.getPrimaryKeyColumnName());
}

Back to the top