JVMS draft for L-world value types with support for nullability
frederic.parain at oracle.com
Tue Feb 6 01:29:05 UTC 2018
Thank you for this very detailed review.
I’ve fixed all the issues (see comments below), and the updated draft is
> On Feb 5, 2018, at 18:31, Karen Kinnear <KAREN.KINNEAR at ORACLE.COM> wrote:
> Detailed review of the updated JVMS draft - many are just minor typos/edits. A couple
> are bigger. Many thanks for the latest changes.
> 1. 2.4 Reference Types and Values
> " whose all instances are identity-less and immutable"
> "whose" -> "for which
> 2. 2.11.5 Instance Creation and Manipulation
> 4th bullet: non-staticfields - need a space)
> 3. 4.1 The Classfile Structure
> "If none of the ACC_VALUE_TYPE or the ACC_INTERFACE flag is set"
> -> "If neither the ACC_VALUE_TYPE …”
> 4. 4.4.1 The CONSTANT_Class_info Structure
> Because arrays are objects, ... "but not the opcode new" - perhaps "but not the opcodes new or defaultvalue”.
> 5. 4.9.1. Static Constraints
> getfield, putfield, getstatic, putstatic -- also withfield - must refer to a CONSTANT_FieldRef
> 6. 4.9.1 Static Constraints
> operands of instanceof, checkcast, new ...
> - also include defaultvalue
> 7. 4.9.1 Static Constraints
> No defaulvalue instruction may reference a constant pool entry ...
> - fix indentation
> 8. 5.3.5 Deriving a Class from a class File Representation
> 3. Note that if C is an interface it must have Object as its direct superclass, ...
> change to "if C is an interface or a value class”
> 9. 5.3.5 Deriving a Class from a class File Representation
> 3. "If the class or interface named as the direct superclass of C is in fact an interface, ...
> change to "is in fact an interface or value class" -> ICCE
> 10. 5.3.5 Deriving a Class from a class File Representation
> 5. Change ACC_VALUE_TYPE flag to ACC_FLATTENABLE
> 5. Perhaps word: If C has any non-static field FC with the ACC_FLATTENABLE flag set, in order
> to use F below in the exception case
> 5. Exceptions:
> Rather than triggering a StackOverflwError, I was expecting a ClassCircularityError
> * If any of the fields marked as ACC_FLATTENABLE is not in fact a value class, loading throws
> an ICCE
> * Otherwise, if any of the ACC_FLATTENABLE fields contains directly or indirectly the class C or the
> class FC, loading throws a ClassCircularityError
I’ve re-worked this section. It will have to be reviewed again.
> 11. 5.3.5 Deriving a Class from a class File Representation
> 5. So it looks as though you have made a change to allow ACC_FLATTENABLE on an object class.
> I recognize there have been requests to support that in the future, but I think that will
> require additional discussions before I would make a JVMS change.
My bad. This is not a change, just a leftover of a previous iterations I forgot to update.
Current semantic is that it is illegal to set the ACC_FLATTENABLE flag for a field
which is an object class.
I’ve fixed this section too.
> Perhaps a bit of non-normative text here say in italics?
> i.e. we do not allow a value class to migrate to an object class
> - intention is to allow declaration of a ACC_FLATTENABLE to imply non-nullable for
> object classes as well as value classes?
> - I would leave this out until we have had further detailed discussions
I’d prefer to keep this idea in our discussion, and not write it down in the spec, to avoid
making wrong expectations.
> 12. 5.5. Initialization
> Thank you for adding step 8 to pre-initialize an ACC_FLATTENABLE field.
> Can you also add this to the bullets under "may be initialized only as a result of:
> * If C is a reference type and a containing class declares a field C with the
> ACC_FLATTENABLE flag set …
> 13. General question
> Would it make sense to disallow an Interface to define a field with ACC_FLATTENABLE?
Yes, if you want to prevent
> 14. Chapter 6:
> putfield "withe" -> "with the”
> I need to double-check - I was expecting a runtime, not a linktime NPE due to ACC_FLATTENABLE.
> Does linktime actually know the value you are writing?
You’re right, it’s a runtime exception.
> 15. Chapter 6:
> mentions null for value class type throws NPE, but I think that is intended to be if
> ACC_FLATTENABLE, and again - isn't this a run-time exception?
> 16. Chapter 6:
> new: if finds interface, abstract class or value class -> throws InstantiationError
> defaultvalue: if interface or abstract class, throws InstantiationError
> if object class, throws ICCE
> We can ask Dan Smith what he prefers here. Given it is ok to migrate object class to value class, but
> not value class to object class, perhaps it is appropriate to have asymmetric errors.
I will let Dan answer this one, I don’t have a preference or a good argument here.
> 17. Chapter 6:
> typo: vwithtfield =204
> same question: NPE - isn't that a runtime exception
>> On Feb 5, 2018, at 2:05 PM, Frederic Parain <frederic.parain at oracle.com> wrote:
>> Here’s an update of the JVMS draft:
>> with the following changes:
>> * Renamed ACC_NON_NULLABLE with ACC_FLATTENABLE
>> * Removed restriction that ACC_FLATTENABLE cannot be used on static fields
>> * Added rules about circularity restrictions for fields with the ACC_FLATTENABLE flag set
>> * Added rules about initialization of classes of flattenable fields
More information about the valhalla-spec-experts