I'm trying to create a HashMap that aggregates a b...
# announcements
l
I'm trying to create a HashMap that aggregates a bunch of objects, and these objects use the init blocks to register themselves by adding themselves into the HashMap. Unfortunately, it appears to me that Kotlin is thinking that since I never access the objects directly (by name) that they should never initialize, which leaves my HashMap empty
g
care to post some code? maybe make a [gist](https://gist.github.com/) or code snippit?
l
sure, give me a sec
@Serializes(Sign::class) internal object SignSerializer : BlockStateSerializer() { init { val annotation = javaClass.getAnnotation(Serializes::class.java) ?: throw IllegalStateException("Child class ${javaClass.simpleName} not annotated with @Serializes!") val blockSerializer = this as? InPlaceSerializer<BlockState> ?: throw IllegalStateException("Child class ${javaClass.simpleName} serializes non-block type.") serializersByType.put(annotation.type, blockSerializer) }
can't seem to create Snippet... that functionality does not appear to be exposed in Slack in comment replies =/