JetBrains/intellij-community · error · IllegalArgumentException

mutation.signature.problem.invalid.token

mutation.signature.problem.invalid.token

Error message

Invalid token: {0}; supported are 'this', 'io', 'param1', 'param2', and so on.

What it means

IllegalArgumentException from MutationSignature.parse when a token in a 'mutates' signature string is not one of 'this', 'io', 'param', or 'paramN'. The parser splits the signature on separators and rejects anything else, including 'param' followed by a non-numeric suffix or a negative/out-of-range index. The signature describes which arguments/ receivers a method mutates (used by @Contract-style mutation contracts).

Source

Thrown at java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/MutationSignature.java:242

    for (String part : signature.split(",")) {
      part = part.trim();
      if (part.equals("this")) {
        mutatesThis = true;
      }
      else if (part.equals("io")) {
        mutatesIO = true;
      }
      else if (part.equals("param")) {
        if (args.length == 0) {
          args = new boolean[] {true};
        } else {
          args[0] = true;
        }
      }
      else if (part.startsWith("param")) {
        int argNum = Integer.parseInt(part.substring("param".length()));
        if (argNum < 0 || argNum > 255) {
          throw new IllegalArgumentException(JavaAnalysisBundle.message("mutation.signature.problem.invalid.token", part));
        }
        if(args.length < argNum) {
          args = Arrays.copyOf(args, argNum);
        }
        args[argNum-1] = true;
      }
      else if (!part.isEmpty()) {
        throw new IllegalArgumentException(JavaAnalysisBundle.message("mutation.signature.problem.invalid.token", part));
      }
    }
    return new MutationSignature(Kind.OTHER, mutatesThis, mutatesIO, args);
  }

  /**
   * Checks the mutation signature
   *
   * @param signature signature to check
   * @param method    a method to apply the signature

View on GitHub (pinned to be881553f2)

Solutions

  1. Use only the tokens 'this', 'io', 'param', or 'param1'..'param255' in the mutates string
  2. Replace argN/argumentN style tokens with paramN
  3. Remove stray tokens or typos after commas

Example fix

// before
MutationSignature.parse("this, args1, io")
// after
MutationSignature.parse("this, param1, io")
Defensive patterns

Strategy: validation

Validate before calling

private static final Pattern TOKEN = Pattern.compile("this|io|param(?:[1-9][0-9]{0,2})?\\s*");
static boolean isValidMutationSignature(String s) {
  for (String part : s.split("[,;]")) {
    String t = part.trim();
    if (!t.isEmpty() && !TOKEN.matcher(t).matches()) return false;
  }
  return true;
}

Try / catch

try { MutationSignature.parse(sig); } catch (IllegalArgumentException e) { /* report invalid token to annotation author */ }

Prevention

When it happens

Trigger: Calling MutationSignature.parse (directly or via the mutation-contract annotation mechanism) with a string like "this,foo", "param-1", "param999", or a stray comma segment. Also 'paramN' where N parses outside 0..255.

Common situations: Hand-writing a mutates= attribute in an annotation and misspelling a token; using 'arg1' instead of 'param1'; copy-pasting from different contract dialects; empty segments from trailing commas are tolerated, other junk is not.

Understand the failure class

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/055507ff969898ca. Report an issue: GitHub.