David M. Lloyd
david.lloyd at redhat.com
Mon Oct 8 10:10:48 PDT 2012
On 10/08/2012 10:45 AM, Brian Goetz wrote:
>> Well, they don't really solve the problem of making serialization
>> correct; they accept as given that it's OK for anonymous and (worse yet)
>> capturing lambdas to be serialized with the expectation that it'll just
>> be flat-out wrong if you change the source in any way, which is
>> something I absolutely do not concede and which I firmly believe will
>> bite us (where "us"=="Java EE vendors"... and RMI users, and JPA users,
>> and just about any of the hundreds of widely-used serialization-based
>> technologies out there).
> I think the correctness you seek is just inachievable. Even with named
> classes, serialization has all sorts of limits and gotchas.
Sure, but by and large it works. There are few surprises as long as you
stick to named classes.
> With inner
> classes, people have learned that you can use inner classes with
> serialization when you have identical bytecode on both sides of the
> pipe, and can't otherwise.
That's not perfectly accurate; only anonymous (and, I think, local)
classes have this limitation. "Regular" inner classes generally work
fine, even if the source is rearranged, since by and large (from my
experience anyway) everyone uses the same representation for inner class
names and outer class links.
> Its imperfect, but it seems a reasonable bar to say "no worse than inner classes".
> I get that you would like to set a higher bar -- and I'm open to seeing
> what we can do to meet a higher bar. But first we should meet the bar
> we have, and we're stuck there.
I disagree - anonymous classes were an oversight; just because one thing
doesn't work does not give justification to make more problems. It's
more of an excuse. I think we *can* limit serialization to named
references, and this would cause a better user experience; and, as far
as I'm able to figure, this is actually a *lower* bar
implementation-wise, therefore I think *this* should be our default
setting rather than (what appears to be) going out of our way to repeat
mistakes of the past for the sake of consistency.
More information about the lambda-spec-experts