Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KSP] [KSP2] unexpected jvm signature V when processing in KSP2 #4505

Open
Tracked by #16
ZacSweers opened this issue Nov 12, 2024 · 6 comments
Open
Tracked by #16

[KSP] [KSP2] unexpected jvm signature V when processing in KSP2 #4505

ZacSweers opened this issue Nov 12, 2024 · 6 comments

Comments

@ZacSweers
Copy link

ZacSweers commented Nov 12, 2024

We ran into an odd case with KSP2 when assisted injecting an enum class from another module into a class

class Example @AssistedInject constructor(@Assisted database: Database)

// In an upstream module
enum class Database {
  APP,
  // ...
}

This seems like a fairly simple case, I'm not super sure where to look. This is with Kotlin 2.0.21 and KSP 2.0.21-1.0.27. It's unfortunately nearly impossible for me to debug directly because all these APIs are still shaded into dagger.spi.internal.shaded.androidx.room.compiler.processing.javac.kotlin

Trace

Caused by: dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException$UnexpectedException: 	
  Validation trace:	
    => element (CLASS): slack.telemetry.metric.db.LoggableSqliteDriver	
	at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.from(DaggerSuperficialValidation.java:527)	
	at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.access$100(DaggerSuperficialValidation.java:491)	
	at dagger.internal.codegen.base.DaggerSuperficialValidation.validateElement(DaggerSuperficialValidation.java:299)	
	at dagger.internal.codegen.processingstep.SuperficialValidator.validationExceptionsUncached(SuperficialValidator.java:58)	
	at dagger.internal.codegen.processingstep.SuperficialValidator.throwIfNearestEnclosingTypeNotValid(SuperficialValidator.java:47)	
	at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.lambda$process$0(TypeCheckingProcessingStep.java:92)	
	at com.google.common.collect.RegularImmutableMap.forEach(RegularImmutableMap.java:300)	
	at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:72)	
	at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:49)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.XProcessingStep.process(XProcessingStep.kt:57)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:134)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspBasicAnnotationProcessor.process(KspBasicAnnotationProcessor.kt:62)	
	at com.google.devtools.ksp.impl.KotlinSymbolProcessing$execute$1$1.invoke(KotlinSymbolProcessing.kt:552)	
	at com.google.devtools.ksp.impl.KotlinSymbolProcessing$execute$1$1.invoke(KotlinSymbolProcessing.kt:550)	
	at ksp.com.google.devtools.ksp.common.IncrementalContextBase.closeFilesOnException(IncrementalContextBase.kt:409)	
	at com.google.devtools.ksp.impl.KotlinSymbolProcessing.execute(KotlinSymbolProcessing.kt:550)	
	at com.google.devtools.ksp.impl.KSPLoader$Companion.loadAndRunKSP(KSPLoader.kt:37)	
	at com.google.devtools.ksp.impl.KSPLoader.loadAndRunKSP(KSPLoader.kt)

Cause

Caused by: java.lang.IllegalStateException: unexpected jvm signature V	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.javac.kotlin.JvmDescriptorUtilsKt.typeNameFromJvmSignature(JvmDescriptorUtils.kt:106)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeJavaPoetExtKt.asJTypeName(KSTypeJavaPoetExt.kt:99)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeJavaPoetExtKt.asJTypeName(KSTypeJavaPoetExt.kt:182)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeJavaPoetExtKt.asJTypeName(KSTypeJavaPoetExt.kt:64)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeJavaPoetExtKt.asJTypeName$resolveTypeName(KSTypeJavaPoetExt.kt:143)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeJavaPoetExtKt.asJTypeName(KSTypeJavaPoetExt.kt:148)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeJavaPoetExtKt.asJTypeName(KSTypeJavaPoetExt.kt:172)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeJavaPoetExtKt.asJTypeName(KSTypeJavaPoetExt.kt:154)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.DefaultKspType.resolveJTypeName(DefaultKspType.kt:43)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType$xTypeName$2.invoke(KspType.kt:90)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType$xTypeName$2.invoke(KspType.kt:69)	
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType.getXTypeName(KspType.kt:69)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType.access$getXTypeName(KspType.kt:49)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType$typeName$2.invoke(KspType.kt:61)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType$typeName$2.invoke(KspType.kt:61)	
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType.getTypeName(KspType.kt:61)	
	at dagger.internal.codegen.xprocessing.XTypes.toStableString(XTypes.java:496)	
	at dagger.internal.codegen.xprocessing.XElements.toStableString(XElements.java:346)	
	at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.getMessageForElement(DaggerSuperficialValidation.java:637)	
	at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.append(DaggerSuperficialValidation.java:547)	
	at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.access$200(DaggerSuperficialValidation.java:491)	
	at dagger.internal.codegen.base.DaggerSuperficialValidation.validateElement(DaggerSuperficialValidation.java:299)	
	at dagger.internal.codegen.base.DaggerSuperficialValidation.validateElements(DaggerSuperficialValidation.java:250)	
	at dagger.internal.codegen.base.DaggerSuperficialValidation.validateElement(DaggerSuperficialValidation.java:285)	
	at dagger.internal.codegen.processingstep.SuperficialValidator.validationExceptionsUncached(SuperficialValidator.java:58)	
	at dagger.internal.codegen.processingstep.SuperficialValidator.throwIfNearestEnclosingTypeNotValid(SuperficialValidator.java:47)	
	at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.lambda$process$0(TypeCheckingProcessingStep.java:92)	
	at com.google.common.collect.RegularImmutableMap.forEach(RegularImmutableMap.java:300)	
	at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:72)	
	at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:49)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.XProcessingStep.process(XProcessingStep.kt:57)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:134)	
	at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspBasicAnnotationProcessor.process(KspBasicAnnotationProcessor.kt:62)
@ZacSweers ZacSweers changed the title [KSP] [KSP2] unexpected jvm signature V when processing in KSP2 when encountering an error type [KSP] [KSP2] unexpected jvm signature V when processing in KSP2 Nov 12, 2024
@kuanyingchou
Copy link
Collaborator

kuanyingchou commented Nov 12, 2024

Hi, @ZacSweers , this should have been fixed with https://android-review.googlesource.com/c/platform/frameworks/support/+/3314733. A future Dagger release should include the fix.

@ZacSweers
Copy link
Author

Great! Between this and supporting Kotlin 2.1.0 (which is in RC but dagger apt is currently incompatible), it would be quite helpful if y'all would consider getting another release out. Sounds like dagger at HEAD would be fully compatible with K2 kapt and KSP

@ZacSweers
Copy link
Author

I don't believe this is fixed on HEAD. Just tested the latest snapshot and the same issue occurs

@ZacSweers
Copy link
Author

Or is the link above in androidx but not yet consumed in dagger?

@kuanyingchou
Copy link
Collaborator

Yes, sorry about the confusion and the internal link. It still needs to be consumed in Dagger. I've updated the link.

@Chang-Eric
Copy link
Member

@ZacSweers

Great! Between this and supporting Kotlin 2.1.0 (which is in RC but dagger apt is currently incompatible), it would be quite helpful if y'all would consider getting another release out. Sounds like dagger at HEAD would be fully compatible with K2 kapt and KSP

Actually the story is unfortunately more complicated. We actually don't support KSP2 right now. See #2349 (comment) for details, but we're right now still dealing with known issues with KSP2 and trying to make sure our own tests pass with KSP2. We're hoping to make more progress soon (several KSP2 issues have recently been fixed) but we still aren't in a spot where you should expect things to work. I know this is not what you probably want to hear, but a lot of it hasn't been in our control. It is however our top priority to get KSP2 working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants