java: incorrect annotation decoding fixed

This commit is contained in:
Roman Shevchenko
2013-08-26 17:36:39 +04:00
parent 9f07ea55e1
commit 80087098e8
11 changed files with 25 additions and 3 deletions
@@ -31,14 +31,20 @@ public class ClsAnnotationParameterListImpl extends ClsElementImpl implements Ps
public ClsAnnotationParameterListImpl(@NotNull PsiAnnotation parent, @NotNull PsiNameValuePair[] psiAttributes) {
myParent = parent;
myAttributes = new ClsNameValuePairImpl[psiAttributes.length];
for (int i = 0; i < myAttributes.length; i++) {
for (int i = 0; i < psiAttributes.length; i++) {
String name = psiAttributes[i].getName();
PsiAnnotationMemberValue value = psiAttributes[i].getValue();
if (value == null) {
String anno = parent instanceof ClsAnnotationImpl ? ((ClsAnnotationImpl)parent).getStub().getText() : parent.getText();
Logger.getInstance(getClass()).error("name=" + name + " anno=[" + anno + "]");
Logger.getInstance(getClass()).error("name=" + name + " anno=[" + anno + "] file=" + parent.getContainingFile());
value = new ClsLiteralExpressionImpl(this, "null", PsiType.NULL, null);
}
if (psiAttributes.length == 1 && "value".equals(name)) {
name = null; // cosmetics - omit default attribute name
}
myAttributes[i] = new ClsNameValuePairImpl(this, name, value);
}
}
@@ -556,7 +556,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
myBuilder.append(',');
}
if (name != null && !"value".equals(name)) {
if (name != null) {
myBuilder.append(name).append('=');
}
}
@@ -25,6 +25,9 @@ abstract class Annotations {
@pkg.Annotations.A4(ids = {42, 84})
abstract void m4b();
@pkg.Annotations.A5(b = true, value = java.lang.Integer.class)
abstract void m5();
static @interface IndeterminateAnno {
float f1() default -1.0f / 0.0;
@@ -39,6 +42,12 @@ abstract class Annotations {
double d3() default 1.0 / 0.0;
}
static @interface A5 {
boolean b() default false;
java.lang.Class<? extends java.lang.Number> value() default java.lang.Integer.class;
}
static @interface A4 {
int[] ids() default {};
}
@@ -16,6 +16,11 @@ abstract class Annotations {
int[] ids() default { };
}
@interface A5 {
boolean b() default false;
Class<? extends Number> value() default Integer.class;
}
@A1 abstract void m1();
@A2() abstract void m2a();
@@ -26,6 +31,8 @@ abstract class Annotations {
@A4 abstract void m4a();
@A4(ids = {42, 84}) abstract void m4b();
@A5(b = true, value = Integer.class) abstract void m5();
@interface IndeterminateAnno {
float f1() default Float.NEGATIVE_INFINITY;
float f2() default Float.NaN;