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

[Bug] Kotlin2Cpg fails when kotlin 2.x compiler is present #5020

Open
tajobe opened this issue Oct 22, 2024 · 0 comments
Open

[Bug] Kotlin2Cpg fails when kotlin 2.x compiler is present #5020

tajobe opened this issue Oct 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tajobe
Copy link
Contributor

tajobe commented Oct 22, 2024

The kotlin2cpg frontend uses at least one function from the compiler that is only available on 1.x, meaning it fails for kotlin 2.x

I am invoking the frontend from a kotlin 2.x project which uses kotlin scripting and thus embeds its own kotlin compiler, meaning at runtime it seems to resolve the 2.x compiler rather than the embedded one in the kotlin2cpg frontend.

See:

val isWrapperOfPrimitiveType = JvmPrimitiveType.isWrapperClassName(fqName)

This uses JvmPrimitiveType.isWrapperClassName, which seems to have been renamed in 2.x to JvmPrimitiveType.isWrapperClassInternalName, causing a failure for 2.x kotlin projects.

Partial stacktrace:

java.lang.NoSuchMethodError: 'boolean org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType.isWrapperClassName(org.jetbrains.kotlin.name.FqName)'
	at io.joern.kotlin2cpg.types.TypeRenderer.maybeUnwrappedRender(TypeRenderer.scala:88)
	at io.joern.kotlin2cpg.types.TypeRenderer.renderForDescriptor$$anonfun$1(TypeRenderer.scala:106)

To Reproduce
Steps to reproduce the behavior:

  1. Attempt to invoke the kotlin2cpg frontend with kotlin 2.x compiler on the classpath

Expected behavior
CPG is created successfully

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS 15
  • Joern Version: 4.0.115
  • Java version: 17
@tajobe tajobe added the bug Something isn't working label Oct 22, 2024
@tajobe tajobe changed the title [Bug] Kotlin2Cpg fails for kotlin 2.x [Bug] Kotlin2Cpg fails when kotlin 2.x compiler is present Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant