Starting with JDK9, non-static method references trigger the injection of a call to Objects.requireNonNull by the compiler. Before that, the injected call was just object.getClass().
That's actually a problem for us, since we added Objets.requireNonNull to the forbiddenapis blacklist (because we want to use our own Contracts class instead), and forbiddenapis seems to look at the bytecode, not the source code. So currently, any non-static method reference in our code will fail the build in JDK9+.
Note that this code injection occurs even when using Java 8 as a target.
One solution, for the time being, would be not to recompile our main code with JDK9/10/11: just compile it using JDK8, then re-use the generated artifacts to run integration tests with JDK11. That would be a great feature from the testing point of view, since we would be testing something closer to what we'll actually release. But... that's clearly a short-term solution, as we'll ultimately have to build everything with JDK11.
Another obvious solution would be to disable this forbiddenapis rule.
Maybe there are other solutions... ?