Skip to content

[KT-84822] added java annotations libraries for tests that use them#5895

Open
zardilior wants to merge 1 commit intomasterfrom
zardilior/fix-jklib-tests-annotations-for-java-files
Open

[KT-84822] added java annotations libraries for tests that use them#5895
zardilior wants to merge 1 commit intomasterfrom
zardilior/fix-jklib-tests-annotations-for-java-files

Conversation

@zardilior
Copy link
Copy Markdown
Collaborator

@zardilior zardilior commented Apr 18, 2026

Tests with java sources that used
with org.jetbrains.annotations or @null @NotNull would crash with IllegalState.

Adding these dependencies fixes the issue

@zardilior zardilior changed the title [JKLIB][TEST] added annotations libraries to compile java srcs [KT-84822] added annotations libraries to compile java srcs Apr 18, 2026
@zardilior zardilior force-pushed the zardilior/fix-jklib-tests-annotations-for-java-files branch from ce92638 to d60cce1 Compare April 29, 2026 01:07
@zardilior zardilior changed the title [KT-84822] added annotations libraries to compile java srcs [KT-84822] added java annotations libraries for tests that use them Apr 29, 2026
@zardilior zardilior force-pushed the zardilior/fix-jklib-tests-annotations-for-java-files branch from d60cce1 to 4e0866f Compare April 29, 2026 03:07
@zardilior zardilior marked this pull request as ready for review April 29, 2026 03:17
javaFiles.forEach { testServices.sourceFileProvider.getOrCreateRealFileForSourceFile(it) }

val javaDir = testServices.sourceFileProvider.getJavaSourceDirectoryForModule(module)
val java8AnnotationsDir = File(JavaForeignAnnotationType.Java8Annotations.path)
Copy link
Copy Markdown
Collaborator Author

@zardilior zardilior Apr 29, 2026

Choose a reason for hiding this comment

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

Contains @NotNull and @nullable annotations
from org.jetbrains.annotations.* as well as JSR-305 annotations
like javax.annotation.Nonnull
javax.annotation.Nullable

and has to be compiled before use.
This is also done for jvm tests through
JvmForeignAnnotationsConfigurator.kt

@zardilior zardilior force-pushed the zardilior/fix-jklib-tests-annotations-for-java-files branch from 4e0866f to 8687206 Compare April 29, 2026 03:28
@zardilior zardilior requested review from demiurg906, jDramaix and sellmair and removed request for demiurg906 April 29, 2026 03:28
@zardilior zardilior force-pushed the zardilior/fix-jklib-tests-annotations-for-java-files branch from 8687206 to 0b77511 Compare April 29, 2026 03:32

val javaDir = testServices.sourceFileProvider.getJavaSourceDirectoryForModule(module)
val java8AnnotationsDir = File(JavaForeignAnnotationType.Java8Annotations.path)
val java8AnnotationsJar = MockLibraryUtil.compileJavaFilesLibraryToJar(
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.

Same as in JvmForeignAnnotationsConfigurator, please execute this code only if there is a ENABLE_FOREIGN_ANNOTATIONS directive enabled.
Otherwise you'll invoke the javac for each test, which would significantly slow tests down.

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.

2 participants