stanfordnlp/CoreNLP · warning
found @Option annotations in class
Error message
found @Option annotations in class
What it means
After filling options into a target object, fillOptionsImpl() checks that if the class declared @Option-annotated fields, at least one option was actually filled. If annotations were found but nothing was set (e.g. all options are instance fields but only a static/Class object was passed, or command-line values did not match), it warns 'found @Option annotations in class <c>, but didn't set any of them (all options were instance variables and no instance given?)'. Parsing proceeds, but no options were applied.
Solutions
- Pass an instance (or let ArgumentParser instantiate the class) rather than the raw Class object when options are instance fields
- Make the @Option fields static if filling into a Class is intended
- Verify the command-line flag names match the @Option names exactly
- Use the ArgumentParser-produced bootstrap map (getUsage / bootstrapMap) to confirm expected flag names
Example fix
// before ArgumentParser.fillOptions(MyOptions.class, args); // after MyOptions opts = new MyOptions(); ArgumentParser.fillOptions(opts, args);
Defensive patterns
Strategy: validation
Validate before calling
// ensure an instance is used when @Option fields are non-static
Class<?> c = MyOptions.class;
boolean onlyInstanceFields = java.util.Arrays.stream(c.getDeclaredFields())
.anyMatch(fd -> fd.isAnnotationPresent(edu.stanford.nlp.util.ArgumentParser.Option.class)
&& !java.lang.reflect.Modifier.isStatic(fd.getModifiers()));
Object target = onlyInstanceFields ? c.getDeclaredConstructor().newInstance() : c;
ArgumentParser.fillOptions(target, args); Prevention
- Prefer filling into instances unless options are static
- Cross-check flag names against getUsage()/bootstrapMap output before running
- Keep a smoke test that fills one option per annotated class
When it happens
Trigger: Calling fillOptions(Class) instead of fillOptions(instance) when the @Option fields are non-static instance variables; passing a Class object for a class whose options require an instance to be instantiated and populated; flag names on the command line that match none of the @Option names so someOptionFilled stays false while annotations were seen.
Common situations: Bootstrapping a pipeline with the wrong class literal; reflection-based instantiation disabled; typos in command-line flags; passing Class.class where a new instance was expected.
Understand the failure class
Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.
Related errors
- Error getting field value for {fieldName}
- Cannot get field ${fieldName} from ${v}
- Bad arguments after ${flag}
- Unknown argument ${args[argIndex]}
- Unknown argument ${args[argIndex]}
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/c53e98a97b8f5952.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/util/ArgumentParser.java:414
canFill.put(name, f);
required.put(name, mark);
interner.put(name, name);
//(add alternate names)
if ( ! o.alt().isEmpty()) {
for (String alt : o.alt().split(" *, *")) {
alt = alt.toLowerCase();
if (canFill.containsKey(alt) && !alt.equals(name))
throw new IllegalArgumentException("Multiple declarations of option " + alt + ": " + canFill.get(alt) + " and " + f);
canFill.put(alt, f);
if (mark.first) required.put(alt, mark);
interner.put(alt, name);
}
}
}
}
//(check to ensure that something got filled, if any @Option annotation was found)
if (someOptionFound && !someOptionFilled) {
warn("found @Option annotations in class " + c + ", but didn't set any of them (all options were instance variables and no instance given?)");
}
}
//--Fill Options
for (Map.Entry<Object, Object> entry : options.entrySet()) {
String rawKeyStr = entry.getKey().toString();
String key = rawKeyStr.toLowerCase();
// (get values)
String value = entry.getValue().toString();
assert value != null;
Field target = canFill.get(key);
// (mark required option as fulfilled)
Pair<Boolean, Boolean> mark = required.get(key);
if (mark != null && mark.first) {
required.put(key, Pair.makePair(true, true));
}
// (fill the field)
if (target != null) {View on GitHub (pinned to 1b7edd19c4)