Issue 1:
Try compiling with java 9:

First you will hit this. This can be fixed by using assertEquals, which also simplifies the test.

/home/rmuir/workspace/elasticsearch/core/src/test/java/org/elasticsearch/threadpool/ScalingThreadPoolTests.java:180: error: method invoked with incorrect number of arguments; expected 2, found 0
assertThat(stats(threadPool, threadPoolName).getThreads(), equalTo(128));
^
/home/rmuir/workspace/elasticsearch/core/src/test/java/org/elasticsearch/threadpool/ScalingThreadPoolTests.java:196: error: method invoked with incorrect number of arguments; expected 2, found 0
assertThat(stats(threadPool, threadPoolName).getCompleted(), equalTo(128L));
^

Next problem is that I am unsure -source/-target settings are being passed at all. Because I see class files referencing java 9 StringConcatFactory.

Next problem is that forbidden-apis screams, presumably because its being run in the wrong JVM (not the JAVA_HOME that is set, but the java 8 one running gradle itself). It sees StringConcatFactory and fails the build:

Caused by: org.gradle.internal.UncheckedException: de.thetaphi.forbiddenapis.ForbiddenApiException: Check for forbidden API calls failed: java.lang.ClassNotFoundException: java.lang.invoke.StringConcatFactory
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:45)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:78)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 68 more
Caused by: de.thetaphi.forbiddenapis.ForbiddenApiException: Check for forbidden API calls failed: java.lang.ClassNotFoundException: java.lang.invoke.StringConcatFactory
at de.thetaphi.forbiddenapis.Checker.run(Checker.java:550)
at de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis.checkForbidden(CheckForbiddenApis.java:551)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
... 75 more
Caused by: java.lang.ClassNotFoundException: java.lang.invoke.StringConcatFactory
at de.thetaphi.forbiddenapis.Checker.getClassFromClassLoader(Checker.java:264)
at de.thetaphi.forbiddenapis.Checker.lookupRelatedClass(Checker.java:277)
at de.thetaphi.forbiddenapis.ClassScanner$2.checkMethodAccess(ClassScanner.java:349)
at de.thetaphi.forbiddenapis.ClassScanner$2.checkHandle(ClassScanner.java:411)
at de.thetaphi.forbiddenapis.ClassScanner$2.visitInvokeDynamicInsn(ClassScanner.java:497)
at de.thetaphi.forbiddenapis.asm.ClassReader.a(Unknown Source)
at de.thetaphi.forbiddenapis.asm.ClassReader.b(Unknown Source)
at de.thetaphi.forbiddenapis.asm.ClassReader.accept(Unknown Source)
at de.thetaphi.forbiddenapis.asm.ClassReader.accept(Unknown Source)
at de.thetaphi.forbiddenapis.Checker.checkClass(Checker.java:528)
at de.thetaphi.forbiddenapis.Checker.run(Checker.java:545)
... 77 more

BUILD FAILED

Issue 2:
Does it work with existing java 9 builds at all?

I get vague compilation failures from maven, with no mention of any warnings or anything, even when running with debugging enabled.

We might need to conditionally disable Werror for java 9, but it would be good to investigate why its not working and get it fixed (seems like a maven bug).