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

Kotlin 2.0.21 - java.lang.NullPointerException during compilation #53

Closed
lupuuss opened this issue Oct 19, 2024 · 6 comments
Closed

Kotlin 2.0.21 - java.lang.NullPointerException during compilation #53

lupuuss opened this issue Oct 19, 2024 · 6 comments

Comments

@lupuuss
Copy link
Owner

lupuuss commented Oct 19, 2024

When attempting to update our project from 2.0.20 to 2.0.21, I see tests failing to run due to

e: java.lang.NullPointerException
	at dev.mokkery.plugin.ir.IrClassKt.addOverridingProperty(IrClass.***:128)
	at dev.mokkery.plugin.ir.IrClassKt.addOverridingProperty(IrClass.***:111)
	at dev.mokkery.plugin.ir.IrClassKt.overrideAllOverridableProperties(IrClass.***:102)
	at dev.mokkery.plugin.transformers.BuildMockClassKt.buildMockClass(BuildMockClass.***:99)
	at dev.mokkery.plugin.transformers.MokkeryTransformer.replaceWithMock$lambda$1(MokkeryTransformer.***:95)
	at dev.mokkery.plugin.core.HashMapCache.getOrPut(Cache.***:22)
	at dev.mokkery.plugin.transformers.MokkeryTransformer.replaceWithMock(MokkeryTransformer.***:95)
	at dev.mokkery.plugin.transformers.MokkeryTransformer.visitCall(MokkeryTransformer.***:67)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.***:299)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.***:19)
	at org.jetbrains.kotlin.ir.expressions.IrCall.accept(IrCall.***:24)
	at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.***:24)
	at org.jetbrains.kotlin.ir.expressions.IrExpressionBody.transformChildren(IrExpressionBody.***:31)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBody(IrElementTransformerVoid.***:174)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpressionBody(IrElementTransformerVoid.***:182)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpressionBody(IrElementTransformerVoid.***:185)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpressionBody(IrElementTransformerVoid.***:19)
	at org.jetbrains.kotlin.ir.expressions.IrExpressionBody.accept(IrExpressionBody.***:21)
	at org.jetbrains.kotlin.ir.expressions.IrExpressionBody.transform(IrExpressionBody.***:24)
	at org.jetbrains.kotlin.ir.declarations.IrField.transformChildren(IrField.***:47)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.***:40)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitField(IrElementTransformerVoid.***:96)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitField(IrElementTransformerVoid.***:99)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitField(IrElementTransformerVoid.***:19)
	at org.jetbrains.kotlin.ir.declarations.IrField.accept(IrField.***:40)
	at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.***:33)
	at org.jetbrains.kotlin.ir.declarations.IrProperty.transformChildren(IrProperty.***:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.***:40)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitProperty(IrElementTransformerVoid.***:116)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitProperty(IrElementTransformerVoid.***:119)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitProperty(IrElementTransformerVoid.***:19)
	at org.jetbrains.kotlin.ir.declarations.IrProperty.accept(IrProperty.***:45)
	at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.***:33)
	at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.***:35)
	at org.jetbrains.kotlin.ir.declarations.IrClass.transformChildren(IrClass.***:82)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.***:40)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.***:54)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.***:57)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.***:19)
	at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.***:72)
	at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.***:33)
	at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.***:35)
	at org.jetbrains.kotlin.ir.declarations.IrFile.transformChildren(IrFile.***:38)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitPackageFragment(IrElementTransformerVoid.***:146)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.***:160)
	at dev.mokkery.plugin.core.CoreTransformer.visitFile(CoreTransformer.***:21)
	at dev.mokkery.plugin.transformers.MokkeryTransformer.visitFile(MokkeryTransformer.***:82)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.***:163)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.***:19)
	at org.jetbrains.kotlin.ir.declarations.IrFile.accept(IrFile.***:28)
	at org.jetbrains.kotlin.ir.declarations.IrFile.transform(IrFile.***:31)
	at org.jetbrains.kotlin.ir.declarations.IrFile.transform(IrFile.***:20)
	at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.***:35)
	at org.jetbrains.kotlin.ir.declarations.IrModuleFragment.transformChildren(IrModuleFragment.***:43)
	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitModuleFragment(IrElementTransformerVoid.***:108)
	at dev.mokkery.plugin.transformers.MokkeryTransformer.visitModuleFragment(MokkeryTransformer.***:87)
	at dev.mokkery.plugin.MokkeryIrGenerationExtension.generate(MokkeryIrGenerationExtension.***:16)
	at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.applyIrGenerationExtensions(convertToIr.***:442)
	at org.jetbrains.kotlin.fir.pipeline.Fir2IrPipeline.runActualizationPipeline(convertToIr.***:246)
	at org.jetbrains.kotlin.fir.pipeline.Fir2IrPipeline.convertToIrAndActualize(convertToIr.***:130)
	at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.convertToIrAndActualize(convertToIr.***:99)
	at org.jetbrains.kotlin.fir.pipeline.ConvertToIrKt.convertToIrAndActualize$default(convertToIr.***:72)
	at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.convertToIrAndActualizeForJvm(jvmCompilerPipeline.***:196)
	at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.convertAnalyzedFirToIr(jvmCompilerPipeline.***:169)
	at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.compileModulesUsingFrontendIrAndLightTree(jvmCompilerPipeline.***:140)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.***:148)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.***:43)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.***:103)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.***:49)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.***:101)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.***:464)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.***:73)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.***:506)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.***:423)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.***:301)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.***:129)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.***:675)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.***:92)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.***:1660)
	at jdk.internal.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

Originally posted by @zkovar in #48 (comment)

@lupuuss
Copy link
Owner Author

lupuuss commented Oct 19, 2024

@zkovar are you sure it happened while migrating from 2.0.20 to 2.0.21? From stack trace, it does not seem as a regular broken compatibility. It could be some behavioral change on the kotlin compiler side, but it is not very likely in a patch release. Anyway, could you:

  • Try clean build to exclude some IC/cache issues
  • Reproduce it in a separate project

I would be grateful for a minimal reproducer or maybe you will be able to figure out what causes the issue. To give you some hint: from the stack trace it seems that type you want to mock have a property without a getter. It should not be really possible, but maybe you have something unusual in you property definition.

@zkovar
Copy link

zkovar commented Oct 19, 2024

@lupuuss yes, can confirm we're seeing this when the only change in our project is attempting to bump the Kotlin version from 2.0.20 to 2.0.21 (mainly for Xcode 16 support). I'll debug further and try to create a small reproducing project within a few days. Thanks!

@lupuuss
Copy link
Owner Author

lupuuss commented Oct 29, 2024

@zkovar do you have any update?

@zkovar
Copy link

zkovar commented Oct 30, 2024

@lupuuss not yet - getting back to this today. I'm currently trying to debug if we have any bad tests configured that could be causing this

@zkovar
Copy link

zkovar commented Oct 30, 2024

Well well - your hunch was right 😄 . We had one bad test file that, for some reason, when updating from 2.0.20 to 2.0.21, led to this exception. Everything else works, so I think we can close this issue and debug the test on our end. Thanks!

I'll report back when I figure out why that test failed

@lupuuss
Copy link
Owner Author

lupuuss commented Oct 30, 2024

Ok fine. I will add null check before accessing getter just in case. I'm not sure how effective it will be, because getter should not be null and it might be a symptom of something else. I'm closing the issue until you find something. Thank you for reporting this!

@lupuuss lupuuss closed this as completed Oct 30, 2024
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

2 participants