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] NullPointerException #600

Closed
nazarabd3005 opened this issue Mar 12, 2024 · 23 comments
Closed

[KSP] NullPointerException #600

nazarabd3005 opened this issue Mar 12, 2024 · 23 comments
Labels
bug Something isn't working v2.0 Improvement changes under consideration for v2.0

Comments

@nazarabd3005
Copy link

 [ksp] java.lang.NullPointerException
	at com.ramcosta.composedestinations.ksp.processors.Processor$getSubModuleInfos$2$2.invoke(Processor.kt:306)
	at com.ramcosta.composedestinations.ksp.processors.Processor$getSubModuleInfos$2$2.invoke(Processor.kt:144)
	at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
	at kotlin.sequences.FlatteningSequence$iterator$1.next(Sequences.kt:299)
	at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:816)
	at com.ramcosta.composedestinations.ksp.processors.Processor.getSubModuleInfos(Processor.kt:161)
	at com.ramcosta.composedestinations.ksp.processors.Processor.process(Processor.kt:91)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:306)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:304)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:410)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:304)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:112)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:77)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:256)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:247)
	at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:247)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:87)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:43)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:165)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1523)

HI @raamcosta ,
I getting this error when building the App module.

currently use:
v.2.0.0-alpha05

raamcosta added a commit that referenced this issue Mar 12, 2024
raamcosta added a commit that referenced this issue Mar 12, 2024
raamcosta added a commit that referenced this issue Mar 12, 2024
@raamcosta
Copy link
Owner

Hi @nazarabd3005 👋

I need a little help here. Could you please try a special version I made just to test this? It should have more logs in the build tab so we can try to see what exactly is null and why.

Version 2.0.0-alpha05-test01.

It is still building right now, I'll let you know as soon as it's available.

@raamcosta
Copy link
Owner

It's up @nazarabd3005.
Please try it and past here the log warnings you get!

@nazarabd3005
Copy link
Author

Hi @raamcosta
this is the result of build with test version

w: [ksp] path infos declarations = [_PathInfo_ModuleRegistry_d50bc146_2445_415d_adc2_fd6f30b5dbda, _PathInfo_ModuleRegistry_41c62ed4_f9c9_4c1f_a00a_436732bda73c, _PathInfo_ModuleRegistry_11989043_45c3_4926_80a2_c781ff1b7ea6, _PathInfo_ModuleRegistry_f818ac4c_d41c_4f6a_ac3f_f4c8cf65532a, _PathInfo_ModuleRegistry_bdcf53b4_7cda_4c01_842f_fffde3ae12ea, _PathInfo_ModuleRegistry_0c3addf0_4e8d_4f43_98f7_e7750fa974bd, _PathInfo_ModuleRegistry_d83b5b36_83df_4fa2_9208_8f0a5378c6e3, _PathInfo_ModuleRegistry_db73aee8_6d9a_4d73_b610_de27d9ba1f34, _PathInfo_ModuleRegistry_abe25b29_9a5f_495d_acc9_12997797bc5c]
w: [ksp] path infos final = {d50bc146_2445_415d_adc2_fd6f30b5dbda=/Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/auth/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_d50bc146_2445_415d_adc2_fd6f30b5dbda.kt, 41c62ed4_f9c9_4c1f_a00a_436732bda73c=/Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/telemedicine/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_41c62ed4_f9c9_4c1f_a00a_436732bda73c.kt, 11989043_45c3_4926_80a2_c781ff1b7ea6=/Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/profile/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_11989043_45c3_4926_80a2_c781ff1b7ea6.kt, f818ac4c_d41c_4f6a_ac3f_f4c8cf65532a=/Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/pharmacy_online/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_f818ac4c_d41c_4f6a_ac3f_f4c8cf65532a.kt, bdcf53b4_7cda_4c01_842f_fffde3ae12ea=/Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/order/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_bdcf53b4_7cda_4c01_842f_fffde3ae12ea.kt, 0c3addf0_4e8d_4f43_98f7_e7750fa974bd=/Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/home/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_0c3addf0_4e8d_4f43_98f7_e7750fa974bd.kt, d83b5b36_83df_4fa2_9208_8f0a5378c6e3=/Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/online_booking/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_d83b5b36_83df_4fa2_9208_8f0a5378c6e3.kt, db73aee8_6d9a_4d73_b610_de27d9ba1f34=/Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/shared/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_db73aee8_6d9a_4d73_b610_de27d9ba1f34.kt, abe25b29_9a5f_495d_acc9_12997797bc5c=/Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/doctor_schedule/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_abe25b29_9a5f_495d_acc9_12997797bc5c.kt}
w: [ksp] module registry declarations = [_ModuleRegistry_db73aee8_6d9a_4d73_b610_de27d9ba1f34, _ModuleRegistry_f818ac4c_d41c_4f6a_ac3f_f4c8cf65532a, _ModuleRegistry_d83b5b36_83df_4fa2_9208_8f0a5378c6e3, _ModuleRegistry_bdcf53b4_7cda_4c01_842f_fffde3ae12ea, _ModuleRegistry_d50bc146_2445_415d_adc2_fd6f30b5dbda, _ModuleRegistry_0c3addf0_4e8d_4f43_98f7_e7750fa974bd, _ModuleRegistry_41c62ed4_f9c9_4c1f_a00a_436732bda73c, _ModuleRegistry_abe25b29_9a5f_495d_acc9_12997797bc5c, _ModuleRegistry_11989043_45c3_4926_80a2_c781ff1b7ea6]
w: [ksp] declaration _ModuleRegistry_db73aee8_6d9a_4d73_b610_de27d9ba1f34 --- moduleRegistryId db73aee8_6d9a_4d73_b610_de27d9ba1f34
w: [ksp] processing module annotation @_Info_db73aee8_6d9a_4d73_b610_de27d9ba1f34
w: [ksp] map result /Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/shared/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_db73aee8_6d9a_4d73_b610_de27d9ba1f34.kt
w: [ksp] destination qualifiedName = id.kesia.feature.shared.destinations.FilterDoctorBottomScreenDestination
w: [ksp] resultType qualifiedName = id.kesia.feature.shared.filter_doctor.FilterDoctorNavArgs
w: [ksp] destination qualifiedName = id.kesia.feature.shared.destinations.DoctorSchedulePoliListScreenDestination
w: [ksp] resultType qualifiedName = id.kesia.feature.shared.filter_doctor.FilterDoctorNavArgs
w: [ksp] destination qualifiedName = id.kesia.feature.shared.destinations.ForgotMrScreenDestination
w: [ksp] resultType qualifiedName = kotlin.String
w: [ksp] destination qualifiedName = id.kesia.feature.shared.destinations.InsurerListBottomScreenDestination
e: [ksp] java.lang.NullPointerException
	at com.ramcosta.composedestinations.ksp.processors.Processor$getSubModuleInfos$3$2.invoke(Processor.kt:324)
	at com.ramcosta.composedestinations.ksp.processors.Processor$getSubModuleInfos$3$2.invoke(Processor.kt:157)
	at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
	at kotlin.sequences.FlatteningSequence$iterator$1.next(Sequences.kt:299)
	at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:811)
	at com.ramcosta.composedestinations.ksp.processors.Processor.getSubModuleInfos(Processor.kt:177)
	at com.ramcosta.composedestinations.ksp.processors.Processor.process(Processor.kt:91)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:306)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:304)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:410)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:304)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:112)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:77)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:256)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:247)
	at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:247)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:87)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:43)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:165)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1523)
	at jdk.internal.reflect.GeneratedMethodAccessor91.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)

@raamcosta
Copy link
Owner

raamcosta commented Mar 12, 2024

Hi again @nazarabd3005

Can you please open file:

/Users/nazarabdullah/AndroidStudioProjects/KesiaMobile/feature/shared/build/generated/ksp/debug/kotlin/_generated/_ramcosta/_composedestinations/_moduleregistry/_ModuleRegistry_<something>

And show me its contents?

It seems like there is an annotation _Info_<something> that has an issue with typeResult. I need to understand what that is.

More specifically, it seems like it is something like this:

@_Info_<something>(
    moduleName = "",
    packageName = ????
    typeResults = [
       _Destination_Result_Info_<something>(
           destination = InsurerListBottomScreenDestination::class, // 👈 this is what I got from logs, it should be here
           resultType = ??WHAT IS THIS??, // 👈  I need to know what is this
           isResultNullable = ????
       )
    ],
    topLevelGraphs = [
        ????
    ]
)
object _ModuleRegistry_<something>

where <something> will be like a UUID looking string, and "????" I don't know what it is, and it's irrelevant, but the ??WHAT IS THIS?? is what I really need to know 😄

Thank you!

@nazarabd3005
Copy link
Author

hi @raamcosta
here the class

package _generated._ramcosta._composedestinations._moduleregistry

import com.ramcosta.composedestinations.spec.DestinationSpec
import id.kesia.domain.patient.type.DebiturTypeEvent
import id.kesia.feature.shared.destinations.DoctorSchedulePoliListScreenDestination
import id.kesia.feature.shared.destinations.FilterDoctorBottomScreenDestination
import id.kesia.feature.shared.destinations.ForgotMrScreenDestination
import id.kesia.feature.shared.destinations.InsurerListBottomScreenDestination
import id.kesia.feature.shared.destinations.MrValidationScreenDestination
import id.kesia.feature.shared.filter_doctor.FilterDoctorNavArgs
import kotlin.reflect.KClass

annotation class _Info_db73aee8_6d9a_4d73_b610_de27d9ba1f34(
    val moduleName: String,
    val packageName: String,
    val typeResults: Array<_Destination_Result_Info_db73aee8_6d9a_4d73_b610_de27d9ba1f34> = emptyArray(),
    val topLevelGraphs: Array<String> = emptyArray()
)

annotation class _Destination_Result_Info_db73aee8_6d9a_4d73_b610_de27d9ba1f34(
    val destination: KClass<out DestinationSpec>,
    val resultType: KClass<*>,
    val isResultNullable: Boolean
)

@_Info_db73aee8_6d9a_4d73_b610_de27d9ba1f34(
    moduleName = "",
    packageName = "id.kesia.feature.shared",
    typeResults = [
       _Destination_Result_Info_db73aee8_6d9a_4d73_b610_de27d9ba1f34(
           destination = FilterDoctorBottomScreenDestination::class,
           resultType = FilterDoctorNavArgs::class,
           isResultNullable = false
       ),
       _Destination_Result_Info_db73aee8_6d9a_4d73_b610_de27d9ba1f34(
           destination = DoctorSchedulePoliListScreenDestination::class,
           resultType = FilterDoctorNavArgs::class,
           isResultNullable = false
       ),
       _Destination_Result_Info_db73aee8_6d9a_4d73_b610_de27d9ba1f34(
           destination = ForgotMrScreenDestination::class,
           resultType = String::class,
           isResultNullable = false
       ),
       _Destination_Result_Info_db73aee8_6d9a_4d73_b610_de27d9ba1f34(
           destination = InsurerListBottomScreenDestination::class,
           resultType = DebiturTypeEvent::class,
           isResultNullable = false
       ),
       _Destination_Result_Info_db73aee8_6d9a_4d73_b610_de27d9ba1f34(
           destination = MrValidationScreenDestination::class,
           resultType = Boolean::class,
           isResultNullable = false
       )
    ],
    topLevelGraphs = [

    ]
)
object _ModuleRegistry_db73aee8_6d9a_4d73_b610_de27d9ba1f34

@raamcosta
Copy link
Owner

Is there something specific to "DebiturTypeEvent"? Is it a class maybe from another module or something like that?

@raamcosta
Copy link
Owner

Does the module that uses this module have access to it?

I believe I may know the reason and how to fix it, but I'm curious.

@nazarabd3005
Copy link
Author

Yes, the DebiturTypeEvent is in another module
and Yes the main app module doesn't have access to it
this is the module tree branch
appmodule -> featureModule -> domainModule (DebiturTypeEvent is here)

@raamcosta
Copy link
Owner

Ok thank you so much for helping me debug this.

I am already working on a fix. Should be up in like an hour or so!

@raamcosta raamcosta added bug Something isn't working v2.0 Improvement changes under consideration for v2.0 labels Mar 12, 2024
@nazarabd3005
Copy link
Author

No worries 👍

@raamcosta
Copy link
Owner

For what it's worth, this means that this Destination InsurerListBottomScreenDestination can probably be internal. Given that you cannot really navigate to it from the app module (or at least you cannot wait for its result)

@nazarabd3005
Copy link
Author

Maybe need to move DebiturTypeEvent to feature module so app module can access the class

@raamcosta
Copy link
Owner

If you want your app module to be able to call this destination and get result from it, something like that is needed.

That said, the library shouldn't fail just because you have a public modal destination that you're not using on a client module. Luckily, it's an easy fix :)

@raamcosta
Copy link
Owner

Once 2.0.0-alpha06 is up, I'll post it here and then please test it and let me know that it works! Thank you once again 🙏

@raamcosta
Copy link
Owner

It's up! Let me know it works now :)

@nazarabd3005
Copy link
Author

"Hey,
The bug's fixed, but now the app module isn't generating navgraphs. Any ideas on how to fix this?"
this is the annotation class graphs in app module

@NavGraph<RootGraph>
annotation class MainGraphs {

    @ExternalNavGraph<HomeGraphsNavGraph>(start = true)
    @ExternalNavGraph<AuthGraphsNavGraph>
    @ExternalNavGraph<ProfileGraphsNavGraph>
    @ExternalNavGraph<OnlineBookingGraphsNavGraph>
    @ExternalNavGraph<TelemedicineGraphsNavGraph>
    @ExternalNavGraph<PharmacyOnlineGraphsNavGraph>
    @ExternalNavGraph<DoctorScheduleGraphsNavGraph>
    @ExternalNavGraph<OrderGraphsNavGraph>
    companion object Includes
}

@raamcosta
Copy link
Owner

raamcosta commented Mar 13, 2024

Hi @nazarabd3005

Do you see ksp task running for this module?
Can you try having a Composable annotated with Destination<MainGraphs>?

@raamcosta
Copy link
Owner

Seems I’m able to reproduce this. Sorry I’m on it, I’ll let you know 🙏

thank you again

@raamcosta
Copy link
Owner

In the mean time add this code and it should work

@Destination<MainGraphs>
@Composable
fun Asd() {}

one thing though: is this graph “main” the one you want to pass to DestinationsNavHosf? Or does root contain anything else?

if it is the one to pass to the NavHost, then it needs to be annotated with @NavHostGraph. Instead of NavGraph<RootGraph>

@raamcosta
Copy link
Owner

(Found the issue! It was a missing commit on 2.0.0 version.. 2.1.0 has a commit that fixes fixes this but I forgot to include it on this branch 😅. I’ll make a new version!)

@raamcosta
Copy link
Owner

2.0.0-alpha07 is up for a while now.

Let me know if things look good now!

@nazarabd3005
Copy link
Author

Hi @raamcosta
the latest update is now able to generate and app running well 💯

@raamcosta
Copy link
Owner

That’s great news! Thank you 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2.0 Improvement changes under consideration for v2.0
Projects
None yet
Development

No branches or pull requests

2 participants