I have two java classes:
package me.goto1134;
abstract class ATest<M extends ATest<M>> {
public M test(final M t) {
return t;
}
@Override
public String toString() {
return "Test";
}
}
and
package me.goto1134;
public class Test extends ATest<Test> {
}
if I run a kotlin test
import me.goto1134.Test
fun main() {
val test1 = Test()
val test2 = Test()
print(test1.test(test2))
}
I get
Exception in thread “main” java.lang.IllegalAccessError: tried to access class me.goto1134.ATest from class TestKt
at TestKt.main(test.kt:6)
at TestKt.main(test.kt)
but running Java test
import me.goto1134.Test;
public class AbstractClassGenericMethodTest {
public static void main(String[] args) {
Test test1 = new Test();
Test test2 = new Test();
System.out.println(test1.test(test2));
}
}
will lead to a valid output.
How can I work aroung the problem?
P.S. I found the problem using ojalgo library that is used for Linear Algebra in my case.
There is also a relevant(?) issue https://youtrack.jetbrains.com/issue/KT-11700, but there is no progress on solving it.