Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializable anonymous classes. #527

Closed
scabug opened this issue Feb 21, 2008 · 4 comments
Closed

Serializable anonymous classes. #527

scabug opened this issue Feb 21, 2008 · 4 comments

Comments

@scabug
Copy link

scabug commented Feb 21, 2008

How do I create a serializable anonymous class? [[BR]]
The following code:

def fingerprint () = new @serializable java.io.Serializable {val nodeId = bannerNodeId}

produces a warning and still throws an

java.io.NotSerializableException: ...$$$$anon$$11

at runtime.

It would be best if Scala compiler would've understood the java.io.Serializable signature and respected it...

That might also mean making pointers to the parent environment transient!

@scabug
Copy link
Author

scabug commented Feb 21, 2008

Imported From: https://issues.scala-lang.org/browse/SI-527?orig=1
Reporter: ArtemGr (artemgr)

@scabug
Copy link
Author

scabug commented Feb 22, 2008

@dragos said:
It is enough to extend java.io.Serializable, no need for the annotation in that case.

Your error might be because the enclosing class it not Serializable? Can you provide the complete source code for your tests?

I don't think it makes sense to make outer pointers transient, since there is no way to set them afterwards. Your only option is to have the outer class serializable, or use a custom serialization protocol (which is in most cases the best idea by far).

@scabug
Copy link
Author

scabug commented Mar 31, 2008

@ingoem said:
No answer in one month, so closing it for now. Please reopen the ticket with a self-contained example if you still have the problem.

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone 2.7.1 deleted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant