Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Kotlin app that creates illegal class names failing the test in Class.getSimpleName()
package sample
import javafx.application.Application
import javafx.collections.FXCollections
import javafx.scene.Scene
import javafx.scene.control.ListCell
import javafx.scene.control.ListView
import javafx.stage.Stage
import javafx.util.Callback
class Main : Application() {
override fun start(stage: Stage) {
val root = ListView<String>().apply {
items = FXCollections.observableArrayList("One", "Two", "Three")
cellFormat {
// This line crashes with java.lang.InternalError: Malformed class name
// at java.lang.Class.getSimpleName(
text = item
stage.scene = Scene(root)
companion object {
fun main(args: Array<String>) {
// This is a convenience function that provides a cellfactory to a ListView, taken from the TornadoFX framework
// Changing 'crossinline' to 'noinline' seems to solve the problem
inline fun <T> ListView<T>.cellFormat(crossinline formatter: (ListCell<T>.(T) -> Unit)) {
cellFactory = Callback {
object : ListCell<T>() {
override fun updateItem(item: T, empty: Boolean) {
super.updateItem(item, empty)
if (item == null || empty) {
text = null
graphic = null
} else {
formatter(this, item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.