is there any way to freeze a java object? i have a...
# announcements
t
is there any way to freeze a java object? i have a framework which exposes a class like this
Copy code
class Person {
    public int age;
    public String name;
}
and i want to turn it into a
data class(val age: Int, val name: String)
. i know i could write something to convert it, but is there something built-in that can just freeze the object instead?
a
What do you mean by Freeze?
t
basically add a final modifier at runtime
👍 1
d
I don't think JVM supports that.
t
that's too bad, guess i'll have to write a bunch of converters
thanks
g
depends on case of course, there are different options, like use reflections and proxy classes, serialize data to "freeze"