oracle/graal · error · IllegalArgumentException

missing ')' at end of method filter pattern:

Error message

missing ')' at end of method filter pattern: 

What it means

MethodFilter.BaseFilter parses patterns like 'Class.method(param;param)'. Once an opening '(' is found, the pattern must end with ')'; otherwise the parameter section cannot be extracted and IllegalArgumentException('missing ')' at end of method filter pattern: <pattern>') is thrown.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/debug/MethodFilter.java:282

            return Pattern.compile(createGlobString(pattern));
        } else {
            return Pattern.compile("([^\\.\\$]*[\\.\\$])*" + createGlobString(pattern));
        }
    }

    private static final class BaseFilter {
        private final Pattern clazz;
        private final Pattern methodName;
        private final Pattern[] signature;

        private BaseFilter(String sourcePattern) {
            String pattern = sourcePattern.trim();

            // extract parameter part
            int pos = pattern.indexOf('(');
            if (pos != -1) {
                if (pattern.charAt(pattern.length() - 1) != ')') {
                    throw new IllegalArgumentException("missing ')' at end of method filter pattern: " + pattern);
                }
                String[] signatureClasses = pattern.substring(pos + 1, pattern.length() - 1).split(";", -1);
                signature = new Pattern[signatureClasses.length];
                for (int i = 0; i < signatureClasses.length; i++) {
                    signature[i] = createClassGlobPattern(signatureClasses[i].trim());
                }
                pattern = pattern.substring(0, pos);
            } else {
                signature = null;
            }

            // If there is at least one "." then everything before the last "." is the class name.
            // Otherwise, the pattern contains only the method name.
            pos = pattern.lastIndexOf('.');
            if (pos != -1) {
                clazz = createClassGlobPattern(pattern.substring(0, pos));
                methodName = Pattern.compile(createGlobString(pattern.substring(pos + 1)));
            } else {

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Close the parameter list: Foo.bar(java.lang.String).
  2. If you did not mean to filter by signature, remove the '(' entirely — a bare class.method pattern needs no parentheses.
  3. Remember parameters are ';'-separated inside the parens: Foo.Bar.method(java.lang.String;int).

Example fix

# before
-Dgraal.MethodFilter=com.my.Foo.bar(java.lang.String

# after
-Dgraal.MethodFilter=com.my.Foo.bar(java.lang.String)
Defensive patterns

Strategy: validation

Validate before calling

static boolean isValidMethodFilterPattern(String p) {
    String t = p.trim();
    int open = t.indexOf('(');
    return open == -1 || t.charAt(t.length() - 1) == ')';
}
// call before new MethodFilter(...) / setting -Dgraal.MethodFilter

Prevention

When it happens

Trigger: Supplying -Dgraal.MethodFilter=Foo.bar(Baz or -Dgraal.Dump=Foo.bar(String (a filter with a signature but unbalanced parentheses). Note only the final character is checked — a pattern like 'Foo.bar(String' fails, and whitespace is trimmed before the check so a trailing ') ' is fine.

Common situations: Writing method filters for -Dgraal.Dump/-Dgraal.MethodFilter by hand and forgetting the closing paren on signature filters; shell line-wrapping splitting a long signature pattern; semicolon-separated signature lists (parameters are separated by ';' not ',') written with an unbalanced terminator.

Related errors


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