BaseDateTime volatile fields

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

BaseDateTime volatile fields

Brian S O'Neill
In Joda-time 2.0, changes were made to make the code compliant with the
Java 5 memory model, but without breaking compatibility. The solution
was to define several fields as volatile, because declaring them as
final would break subclasses or serialization.

Making the BaseDateTime fields volatile has a measurable performance
impact, nullifying (or worse) many of the performance gains Joda-time
has over the JDK date classes. It's possible to make these fields final
while still preserving serialization compatibility. The trick is to use
special object stream features.

For this to work, the field definitions need to be moved to all the
subclasses, and the get/setMillis need to be abstract. The object stream
stuff also needs to move to the subclasses.

There's one little issue: These changes break compatibility for anyone
that is extending BaseDateTime. Although this is an implementation
package, and so no one _should_ be extending it, is anyone out there
actually doing this?

------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: BaseDateTime volatile fields

jodastephen
If we are going to make this change it will have to be v3.0. And we
should release a v2.2 first.
Stephen


On 4 January 2013 16:32, Brian S O'Neill <[hidden email]> wrote:

> In Joda-time 2.0, changes were made to make the code compliant with the
> Java 5 memory model, but without breaking compatibility. The solution
> was to define several fields as volatile, because declaring them as
> final would break subclasses or serialization.
>
> Making the BaseDateTime fields volatile has a measurable performance
> impact, nullifying (or worse) many of the performance gains Joda-time
> has over the JDK date classes. It's possible to make these fields final
> while still preserving serialization compatibility. The trick is to use
> special object stream features.
>
> For this to work, the field definitions need to be moved to all the
> subclasses, and the get/setMillis need to be abstract. The object stream
> stuff also needs to move to the subclasses.
>
> There's one little issue: These changes break compatibility for anyone
> that is extending BaseDateTime. Although this is an implementation
> package, and so no one _should_ be extending it, is anyone out there
> actually doing this?
>
> ------------------------------------------------------------------------------
> Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
> much more. Get web development skills now with LearnDevNow -
> 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
> SALE $99.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122812
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest

------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...