Bug 472224 - Update Factory.getPackedAnnotationBindings to never
return null entries.
Change-Id: I0ad3e3128c32d05d99c14000c63fd1a8ad354e0c
Signed-off-by: Stefan Xenos <sxenos@gmail.com>
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java
index d18616b..b6c5019 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/Factory.java
@@ -769,7 +769,8 @@
}
/* Wrap repeating annotations into their container, return an array of bindings.
- Incoming array is not modified.
+ Incoming array is not modified. The resulting array may be null but will not contain null
+ entries.
*/
public static AnnotationBinding [] getPackedAnnotationBindings(AnnotationBinding [] annotations) {
@@ -815,14 +816,17 @@
repackagedBindings[i] = new AnnotationBinding(containerType, elementValuePairs);
}
}
- if (repackagedBindings == annotations)
- return annotations;
-
+
int finalTally = 0;
for (int i = 0; i < length; i++) {
if (repackagedBindings[i] != null)
finalTally++;
}
+
+ if (repackagedBindings == annotations && finalTally == length) {
+ return annotations;
+ }
+
annotations = new AnnotationBinding [finalTally];
for (int i = 0, j = 0; i < length; i++) {
if (repackagedBindings[i] != null)