Skip to content

[KT-84822] add directive and skipper for tests whenever Java depends on Kotlin#5890

Draft
zardilior wants to merge 4 commits intomasterfrom
zardilior/jklib-java-depends-on-kotlin-directive
Draft

[KT-84822] add directive and skipper for tests whenever Java depends on Kotlin#5890
zardilior wants to merge 4 commits intomasterfrom
zardilior/jklib-java-depends-on-kotlin-directive

Conversation

@zardilior
Copy link
Copy Markdown
Collaborator

@zardilior zardilior commented Apr 18, 2026

Problem

Currently we target all
TARGET_BACKEND: JVM tests for jklib

Some of these are fully incompatible,
Jklib uses dependency jars of java source for compiling kotlin source and cannot have kotlin depending on java.

Currently we use
IGNORE_BACKEND: JKLIB
for almost all tests from JVM that fail

This is not quite correct when using gradle
as these don't show in the skipped count
and these are executed in the background checking if they can be unmuted

Solution

Adding a directive
// JAVA_DEPENDS_ON_KOTLIN
documents the reason they are being skipped
and allows the JKLIB test suite to ignore these without adding
TARGET_BACKEND: JKLIB to all old and new JVM tests

Unrelated changes

Removing

# IGNORE_BACKEND: JKLIB

in tests with

# IGNORE_BACKEND: ANY

@kotlin-safe-merge
Copy link
Copy Markdown

kotlin-safe-merge Bot commented Apr 18, 2026

Code Owners

Rule Owners Approval
/​compiler/​jklib.​tests/​ @gkdn, @jDramaix, @kevinoconnor7, @zardilior
@jDramaix
/​compiler/​testData/​ir/​irText/​ kotlin-compiler
UNASSIGNED

… depends on java

Restore unchanged tests, remove ignore backend on test that has java depends on
@zardilior zardilior force-pushed the zardilior/jklib-java-depends-on-kotlin-directive branch from 7438e38 to 9542ad8 Compare April 18, 2026 02:32
… depends on java

Add missing tests where java depends on kotlin
@zardilior zardilior marked this pull request as ready for review April 18, 2026 04:17
@zardilior zardilior changed the title [JKLIB][TEST] add directive and skipper for tests where Java depends on Kotlin [KT-84822] add directive and skipper for tests where Java depends on Kotlin Apr 18, 2026
@zardilior zardilior changed the title [KT-84822] add directive and skipper for tests where Java depends on Kotlin [KT-84822] add directive and skipper for tests whenever Java depends on Kotlin Apr 18, 2026
@zardilior
Copy link
Copy Markdown
Collaborator Author

Keeping it as a draft to prioritize jetbrains reviewing of #5892

@zardilior zardilior marked this pull request as draft April 18, 2026 20:53
@zardilior zardilior requested review from jDramaix and removed request for demiurg906 and jDramaix April 18, 2026 20:53
@jDramaix
Copy link
Copy Markdown
Collaborator

Not sure about the added value of an extra directive here. You are just replacing a directive by another one.
In my understanding, the directive IGNORE_BACKEND has been created for that purpose.

That being said, what is the purpose to have Java code depending on Kotlin for ixText test ? That does not change the produced IR right ?

@zardilior
Copy link
Copy Markdown
Collaborator Author

zardilior commented Apr 20, 2026

@jDramaix
I added this so I could filter them out, while categorizing them

With the IGNORE directive.
The tests are still run in the background,
this is the way the error "you can unmute this test as it passes now" happens.

I only need a way to filter them out,
if we have no problem with these running in the background rather than being skipped,
I can keep the IGNORE_BACKEND directive and add a simple comment to filter them out from the tests we still have to unmute.

@zardilior
Copy link
Copy Markdown
Collaborator Author

@jDramaix I added this so I could filter them out, while categorizing them

With the IGNORE directive. The tests are still run in the background, this is the way the error "you can unmute this test as it passes now" happens.

I only need a way to filter them out, if we have no problem with these running in the background rather than being skipped, I can keep the IGNORE_BACKEND directive and add a simple comment to filter them out from the tests we still have to unmute.

Not yet ready for review, just want your input on this decision @demiurg906
Wdyt?
Extra directive vs IGNORE + comment, but no true skip
Are you the right person to ask this to?

@jDramaix
Copy link
Copy Markdown
Collaborator

Based on my understanding, JKlibIrTextTest is designed to verify the generated Kotlin IR against 'golden' files. Since Java code depending on Kotlin shouldn't alter the generated Kotlin IR, these tests should conceptually pass regardless of the Java compilation state. What is the specific cause of the failures when running these tests in the jklib environment?

@zardilior
Copy link
Copy Markdown
Collaborator Author

Based on my understanding, JKlibIrTextTest is designed to verify the generated Kotlin IR against 'golden' files. Since Java code depending on Kotlin shouldn't alter the generated Kotlin IR, these tests should conceptually pass regardless of the Java compilation state. What is the specific cause of the failures when running these tests in the jklib environment?

Yes, but in our current setup, before running any tests

We compile the java code separately with javac, to pass it as a dependency. Without any kotlin on it this compilation fails.

We could silently fail it and not include the java dependencies and see if the compilation delivers IR results.

That would require changes to the current setup which we can do if we see value in that.

@jDramaix
Copy link
Copy Markdown
Collaborator

What does Kotlin/JVM do ? How do they decide if Java compilation result needs to be a dependency or Kotlin code needs to be a dependency ?

@demiurg906
Copy link
Copy Markdown
Contributor

There is a DONT_TARGET_EXACT_BACKEND directive, which works like TARGET_BACKEND in reverse: // DONT_TARGET_EXACT_BACKEND: JKLIB means that the test for JKLIB won't be executed at all.
I think this is exactly what you want.

What does Kotlin/JVM do ? How do they decide if Java compilation result needs to be a dependency or Kotlin code needs to be a dependency ?

It's decided based on which module the java file belongs. In the same module kotlin code is always getting compiled first, so inside one module we analyze java sources as sources. If java files are declared in the dependency module, then the compiler consumes the compiled .class files of them (and kotlin sources from that module are passed as binary dependencies too).

@zardilior
Copy link
Copy Markdown
Collaborator Author

That definetely works @demiurg906 thanks!

… depends on java

Change custom JAVA_DEPENDS_ON_KOTLIN for standard SKIP directive
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