Skip to content

Getting java.lang.ClassCastException: class com.sun.tools.javac.tree.JCTree$JCIdent while updating dependencies using jdk-17 #2123

Closed

Description

@SyedTayyab99

Environment

  • Android OS version:31
  • JDK: jdk-17
  • AGP: 8.0
  • Gradle: 8.0.2

Observed behavior and steps to reproduce

I'm using jdk-17 because of gradle 8 update

compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
       jvmTarget = '17'
    }

I'm trying to upgrade the dependencies

implementation 'com.mapbox.maps:android:10.15.0-beta.1'
    implementation "com.mapbox.search:mapbox-search-android:1.0.0-rc.6"
    implementation "com.mapbox.search:mapbox-search-android-ui:1.0.0-rc.6"
    implementation "com.mapbox.search:offline:1.0.0-rc.6"
    implementation "com.mapbox.search:place-autocomplete:1.0.0-rc.6"
    implementation "com.mapbox.search:discover:1.0.0-rc.6"
    implementation "com.mapbox.search:autofill:1.0.0-rc.6"
    implementation "com.mapbox.navigation:android:2.14.0"
    // Updating dependencies from old to new
    /*implementation files('libs/mapbox-android-plugin-annotation-v9-0.9.0.aar')
    implementation files('libs/mapbox-android-plugin-places-v9-0.12.0.aar')
    implementation files('libs/mapbox-android-sdk-9.2.1.aar')
    implementation files('libs/mapbox-sdk-services-5.8.0.jar')
    implementation files('libs/mapbox-java-geojson-2.2.10.jar')
    implementation files('libs/mapbox-sdk-geojson-5.8.0.jar')
    implementation files('libs/mapbox-sdk-core-5.8.0.jar')
    implementation files('libs/mapbox-sdk-turf-5.7.0.jar')
    implementation files('libs/mapbox-sdk-directions-refresh-models-5.9.0-alpha.1.jar')
    implementation files('libs/mapbox-sdk-directions-models-5.9.0-alpha.1.jar')
    implementation files('libs/mapbox-android-core-4.0.0.aar')
    implementation files('libs/mapbox-android-gestures-0.7.0.aar')
    implementation files('libs/mapbox-android-telemetry-7.0.0.aar')
    implementation files('libs/mapbox-android-accounts-0.8.0.aar')
    implementation files('libs/mapbox-android-plugin-localization-0.6.0.aar')
    implementation files('libs/mapbox-android-geocoder-1.0.0.aar')*/

But I'm getting this error at compile time:

java.lang.ClassCastException: class com.sun.tools.javac.tree.JCTree$JCIdent cannot be cast to class com.sun.tools.javac.tree.JCTree$JCArrayTypeTree (com.sun.tools.javac.tree.JCTree$JCIdent and com.sun.tools.javac.tree.JCTree$JCArrayTypeTree are in module jdk.compiler of loader 'app')
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.visitVarDef(Unknown Source)
	at org.jetbrains.kotlin.kapt3.PrettyWithWorkarounds.visitVarDef(Kapt3Extension.kt:398)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printExpr(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printExpr(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printExprs(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printExprs(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.visitMethodDef(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printExpr(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printStat(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printStats(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printBlock(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.visitClassDef(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printExpr(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printStat(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printUnit(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.visitTopLevel(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printExpr(Unknown Source)
	at jdk.compiler/com.sun.tools.javac.tree.Pretty.printStat(Unknown Source)
	at org.jetbrains.kotlin.kapt3.Kapt3ExtensionKt.prettyPrint(Kapt3Extension.kt:373)
	at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.saveStubs(Kapt3Extension.kt:347)
	at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.generateKotlinSourceStubs(Kapt3Extension.kt:308)
	at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:175)
	at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:104)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:115)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:125)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:99)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:257)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:42)
	at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:248)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:88)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:47)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:168)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:100)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:46)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:495)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:133)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.kt:486)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:409)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:290)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:112)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:627)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1587)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
	at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
	at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Unknown Source)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

Errors were stored into /Users/SamKazmi/StudioProjects/android-native/.gradle/kotlin/errors/errors-1688562997837.log

P.S. I tired changing the jdk to 18 and 19 but i no luck

Activity

  1. added
    bug 🪲
    on Jul 5, 2023
  2. BakkerTom commented on Feb 20, 2024

    @BakkerTom

    I'm having the same problem, but I am using JavaVersion.VERSION_11. Any updates on this?

  3. kiryldz commented on Nov 1, 2024

    @kiryldz
    Contributor

    Based on given input it is hard to say what the issue could be. Assuming that this issue is pretty stale - I am leaning to the idea that there's some misconfiguration on user's end. I'll close this issue as stale. If this issue is still relevant - please provide a link to an empty project with the dependencies that cause this fail so that we can try reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions