> On Apr 18, 2019, at 4:08 PM, John Rose <[email protected]> wrote: > > Here's the background: The JVMS takes great care to > use the terms "reference" and "value" with > precision, and this occasionally surfaces in explanations > meant for ordinary Java users. We have already released > the term "value" from its new duties; I think we have an > equal need to release "reference" from its new duties > as well. > > (Put another way: The JVMS says that all a-series opcodes > take "reference" arguments, and all L-series descriptors > denotes reference variables. In L-world "reference" means > a value which refers potentially to either an inline object > or a non-inlinable identity-laden object. Changing this > term is IMO not feasible. I'm arguing against overloading > as well.) > > So what we need is a formal term NI which means "not > inline", the opposite of the formal term "inline".
I'm working on the introductory spec material, and have also come to this conclusion. All values are either *primitives* or *references*. Everything we've done in L-world has to do with refining the space of things that references can point to (*objects*). > Now for a NI bikeshed color. I think it is sufficient > to use the term "identity" for NI. > > Thus, we would have: > > - inline classes and identity classes > - inline types and identity types > - the top types InlineObject and IdentityObject > - inline objects and identity objects > - inline values and identity values > - inline references and identity references > - informally, maybe "inlines" and "identities" Here's a cut of JVMS 2.4 that incorporates some of this terminology (some of it I've avoided, either because I didn't need it, or it seemed insufficiently precise.) I also decided to call out the `Object` type as a unique entity. This probably have some ripple effects elsewhere, which I haven't explored yet. It's hard to say much about identity without talking about acmp/substitutability; I chose the term "identical" here for that purpose (rather than the overloaded "equal"). ~~~~~~~~~~ ### 2.4 Reference Types and Values There are five kinds of reference types: identity class types, inline class types, array types, interface types, and the `Object` type. Their values are references to *objects* or the special `null` reference. An identity class type names a non-inline, non-interface class other than `Object` defined in a `class` file. The objects referenced by values of an identity class type are instances of the class or one of its subclasses. Each instance is dynamically allocated and has a unique *identity*, which is used to determine whether two references are identical. The instance encapsulates *fields*; the values of fields may be changed, but doing so does not change the identity of the object. An inline class type names an inline class defined in a `class` file. The objects referenced by values of an inline class type are instances of the class. Each instance encapsulates fields whose values cannot be changed. Inline class instances do not have a unique identity—two references are identical if they reference instances of the same inline class and the values of the objects' fields are identical. For each inline class, there is a *nullable* and a *null-free* inline class type. These types share the same set of values, with the exception that `null` is a value of the nullable type, but not the null-free type. An array type names a *component type*, which may be `boolean`, any numeric type, or any reference type. The objects referenced by values of an array type are dynamically-allocated arrays. Each array object has a unique identity, a component type, and a vector of mutable components. The identity is used to determine whether two references are identical. The components store values of the component type; the number of components is fixed at allocation time, but is not constrained by the array type. Array types are covariant: if an array type has component type *T*, an array referenced by a value of the array type has a component type that is a subtype of *T*. The component type of an array type may itself be an array type; such a type is a *multi-dimensional* array type. The *element type* of a single-dimensional array type is its component type; the element type of a multi-dimensional array type is the element type of its component type. An interface type names an interface defined in a `class` file. The objects referenced by values of an interface type are instances of a class that implements the interface. These instances may be identity objects or inline objects. The objects referenced by values of interface types `Cloneable` and `java.io <http://java.io/>.Serializable` may also be arrays. The `Object` type names the `Object` class. References of type `Object` may refer to any object: identity class instances, inline class instances, or arrays. Instances of the `Object` class itself are treated as identity class instances. The default value of a null-free inline class type is a reference to a class instance whose fields all have the default value for their type. The default value of any other reference type is `null`. ~~~~~~~~~~
