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?

1
  • 3
    In Scala 2.9 @Serializable is deprecated and you should implement Serializable as you do in Java
    – tuxSlayer
    Jun 23, 2011 at 7:39

2 Answers 2

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.

3
  • 6
    Scala doesn't compile to Java code. It compiles to JVM bytecode, as does Java.
    – Don Roby
    Jun 22, 2011 at 22:09
  • @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) ;)
    – Voo
    Jun 23, 2011 at 12:46
  • 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.
    – Voo
    Jun 24, 2011 at 20:46
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.