# getting-started

Nathan Schwermann

09/21/2021, 6:38 PM
I want to bring kotlin support to a java library without adding kotlin to it. What I want is to make a sealed class. Is there any kind of meta data or naming conventions I can use to make my classes work as a sealed class when consumed by kotlin?
nope 1


09/21/2021, 7:10 PM
sealed classes
are a Kotlin feature, so you can't at the moment. I think Kotlin might soon support the new "permitted subsclasses" JVM feature that was added in Java 15: But at the moment I don't believe it's possible to do what you want

Nathan Schwermann

09/21/2021, 7:13 PM
How does the compiler know though after the kotlin class is converted to bytecode?? There has got to be some kind of metadata or naming convention. When I reverse compile a sealed class I see the java structure needed. But the metadata is byte strings not sure how they are generated, and there may be a naming convention as well.


09/21/2021, 8:16 PM
Kotlin serializes extra info that cannot be expressed in bytecode to both the
annotation as well as a
💯 1
the kotlinx.metadata.jvm library can read and write those, but it's definitely not intended to be a public interface
👍 1
in practice the metadata is partly a shared constant pool and partly a serialized protobuf
it's not something you can write by hand and add to a Java class

Nathan Schwermann

09/21/2021, 8:21 PM
Interesting… I think I follow your github profile, your looks familiar. I think you had some great advent of code solutions 🙂
🙏 1