The Artima Developer Community
Sponsored Link

Java Buzz Forum
That was weird!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mike Melia

Posts: 74
Nickname: tricky
Registered: Feb, 2004

Mike Melia is a ThoughtWorker specialising in Java/J2EE but spreading into .NET (all agile).
That was weird! Posted: Jan 22, 2007 2:27 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Mike Melia.
Original Post: That was weird!
Feed Title: I know the meaning of life, it doesn't help me a bit
Feed URL: http://www.gigantiq.com/blogs/mike/?feed=rss2
Feed Description: Observations on the Java, OSS worlds with an agile perspective. Observation on the .NET world from a learning and agile perspective.
Latest Java Buzz Posts
Latest Java Buzz Posts by Mike Melia
Latest Posts From I know the meaning of life, it doesn't help me a bit

Advertisement

I was trying to construct an object that took a Map as a constructor argument.

e.g.

public Foo(Map bar) { this.bar = bar; }

The client code was instantiating the Foo object like this

Foo foo = new Foo(bar);

and, as a shortcut to populating the Map, I was using an instance initialiser on an anonymous subclass of HashMap

Map bar = new HashMap() {{ put("key", "value"); }};

All was well until I tried to store my Foo object in flow context (I'm using Spring webflow).

Did anyone else know that that anonymous subclasses of previously Serializable classes are no longer Serializable once you add an instance initialiser?

Anonymous subclasses of Serializable classes can be Serializable (but don't serialise across JVMs).

Classes with instance initialisers can be Serializable.

BUT

Anonymous subclasses of Serializable classes will not be Serializable if the subclass definition adds an anonymous instance initialiser.

Read: That was weird!

Topic: links for 2007-01-18 from PeopleOverProcess.com Previous Topic   Next Topic Topic: Programming languges panel at CodeMash

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use