I am having a issue with java interop and Kotlin I have a package protected java abstract class ,AbstractTest, which is used as a member in another class,TestHolder. When I create a derived instance of the abstract class ,Test, and try to use it in kotlin I get:
java.lang.IllegalAccessError: tried to access class test.AbtractTest from class KotlinTest
The Java version of the same code seems to work fine though …
package test;
abstract class AbtractTest {
}
package test;
public class Test extends AbtractTest {
}
package test;
public class TestHolder {
private AbtractTest test;
public AbtractTest getTest() {
return test;
}
public void setTest(AbtractTest test) {
this.test = test;
}
}
public class JavaTest {
private TestHolder testHolder;
public JavaTest() {
testHolder = new TestHolder();
testHolder.setTest(new Test());
}
}
fun main(args: Array<String>) {
JavaTest()
KotlinTest()
}
class KotlinTest {
val testHolder: TestHolder
init {
testHolder = TestHolder()
testHolder.test= Test()
}
}