JEP update: Classes for the Basic Primitives

Kevin Bourrillion kevinb at google.com
Thu Feb 10 02:18:50 UTC 2022


Some much-delayed feedback/questions....

* Could the doc make a clearer distinction (throughout) between which facts
about int/Integer are happening because we expect *all* bucket-3 classes to
work that way, vs. which are special one-off tweaks for the 8 predefined
types?

* I'm curious whether it would be *possible* to make `int` no longer a
keyword, just a special kind of type alias that normal people don't get to
declare. I'm *not* claiming that'd be worth actually doing; just wanting to
understand what forces would act to prevent it, as part of understanding
everything that makes the 8 builtin types "irredeemably special".

* I assume the reason "the JVM type Qjava/lang/Double cannot be encoded
with a Class object" is because the distinction between it and D is
intentional implementation detail.

* Since I think/hope it is *not* true that `int` will be a subtype of
`Integer`, it's not 100% clear whether the phrase "array covariance" in the
doc is referring to the (desirable) property that `int[] <: Integer[]`. I
think it is.

* I said in the meeting that "I don't think anyone cares" what kind of
exception gets thrown if trying to store null in an `Integer[]` which is
secretly an `int[]`. Well, I'm sure that's not at all true. :-) Sorry.

* Re: "a basic primitive class may declare an instance field of its own
primitive" -- does it really need that field, or can we nuke it and just
s/value/this/g throughout the file? If that could work, it would be so much
less confusing -- nothing circular! The only magic would be "where are the
actual bits??" but you don't see the bits of an object header in
`Object.java` either and the number of people this bothers is a very round
number.

~~

Since we might really be on the verge of being through with "boxing" for
good, here, have an appropriate musical closing!




*  "Boxing's been good to me, Howard  Now I'm told, you're growing old  The
whole time you knew, in a couple of years I'd be through  Has boxing been
good to you?"*

https://youtu.be/UtIp6uP13kk?t=30




On Wed, Jan 12, 2022 at 4:22 PM Dan Smith <daniel.smith at oracle.com> wrote:

> I'm made some revisions to JEP 402 to better track with the revised JEP
> 401—in particular backing off of "everything is an object".
>
> There were some short-lived changes where I more aggressively pursued the
> idea that the class was named 'int', but I've backed off of that, too. Now
> taking the more conservative approach that there is a primitive class named
> 'Integer', but by special rule its primitive type is expressed 'int', and
> the class name refers to the reference type.
>
> I realize that much of this could potentially change—reflection story,
> terminology, etc. But consider this the "plan of record" for now.
>
> https://bugs.openjdk.java.net/browse/JDK-8259731



-- 
Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com


More information about the valhalla-spec-observers mailing list