BootstrapMethodError with custom bootclasspath in Android

I’m getting this build error when trying to build an android app with the Checker Framework.
Any ideas would help.

./gradlew compileReleaseJavaWithJavac -Ptypecheck=true
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html.
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2511Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72511Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2511Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72511Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2511Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2511Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2511Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2511Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2511Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42511Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2511Library UP-TO-DATE
:app:prepareComAndroidSupportTransition2511Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:app:compileReleaseJavaWithJavac
java.lang.BootstrapMethodError: call site initialization exception
        at java.lang.invoke.CallSite.makeSite(CallSite.java:341)
        at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:307)
        at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:297)
        at java.io.ObjectInputStream.<clinit>(ObjectInputStream.java:3578)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:80)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:45)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:61)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:66)
Caused by: java.lang.ClassCastException: bootstrap method failed to produce a CallSite
        at java.lang.invoke.CallSite.makeSite(CallSite.java:332)
        ... 7 more
:app:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileReleaseJavaWithJavac'.
> Failed to run Gradle Compiler Daemon
   > Process 'Gradle Compiler Daemon 1' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 10.184 secs

FAILURE: Build failed with an exception.

* What went wrong:
Process 'Gradle Compiler Daemon 1' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

The following are the relevant parts of the two build.gradle files

Top-level

boolean typecheck = project.properties['typecheck'] ?: false

allprojects {
    repositories {
        jcenter()
    }

    configurations {
        checkerFrameworkJavac {
            description = 'a customization of the OpenJDK javac compiler with additional support for type annotations'
        }
        checkerFrameworkAnnotatedJDK {
            description = 'a copy of JDK classes with Checker Framework type qualifers inserted'
        }
        checkerFramework {
            description = 'The Checker Framework: custom pluggable types for Java'
        }
    }

    if (typecheck) {
        gradle.projectsEvaluated {
            tasks.withType(JavaCompile).all { JavaCompile compile ->
                println "compile.options is: ${configurations.checkerFramework.asPath}"
                println "compile.options is: ${configurations.checkerFrameworkAnnotatedJDK.asPath}"
                println "compile.options is: ${configurations.checkerFrameworkJavac.asPath}"
                compile.options.compilerArgs = [
                        '-processor', 'org.checkerframework.checker.nullness.NullnessChecker',
                        '-processorpath', "${configurations.checkerFramework.asPath}",
                        // uncomment to turn Checker Framework errors into warnings
//                        '-Awarns',
                        "-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}"
                ]
                compile.options.compilerArgs += ['-source', '7', '-target', '7']
                if (options.bootClasspath) {
                    options.bootClasspath = "${configurations.checkerFrameworkJavac.asPath}:${System.getProperty("sun.boot.class.path")}:${options.bootClasspath}"
                } else {
                    options.bootClasspath = "${configurations.checkerFrameworkJavac.asPath}:${System.getProperty("sun.boot.class.path")}"
                }
                options.fork = true
                options.forkOptions.jvmArgs += ["-Xbootclasspath/p:${options.bootClasspath}"]
            }
        }
    }
}

Module level

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    // Checker framework
    ext.checkerFrameworkVersion = '2.1.4'
    ext.jdkVersion = JavaVersion.current().isJava7() ? 'jdk7' : 'jdk8'
    checkerFrameworkAnnotatedJDK "org.checkerframework:${jdkVersion}:${checkerFrameworkVersion}"
    checkerFrameworkJavac "org.checkerframework:compiler:${checkerFrameworkVersion}"
    checkerFramework "org.checkerframework:checker:${checkerFrameworkVersion}"
    compile "org.checkerframework:checker-qual:${checkerFrameworkVersion}"
}

The build error only happens when the custom bootclasspaths are specified in the top-level build script

options.bootClasspath = "${configurations.checkerFrameworkJavac.asPath}:${System.getProperty("sun.boot.class.path")}:${options.bootClasspath}"
options.forkOptions.jvmArgs += ["-Xbootclasspath/p:${options.bootClasspath}"]