Skip to content

IllegalArgumentException if Invocation.process calls String varargs method #636

@dranuhl

Description

@dranuhl
  • Version of JMockit that was used:

OpenJDK 1.8.0_232, JUnit 4.12, JMockit 1.48

  • Description of the problem or enhancement request:

Below example JUnit code snippet fails with an java.lang.IllegalArgumentException

final List<String[]> commandArrays = new ArrayList<>();
new MockUp<ProcessBuilder>() {
  @Mock
  public ProcessBuilder command(Invocation inv, String... command) {
    commandArrays.add(command);
    inv.proceed((Object[])command);
  }
};

new ProcessBuilder().command("echo", "'Some test'");

Result:

 java.lang.IllegalArgumentException: Failure to invoke method: public java.lang.ProcessBuilder java.lang.ProcessBuilder.command(java.lang.String[])
  Caused by: java.lang.IllegalArgumentException: argument type mismatch

While faking ProcessBuilder via MockUp is probably a bad idea and mocking should be used instead, is it an easy example to show this bug.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions