RefObject and ValObject

forax at univ-mlv.fr forax at univ-mlv.fr
Mon Apr 15 20:54:55 UTC 2019


> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Maurizio Cimadamore" <maurizio.cimadamore at oracle.com>,
> "valhalla-spec-experts" <valhalla-spec-experts at openjdk.java.net>
> Envoyé: Lundi 15 Avril 2019 22:39:43
> Objet: Re: RefObject and ValObject

>> 1) any codes that has inference
>> var list = List.of(new Foo(), new Bar());
>> will be inferred as List<RefObject> instead of List<Object>, so calling a method
>> that takes a List<Object> will not compile anymore.

> Not to dismiss the “what about inference” issue, but any code that combines
> `var` with `List,of()` should not be surprised at the result of inference ….

> But, “what about inference” noted.

you don't need var, var represent the inference value of an expression, instead of having two lines, you can always write 
m(List<Object> list ) { ... } 
... 
m(List.of(new Foo(), new Bar())); 

>> 2) any code that consider Object as special class may stop working, dynamic
>> proxies that have a special case for Object, any code that reflect recursively
>> on the hierarchy to find all the methods, any code that remove getClass() from
>> the getter list, etc.

> Absorbing value types is going to require some changes on the part of most
> frameworks to get best results. This one seems in that category?

> Again, not to dismiss, keep them coming, but so far this isn’t scaring me away
> from having the object model that makes most sense.

but this compatibility issues have nothing to do with value types pre se, it's because of the introduction of RefObject, and currently all other compatibility issues can be solved at use site (i believe), here you are adding compatibility issue that can only be solved at declaration site, that's a big change because now as a user you have to wait until all your dependencies have been updated before using value type. 

Rémi 


More information about the valhalla-spec-observers mailing list