oracle/graal · error · IllegalArgumentException

Signature cannot be empty

Error message

Signature cannot be empty

What it means

IllegalArgumentException from SignatureUtil.parseSignatureInternal (surfaced via SignatureUtil.parseSignature): the method descriptor string is empty. SignatureUtil parses JVMS 4.3.3 method descriptors like '(II)V'; the very first check rejects '' before even looking for the mandatory leading '('. The non-throwing twin isSignatureValid returns false for the same input.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/SignatureUtil.java:141

        }
    }

    /**
     * Checks if the given signature can be successfully parsed by
     * {@link #parseSignature(String, List)}.
     *
     * @param signature the signature to check
     * @param acceptMissingReturnType whether a signature without a return type is considered to be
     *            valid
     * @return whether the signature can be successfully parsed
     */
    public static boolean isSignatureValid(String signature, boolean acceptMissingReturnType) {
        return parseSignatureInternal(signature, null, false, acceptMissingReturnType) != null;
    }

    private static <T> T throwOrReturn(boolean shouldThrow, T returnValue, String errorMessage) {
        if (shouldThrow) {
            throw new IllegalArgumentException(errorMessage);
        } else {
            return returnValue;
        }
    }
}

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Guard the call: if signature == null || signature.isBlank(), skip or report the missing descriptor upstream instead of parsing.
  2. Fix the producer so a valid descriptor is always supplied (e.g. use MetaAccessProvider to derive the descriptor from a ResolvedJavaMethod rather than building it by hand).
  3. Use SignatureUtil.isSignatureValid(sig, false) to check before parsing when input is untrusted.

Example fix

// before
String ret = SignatureUtil.parseSignature(mayBeEmpty, params);

// after
if (sig == null || sig.isEmpty()) throw new IllegalStateException("missing descriptor for " + method);
String ret = SignatureUtil.parseSignature(sig, params);
Defensive patterns

Strategy: validation

Validate before calling

if (sig == null || sig.isEmpty()) {
    throw new IllegalArgumentException("method descriptor missing for " + method);
}
// or non-throwing check
boolean ok = SignatureUtil.isSignatureValid(sig, /*acceptMissingReturnType=*/ false);

Type guard

static boolean isNonEmptyMethodDescriptor(String s) {
    return s != null && !s.isEmpty() && s.charAt(0) == '(';
}

Try / catch

try {
    String ret = SignatureUtil.parseSignature(sig, params);
} catch (IllegalArgumentException e) {
    throw new MetadataException("bad descriptor '" + sig + "': " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Calling SignatureUtil.parseSignature("") (or with a string that trims to empty) — e.g. a null-safe default of "" for a missing descriptor, or reading a signature field that was never populated.

Common situations: Metadata parsing where a method record has an absent signature defaulted to empty string; generating descriptors from templates whose parameter/return placeholders were never substituted; passing a substring that computed to zero length.

Related errors


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