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

Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8 #579

Open
sheu opened this issue Dec 5, 2022 · 3 comments

Comments

@sheu
Copy link

sheu commented Dec 5, 2022

I cloned this project and added my own kotlin library that is compiled with java 11 as the target. I however cannot run code that requires fold operation based on the result of library operations. The server returns this error: "Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option"

What JVM target is used to the the code passed my /run endpoint?. How can I specify the jvm target for run calls?

@AlexanderPrendota
Copy link
Collaborator

AlexanderPrendota commented Dec 5, 2022

I think it's a duplicate. #576.

Please rebase on master.

I hope it helps

@sheu
Copy link
Author

sheu commented Dec 6, 2022

I rebased and I still come across this issue. I also updated the source compatibility but I still get the same error.
Also looking at #576 I cannot figure out what upgrade was done to resolve the issue.

My understanding is that when a call to /run is made, the compiler server will compile and run the code. I think this is where the issue is because the default target is 1.8 if not specified.

I tried making this change in component/KotlinEnvironment.kt:

private val additionalCompilerArguments: List<String> = listOf(
      "-opt-in=kotlin.ExperimentalStdlibApi",
      "-opt-in=kotlin.time.ExperimentalTime",
      "-opt-in=kotlin.RequiresOptIn",
      "-opt-in=kotlin.ExperimentalUnsignedTypes",
      "-opt-in=kotlin.contracts.ExperimentalContracts",
      "-opt-in=kotlin.experimental.ExperimentalTypeInference",
      "-jvm-target 11",
      "-Xcontext-receivers",
      "-XXLanguage:+RangeUntilOperator"
    )

adding "-jvm-target 11",
This did not help either. What am I missing ?

@sheu
Copy link
Author

sheu commented Jan 9, 2023

After some debugging, I found out that the compiler configurations that is built in component/KotlinEnvironment.kt does not not include the jvm target and setting this in the additionalCompilerArguments does not help either.

The quick fix for me was to add the lines
put(JVMConfigurationKeys.JVM_TARGET, JvmTarget.JVM_11) in the method createConfiguration()

Refer to #594

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