File tree 1 file changed +28
-0
lines changed
core/src/test/kotlin/com/tschuchort/compiletesting
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,34 @@ class KotlinCompilationTests {
363
363
assertClassLoadable(result, " com.tschuchort.compiletesting.JSource" )
364
364
}
365
365
366
+ @Test
367
+ fun `Kotlin can access Java class in different package` () {
368
+ val jSource = SourceFile .java(" JSource.java" , """
369
+ package package1;
370
+ class JSource {
371
+ void foo() {}
372
+ }
373
+ """ )
374
+
375
+ val kSource = SourceFile .kotlin(" KSource.kt" , """
376
+ package package2
377
+ import package1
378
+ class KSource {
379
+ fun bar() {
380
+ JSource().foo()
381
+ }
382
+ }
383
+ """ )
384
+
385
+ val result = defaultCompilerConfig().apply {
386
+ sources = listOf (kSource, jSource)
387
+ }.compile()
388
+
389
+ assertThat(result.exitCode).isEqualTo(ExitCode .OK )
390
+ assertClassLoadable(result, " package2.KSource" )
391
+ assertClassLoadable(result, " package1.JSource" )
392
+ }
393
+
366
394
@Test
367
395
fun `Java can access Kotlin class` () {
368
396
val jSource = SourceFile .java(" JSource.java" , """
You can’t perform that action at this time.
0 commit comments