Value types - compatibility with existing “value objects”

Brian Goetz brian.goetz at oracle.com
Thu Jan 8 15:48:46 UTC 2015


If we were rewriting Java from scratch, obviously yes.

In practice, we're not sure yet, but we sure would like a story for 
this.  The challenge lies in whether we can come up with a migration 
compatibility strategy that allows existing clients that say "reference" 
to freely interoperate with a class which has been migrated to value 
both with and without recompilation.

The tradeoff is one you've seen illustrated quite recently; much of the 
complexity of the language comes from trying to provide smooth migration 
compatibility like this.  It is of course possible to do; the question 
is whether it is worth the complexity it would impose -- which is TBD.

On 1/8/2015 4:47 AM, Palo Marton wrote:
> Hi. I have a question about value types:
>
> Will it be possible (within valhalla) to rewrite java String as value type
> in JDK and use it in all places in JDK where it makes sense? (eg.
> Class.forName(string), Object.toString(), Integer.parseInt(string). …)
>
> Or more general question:
>
> There are already plenty of “value objects” in existing java code. In JDK
> we have, String, File, Point2D,... Also many people have already declared
> their own class Point { final x,y; } and similar objects. Once we move to
> value types in java, will it be possible to rewrite these to value types
> without breaking compatibility with old pre-value-types code? E.g. if I
> change my Point object to value type in my library, can this new library
> (jar) still be used in other projects that were written before this change?
> And without need to recompile those other projects?
>



More information about the valhalla-dev mailing list