Hi all! Question that has probably been answered b...
# getting-started
h
Hi all! Question that has probably been answered before, but I couldn’t find/understand those answers: Why do we need to annotate “value classes” with @JvmInline? Ie. why is it not implied that a “value class” should be inlined? And what is a “value class” without @JvmInline?
But in short from the KEEP:
The @JvmInline annotation makes it explicit that something special with this class is going on in JVM, and it enables us to support non-annotated value class in the future Valhalla JVM by compiling them using the capabilities of the Project Valhalla.
h
Thank you, I understand now. Wish they would have kept inline classes and have that imply inlining. Those annotations are unsexy. But oh well..
j
The point is that these annotations will go away when there is a "better" implementation (Valhalla) instead of (or on top of) inlining. It's "ugly" right now so it can be beautiful in the long run 🙂
👍 1
h
But I guess inlining doesn’t really make a noticeable performance difference, in day to day business logic code, so I’ll probably just skip those annotations, unless i really need it
j
You can't skip the annotations if you use
value class
at the moment, you have to use them because it's currently the only way `value class`es are supported on JVM (this is to ensure that new implementations without
@JvmInline
will be backwards-compatible)
h
Oh, I see
s
but if you don't care much about the inlining, you can always use a
data class
to create a typesafe wrapper.