oracle/graal · critical · IllegalArgumentException
%s missing element %s
Error message
%s missing element %s
What it means
DefaultHomeFinder treats java.home as a GraalVM installation only if it contains lib/modules (the jimage file introduced by the JDK 9+ module system). If java.home exists but lib/modules is missing, the finder concludes this is not a module-image-based GraalVM home and throws an AssertionError naming the offending path. It is the structural check that separates a JDK 9+ layout from a plain JDK 8 JRE.
Source
Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/annotation/AnnotationValue.java:197
/// | Class | ResolvedJavaType |
/// | Enum | EnumElement |
/// | Annotation | AnnotationValue |
/// | T[] | unmodifiable List<T> where `T` is one of the above types |
///
/// @param <V> the type of the element as per the `AnnotationValue` column in the above
/// table or [Object]
/// @param elementType the class for the type of the element or `Object.class`
/// @return the annotation element denoted by `name`
/// @throws ClassCastException if the element is not of type `elementType`
/// @throws IllegalArgumentException if this annotation has no element named `name`
/// or if `elementType != Object.class` and the element is of type
/// [ErrorElement]
// @formatter:on
public <V> V get(String name, Class<V> elementType) {
checkError();
Object val = elements.get(name);
if (val == null) {
throw new IllegalArgumentException(type.toJavaName() + " missing element " + name);
}
if (elementType != Object.class && val instanceof ErrorElement ee) {
throw ee.generateException();
}
return elementType.cast(val);
}
/**
* Gets the array element denoted by {@code name} as an unmodifiable list.
*
* @throws ClassCastException if the element is not an array, or it's a non-empty array whose
* first element does not have type {@code componentType}
* @throws IllegalArgumentException if this annotation has no element named {@code name}
*
* @param <V> the component type of the array as per the {@code AnnotationValue} column in the
* table {@linkplain #get(String, Class) here}
*/
@SuppressWarnings("unchecked")View on GitHub (pinned to a66e9ccd1d)
Solutions
- Install and select a GraalVM or JDK 11+ distribution whose lib/modules exists, e.g. ls $JAVA_HOME/lib/modules to confirm.
- Fix JAVA_HOME / java.home to point at the GraalVM installation root, not a subdirectory like bin or lib.
- Re-download the GraalVM distribution if lib/modules is missing from the archive.
Defensive patterns
Strategy: validation
Validate before calling
Path jh = Paths.get(System.getProperty("java.home", ""));
if (!Files.isRegularFile(jh.resolve(Paths.get("lib", "modules")))) {
throw new IllegalStateException("Not a JDK 9+/GraalVM home (no lib/modules): " + jh);
}
HomeFinder.findHome(); Prevention
- Standardize on JDK 11+ / GraalVM distributions and verify lib/modules exists in CI setup scripts.
- Point java.home at the JDK root, never at bin/ or a JDK 8 jre/ directory.
When it happens
Trigger: Pointing java.home at a JDK 8 or earlier installation (no lib/modules); using a stripped runtime from which the modules image was removed; pointing at a build-output JDK directory that has not yet had its image assembled.
Common situations: Running GraalVM tooling that requires JDK 11+ while JAVA_HOME still targets JDK 8; using a JRE-style directory instead of a full image; partially downloaded or corrupted GraalVM distributions.
Related errors
- nargs not allowed
- illegal type for element %s: %s
- Cannot compare {JavaLangRuntimeVersion.__name__} to {type(ot
- Unexpected enum type: %s
- Cannot look up %s annotation at Native Image runtime
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/2318f15fe9d24e44.
Report an issue: GitHub.