New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalAccessError when mocking ProcessBuilder with Java 9 #428

Closed
assylias opened this Issue Jul 11, 2017 · 0 comments

Comments

2 participants
@assylias

assylias commented Jul 11, 2017

jmockit 1.33
TestNG 6.9.10
Java 9 (build 177)

This test throws an IllegalAccessError at runtime:

public class MainTest {
  @Test public void test(@Mocked ProcessBuilder pb) throws IOException {
    new Expectations() {{ pb.start(); result = null; }};
    assertNull(m());
  }

  public static Process m() throws IOException {
    return new ProcessBuilder("").start();
  }
}

Stacktrace:

java.lang.IllegalAccessError: class java.lang.ProcessBuilder (in module java.base) cannot access class javax.print.PrintException (in module java.desktop) because module java.base does not read module java.desktop

    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java)
    at MainTest$1.<init>(MainTest.java:14)
    at MainTest.test(MainTest.java:14)

Related stackoverflow question: https://stackoverflow.com/q/45018360/829571

@rliesenfeld rliesenfeld self-assigned this Jul 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment