Pavel,
I did not mean to suggest the error message was the only problem. I
merely wanted to note a subtle detail in the message that might
otherwise have been easy to overlook, and which might be a clue to the
underlying problem.
-- Jon
On 03/20/2017 02:44 PM, Pavel Bucek wrote:
// moving from jdk9-dev, as suggested.
Hi Jon,
Thanks for clarification of the error message.
The main point here is that adding "import ... " fixes the issue,
which doesn't feel correct.
When dependencies are put on the classpath, the import statement is
not required.
Regards,
Pavel
On 20/03/2017 22:26, Jonathan Gibbons wrote:
If nothing else, the javac error message needs work.
(package org.mockito.stubbing is declared in module , which does not
export it)
The space between "module" and "," means there's an "empty" module
name there, for the unnamed module, which should have been stated
explicitly (i.e. "declared in the unnamed module").
Follow-ups would be better on jigsaw-dev or compiler-dev.
-- Jon
On 03/20/2017 02:15 PM, Libor Kramolis wrote:
Hello.
I have problem to compile following unit test:
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class TestCase {
@Test
public void test() {
Context context = mock(Context.class);
when(context.test(any())) //returns
org.mockito.stubbing.OngoingStubbing
.thenReturn("mock");
assertEquals("mock", context.test("any"));
}
interface Context {
String test(String value);
}
}
with following error:
src/test/java/tst/TestCase.java:15: error:
OngoingStubbing.thenReturn(T,T...) in package org.mockito.stubbing
is not accessible
.thenReturn("mock");
^
(package org.mockito.stubbing is declared in module , which does
not export it)
where T is a type-variable:
T extends Object declared in interface OngoingStubbing
1 error
Interface org.mockito.stubbing.OngoingStubbing is returned by
when(…) method. And whenever I explicitly import the interface (no
other change in code is necessary) compilation works.
Full reproduced sources are available in zip file at
http://anise.cz/~paja/liba/reproducer.zip
<http://anise.cz/~paja/liba/reproducer.zip>. It contains javac
commands. It is also possible to build it by Maven.
What do you think about this behaviour? It seems to me as a bug. The
import statement is very artificial in this case.
Thanks in advance for your help.
Best regards,
Libor