What is the difference between scala @Serializable and Java Serializable?
Asked Answered
U

2

9

the manner of action of scala @Serializable is different from Java Serializable?

I mean the way to serialize objects or both use the same standard serialization?

Unbar answered 22/6, 2011 at 17:47 Comment(1)
In Scala 2.9 @Serializable is deprecated and you should implement Serializable as you do in JavaSocket
A
5

Well Scala compiles to JVM byte code, so the only difference comes from how Scala implements this conversion. Scala converts the annotation to the interface during type checking which can lead to some subtle problems see here.

Afaik @Serializable is deprecated anyhow - compared to other annotations (volatile annotation instead of a specifier) in scala I don't see much advantages anyhow.. doesn't make the code much clearer or simpler.

Aston answered 22/6, 2011 at 18:4 Comment(3)
Scala doesn't compile to Java code. It compiles to JVM bytecode, as does Java.Plectron
@Don Yeah I should've said java bytecode as that's the final result. But since as I understand it scala uses the java compiler the statement is technically true (if only in an intermediate step) ;)Aston
Ah thought they used the java compiler, interesting that they don't. Wouldn't a source to source transformation be less work and simpler (ie getting all advancements of the java compiler for free). In that case yep sloppy.Aston
B
0

Serializable is just a marker interface. You don't need to implement any methods. An annotation is supposed to be a cleaner solution. But the meaning is the same.

Barbellate answered 22/6, 2011 at 18:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.