Skip to content

[KT-84822] Add javac parameters flag to get same ir in jklib tests#5891

Open
zardilior wants to merge 3 commits intomasterfrom
zardilior/add-java-parameters-to-get-same-ir
Open

[KT-84822] Add javac parameters flag to get same ir in jklib tests#5891
zardilior wants to merge 3 commits intomasterfrom
zardilior/add-java-parameters-to-get-same-ir

Conversation

@zardilior
Copy link
Copy Markdown
Collaborator

@zardilior zardilior commented Apr 18, 2026

Problem

Some JKlib tests were failing due to IR data mismatches when depending on Java sources By default, the Java compiler was stripping parameter names, causing discrepancies in the IR produced by the Kotlin compiler.

Solution

Add the -parameters flag to the Java compilation of these sources to preserve parameter names in the class files. This allows the Kotlin compiler to read the names from the JARs and produce the expected IR.

Unrelated change

Making javaBackedTest previously added for jklib testing a jvm test, now it passes with both

…rom dependencies matches jvm IR tests

unmuted tests that now pass
@zardilior zardilior changed the title Add java parameters to get same ir in jklib tests [KT-84822] Add java parameters to get same ir in jklib tests Apr 18, 2026
@zardilior zardilior marked this pull request as ready for review April 18, 2026 05:57
@zardilior zardilior marked this pull request as draft April 18, 2026 20:51
@zardilior zardilior removed the request for review from demiurg906 April 18, 2026 20:51
@jDramaix jDramaix changed the title [KT-84822] Add java parameters to get same ir in jklib tests [KT-84822] Add javac parameters flag to get same ir in jklib tests Apr 20, 2026
…rom dependencies matches jvm IR tests

Added comment to clarify parameter
@zardilior zardilior marked this pull request as ready for review April 23, 2026 03:20
@@ -64,7 +64,8 @@ class JKlibJavaSourceConfigurator(testServices: TestServices) : EnvironmentConfi
"${module.name}-java-binaries",
extraClasspath = jvmClasspathRoots,
assertions = testServices.assertions,
Copy link
Copy Markdown
Collaborator Author

@zardilior zardilior Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change besides test related unmuting and updates are this file and compiler/tests-compiler-utils/testFixtures/org/jetbrains/kotlin/test/MockLibraryUtil.kt at the bottom

@@ -28,9 +28,9 @@ FILE fqName:<root> fileName:/Kotlin1.kt
public open fun hashCode (): kotlin.Int declared in <root>.BaseJava
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of how the change affects IR generation when inheriting from java sources

@zardilior zardilior requested a review from demiurg906 April 28, 2026 20:35
}
add("-encoding")
add("utf8")
addAll(extraOptions)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot use the same extraOptions list for javac and kotlinc at the same time.
Please introduce a new extraJavacOptions and use it instead.

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

Successfully merging this pull request may close these issues.

3 participants