https://kotlinlang.org logo
#feed
Title
# feed
a

antonis

01/17/2020, 7:54 AM
A Java record is a Kotlin data class? Right? https://blogs.oracle.com/javamagazine/records-come-to-java
a

altavir

01/17/2020, 8:10 AM
Not exactly, but they are close
As far as I remember, records are partially done on VM level
👍 2
t

tseisel

01/17/2020, 8:27 AM
From what I read from the docs,
data class
and Java records have the same goal, but differ on the implementation : - Records share a base class
java.lang.Record
-
toString
,
hashCode
... have a JVM intrinsic with
invokeDynamic
, resulting in smaller and more efficient bytecode (data classes may benefit from that in the future) - Data classes are fully generated at compile time and are platform-agnostic
👍 6
b

bezrukov

01/17/2020, 8:42 AM
Jake Wharton explains it a lot on kotlinconf -

https://youtu.be/te3OU9fxC8U?t=1100

👍 8
a

antonis

01/17/2020, 8:50 AM
Thank you all for your feedback
e

Eduardo Pinto

01/17/2020, 11:07 AM
Is not a problem to kotlin at all, but a problem to lombok 🙂
m

Mike

01/17/2020, 11:48 AM
If it gets added, I''m sure the maintainer of Lombok will be happy. One less feature to have to support/develop/maintain. But I've rarely had to deal with Lombok, and never chose to use it.
👍 2
a

altavir

01/17/2020, 11:49 AM
Lombok is made for old Java versions. Records are only preview in JDK14 and adoption rate will be minuscule for a long time still.
n

nkiesel

01/17/2020, 10:52 PM
Another difference to Kotlin data classes is that fields of Java records are always
val
(i.e. no setters)
n

natpryce

01/18/2020, 9:19 AM
Java records don’t seem to have the convenient copy method that Kotlin data classes have.
2 Views