[lworld] Handling of missing ValueTypes attributes

John Rose john.r.rose at oracle.com
Tue Jul 10 00:08:25 UTC 2018

On Jul 9, 2018, at 3:44 PM, Ioi Lam <ioi.lam at oracle.com> wrote:
> In lworld, how are we suppose to handle cases where the ValueTypes attribute should have been there for a classfile, but is missing?
> E.g.,
>   class MyHack {
>       Point getPoint() {
>           if (onceInAWhile) {
>               return Point.makePoint(1, 2);
>           } else {
>               return null;
>           }
>       }
>   }
> Normally, Point will be included in MyHack's ValueTypes attribute, and the Point class will be aggressively loaded. So we'd know for sure that getPoint returns a ValueType.
> However, someone can write this class by hand and omit the ValueTypes attribute. In that case, I think the program's output should be the same as if the ValueTypes attribute had been present, although performance may differ (slower, more heap allocations, etc).
> Is this understanding correct?

Yes, that is correct.  This model is intended to make it easier for old-school classfiles
to link to old types which have (over time) been upgraded to value types.

More information about the valhalla-dev mailing list