Skip to content

Instantly share code, notes, and snippets.

@tateisu
Last active October 27, 2021 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tateisu/cbda451135d2b5c9b69f7ac4599f9833 to your computer and use it in GitHub Desktop.
Save tateisu/cbda451135d2b5c9b69f7ac4599f9833 to your computer and use it in GitHub Desktop.
can't invoke `size` on some class that derived from ArrayList
package jp.juggler.subwaytooter
import org.junit.Assert.assertEquals
import org.junit.Test
class TestArrayListSort {
@Test
fun testArrayListSize() {
val list = ArrayList(arrayOf("c", "b", "a").toList())
assertEquals("ArrayList size", 3, list.size);
// passed
}
class ArrayListDerived<E>(args: List<E>) : ArrayList<E>(args)
@Test
fun testArrayListDerived() {
val list = ArrayListDerived(arrayOf("c", "b", "a").toList())
assertEquals("ArrayListDerived size", 3, list.size);
// raise error
}
}
'int jp.juggler.subwaytooter.TestArrayListSort$ArrayListDerived.getSize()'
java.lang.NoSuchMethodError: 'int jp.juggler.subwaytooter.TestArrayListSort$ArrayListDerived.getSize()'
at jp.juggler.subwaytooter.TestArrayListSort$ArrayListDerived.size(TestArrayListSort.kt:14)
at jp.juggler.subwaytooter.TestArrayListSort.testArrayListDerived(TestArrayListSort.kt:19)
(snip...)
ext.kotlin_version = '1.5.31'
java 14 (zulu 14.28.21 win64)
@tateisu
Copy link
Author

tateisu commented Oct 27, 2021

kotlin 1.5.30 では問題なかった。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment