oracle/graal · error · IllegalArgumentException

@%s annotated elements reached. Add following Native Image f

Error message

@%s annotated elements reached. Add following Native Image flags to see why they are reachable:

What it means

Error "@%s annotated elements reached. Add following Native Image flags to see why they are reachable:" thrown in oracle/graal.

Source

Thrown at compiler/src/jdk.graal.compiler.libgraal/src/jdk/graal/compiler/libgraal/LibGraalFeature.java:436

                        value = dc.getName() + "." + dc.getSimpleName();
                    }
                    case Field f -> {
                        name = "Field";
                        value = f.getDeclaringClass().getName() + "." + f.getName();
                    }
                    case Class<?> c -> {
                        name = "Type";
                        value = c.getName();
                    }
                    case null, default -> throw new GraalError("Unexpected element: ", e);
                }
                suggestions.computeIfAbsent(name, k -> new TreeSet<>()).add(value);
            }
            var sep = System.lineSeparator() + "  ";
            var s = suggestions.entrySet().stream().map(e -> e.getValue().stream().map(v -> "-H:AbortOn" + e.getKey() + "Reachable" + "=" + v).collect(Collectors.joining(sep))).collect(
                            Collectors.joining(sep));
            String anno = HostedOnly.class.getSimpleName();
            throw new IllegalArgumentException("@" + anno + " annotated elements reached. Add following Native Image flags to see why they are reachable:" + sep + s);
        }
    }

    @Override
    public void beforeCompilation(BeforeCompilationAccess access) {
        beforeCompilationAccess = access;
    }
}

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Fix the condition reported by the error: @{} annotated elements reached. Add Native Image flags to see why they are reachable
  2. Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call.

Example fix

Validate inputs and environment so that the failing condition does not occur: @{} annotated elements reached. Add Native Image flags to see why they are reachable

When it happens

Trigger: Thrown at compiler/src/jdk.graal.compiler.libgraal/src/jdk/graal/compiler/libgraal/LibGraalFeature.java:436 when the library encounters an invalid state.

Common situations: Occurs when a caller violates the contract guarded by this check: @{} annotated elements reached. Add Native Image flags to see why they are reachable


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/da815417c59402b5. Report an issue: GitHub.