The variable idx in getAsStringList method does not updated inside the for-loop, so idx always has the value 0. Since idx is used for Exception handling, it can make debuggers confused.
public List<String> getAsStringList(String methodName) {
// ....
List<String> out = new ArrayList<String>(v.valueGuesses.size());
int idx = 0;
for (Object guess : v.valueGuesses) {
Object result = guess == null ? null : guessToType(guess, String.class, v, idx);
if (result == null) {
if (v.valueGuesses.size() == 1) {
String[] s = getDefaultIf(methodName, new String[0]);
return Collections.unmodifiableList(Arrays.asList(s));
}
throw new AnnotationValueDecodeFail(v,
"I can't make sense of this annotation value. Try using a fully qualified literal.", idx);
}
out.add((String) result);
}
return Collections.unmodifiableList(out);
}
Expected behavior
public List<String> getAsStringList(String methodName) {
// ....
List<String> out = new ArrayList<String>(v.valueGuesses.size());
int idx = 0;
for (Object guess : v.valueGuesses) {
Object result = guess == null ? null : guessToType(guess, String.class, v, idx);
if (result == null) {
if (v.valueGuesses.size() == 1) {
String[] s = getDefaultIf(methodName, new String[0]);
return Collections.unmodifiableList(Arrays.asList(s));
}
throw new AnnotationValueDecodeFail(v,
"I can't make sense of this annotation value. Try using a fully qualified literal.", idx);
}
out.add((String) result);
idx++;
}
return Collections.unmodifiableList(out);
}
Describe the bug
The variable
idx
in getAsStringList method does not updated inside the for-loop, soidx
always has the value0
. Since idx is used for Exception handling, it can make debuggers confused.Expected behavior