oracle/graal · error · UnsupportedOperationException
too many arguments
Error message
too many arguments
What it means
SnippetParameterInfo encodes per-parameter snippet annotations (@ConstantParameter, @VarargsParameter, @NonNullParameter) as bits in a single int, so a @Snippet method may have at most Integer.SIZE (32) parameters (SnippetParameterInfo.java:60). Thrown when a snippet method's parameter count exceeds this bit-packing limit.
Source
Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/spi/SnippetParameterInfo.java:60
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.Local;
import jdk.vm.ci.meta.LocalVariableTable;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
/**
* Encodes info about a snippet's parameters derived from annotations such as
* {@link ConstantParameter}, {@link VarargsParameter} and {@link NonNullParameter} as well as class
* file attributes such as {@link LocalVariableTable}. This supports libgraal where annotations and
* class file attributes are not available.
*/
public final class SnippetParameterInfo {
public SnippetParameterInfo(ResolvedJavaMethod method) {
assert getAnnotationValue(method, Snippet.class) != null : method + " must be annotated with @" + Snippet.class.getSimpleName();
int parameterCount = method.getSignature().getParameterCount(method.hasReceiver());
if (parameterCount > Integer.SIZE) {
throw new UnsupportedOperationException("too many arguments");
}
this.count = parameterCount;
int constant = 0;
int varargs = 0;
int nonNull = 0;
int offset = method.hasReceiver() ? 1 : 0;
var parsed = AnnotationValueSupport.getParameterAnnotationValues(method);
if (parsed != null) {
for (int i = offset; i < count; i++) {
List<AnnotationValue> annotations = parsed.values().get(i - offset);
int bit = 1 << i;
ResolvedJavaType container = parsed.container();
if (findAnnotationValue(annotations, ConstantParameter.class, container) != null) {
constant |= bit;
}
if (findAnnotationValue(annotations, VarargsParameter.class, container) != null) {
varargs |= bit;View on GitHub (pinned to a66e9ccd1d)
Solutions
- Refactor the snippet to take fewer parameters: group related values into a small object or frame/stack manipulation instead of individual parameters
- Move logic that needs many inputs out of the snippet and into a non-snippet helper called around it
- If you cannot change the snippet, split it into two snippets invoked from separate locations
Example fix
// before
@Snippet static void s(int a1, ..., int a33) { ... }
// after
record SArgs(int a1, ..., int a16) {}
@Snippet static void s(SArgs args, int b1, ..., int b16) { ... } Defensive patterns
Strategy: validation
Validate before calling
assert method.getParameterCount() <= Integer.SIZE : "snippet exceeds 32 parameters: " + method;
Prevention
- Keep snippets under ~30 parameters by design; group values into parameter objects
- When adding parameters to an existing snippet, check the current count first
When it happens
Trigger: Defining or loading a @Snippet-annotated method whose signature (including receiver) has more than 32 parameters; the check runs when SnippetParameterInfo is constructed from the ResolvedJavaMethod.
Common situations: Gradually adding parameters to a long-lived snippet until it crosses 32; generated snippet code that emits signatures based on template parameters.
Related errors
- Number of elements in a node list too high: %d
- Too many nodes in list:
- Too deep inlining, probably caused by recursive inlining.
- Could not find method in %s named %s
- Can't store into VarargsParameter array
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/8c59513cd950637f.
Report an issue: GitHub.