When I run this test (using jmockit and TestNG, not sure if that's relevant):
public class Test {
@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();
}
}
I get this exception:
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)
....
I am using build 177.
I can rerun the test using --add-reads java.base=java.desktop
argument and it works fine but I don't really understand what is happening here.
Why am I getting that exception?
PrintException
does extendIOException
, and this feels like the inexplicableHeadlessException
s when using something not obviously Swing-related. I suggest filing a bug about a possible hidden class dependency. – Allure-Djdk.attach.allowAttachSelf
for surefire to allow jmockit to run. – Unhealthy