title: Java11 Migration - compilation error, Symbol$ClassSymbol cannot be cast to class Symbol$MethodSymbol
body: <p>I am trying to migrate my application from java 8 to java 11 but am facing an error that I cannot get through:</p>
  <pre><code>compiler message file broken: key=compiler.misc.msg.bug arguments=11.0.7, {1}, {2}, {3}, {4}, {5}, {6}, {7}
  java.lang.ClassCastException: class com.sun.tools.javac.code.Symbol$ClassSymbol cannot be cast to class com.sun.tools.javac.code.Symbol$MethodSymbol (com.sun.tools.javac.code.Symbol$ClassSymbol and com.sun.tools.javac.code.Symbol$Me
  thodSymbol are in module jdk.compiler of loader 'app')
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitApply(TransTypes.java:626)
          at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:454)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitVarDef(TransTypes.java:499)
          at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:956)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:167)
          at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:454)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitLambda(TransTypes.java:540)
          at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1807)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:454)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translateArgs(TransTypes.java:200)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitApply(TransTypes.java:639)
          at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:454)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitVarDef(TransTypes.java:499)
          at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:956)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:167)
          at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:454)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitMethodDef(TransTypes.java:489)
          at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitClassDef(TreeTranslator.java:139)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translateClass(TransTypes.java:918)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.visitClassDef(TransTypes.java:475)
          at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:774)
          at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translate(TransTypes.java:454)
          at jdk.compiler/com.sun.tools.javac.comp.TransTypes.translateTopLevelClass(TransTypes.java:942)
          at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1553)
          at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1432)
          at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
          at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
          at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
          at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
          at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
          at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:93)
          at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)
          at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:54)
          at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:39)
          at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:113)
          at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:47)
          at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:46)
          at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:36)
          at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)
          at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:36)
          at org.gradle.workers.internal.FlatClassLoaderWorker.execute(FlatClassLoaderWorker.java:31)
          at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:56)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.base/java.lang.reflect.Method.invoke(Method.java:566)
          at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:118)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.base/java.lang.reflect.Method.invoke(Method.java:566)
          at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
          at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
          at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
          at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
          at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:412)
          at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
          at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
          at java.base/java.lang.Thread.run(Thread.java:834)
  </code></pre>
  <p>I have tried to add modules with <code>compilerArgs</code>:</p>
  <pre><code>compilerArgs.addAll(['--add-modules', 'jdk.compiler'])
  compilerArgs.addAll(['--add-modules', 'java.compiler'])
  </code></pre>
  <p>But that didn't resolve my problem either.</p>
  <p>I am using gradle 5.6 to build.</p>