elastic/elasticsearch · error · IllegalArgumentException
Error trying to read [{}#ARGUMENTS]
Error message
Error trying to read [{}#ARGUMENTS] What it means
After confirming PARAMETERS exists and is of type String[], readArgumentNamesConstant calls Field.get(null) to read its value. If that reflection read throws IllegalArgumentException or IllegalAccessException (e.g. the field is not actually accessible despite being public, or security manager/module access rules block it), it is wrapped and rethrown as this IllegalArgumentException.
Source
Thrown at modules/lang-painless/src/main/java/org/elasticsearch/painless/ScriptClassInfo.java:299
"Painless needs a constant [String[] PARAMETERS] on all interfaces it implements with the "
+ "names of the method arguments but ["
+ iface.getName()
+ "] doesn't have one.",
e
);
}
if (false == argumentNamesField.getType().equals(String[].class)) {
throw new IllegalArgumentException(
"Painless needs a constant [String[] PARAMETERS] on all interfaces it implements with the "
+ "names of the method arguments but ["
+ iface.getName()
+ "] doesn't have one."
);
}
try {
return (String[]) argumentNamesField.get(null);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new IllegalArgumentException("Error trying to read [" + iface.getName() + "#ARGUMENTS]", e);
}
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- Ensure the interface's package is open to the Painless module (add 'opens' / 'requires transitive' as appropriate) or that no SecurityManager blocks reflection.
- Verify PARAMETERS is declared directly on the interface as 'public static final String[]' and is not shadowed.
- Inspect the chained cause (e original) for the precise IllegalAccess/IllegalArgument reason.
Example fix
// module-info.java — open the package to lang-painless
module my.plugin {
requires elasticsearch.painless;
opens com.example.scripts to elasticsearch.painless;
} Defensive patterns
Strategy: try-catch
Validate before calling
void assertParametersReadable(Class<?> iface) throws Exception {
Field f = iface.getField("PARAMETERS");
if (!f.getType().equals(String[].class)) throw new IllegalStateException("wrong type");
try { f.setAccessible(true); f.get(null); }
catch (IllegalAccessException e) { throw new IllegalStateException("open the package to lang-painless", e); }
} Try / catch
try {
new ScriptClassInfo(lookup, MyScript.class);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Error trying to read")
&& (e.getCause() instanceof IllegalAccessException || e.getCause() instanceof IllegalArgumentException)) {
fail("Module/access problem reading PARAMETERS: " + e.getCause().getMessage());
}
throw e;
} Prevention
- Under JPMS, 'opens <package> to elasticsearch.painless' (or unconditional opens).
- Do not install a SecurityManager that blocks reflective reads on context interfaces.
- Unit-test PARAMETERS readability in the same module layout used at runtime.
When it happens
Trigger: A PARAMETERS field that exists and is typed String[] but cannot be reflectively read — typically due to Java module-system encapsulation, a SecurityManager denying access, or the field being declared on a class rather than an interface with non-static semantics.
Common situations: Running under a restrictive JPMS module that does not 'opens' the interface's package; custom security manager; field shadowing across interfaces where get(null) resolves ambiguously.
Related errors
- Painless can only implement interfaces that have a single me
- no execute method found
- convertFromDef must take a single Object as an argument, not
- [{}#ARGUMENTS] has length [2] but [{}#execute] takes [1] arg
- Painless needs a constant [String[] PARAMETERS] on all inter
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/01525cf1c8d5ddfc.
Report an issue: GitHub.