Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8261782

[lworld] Add support for PrimitiveObject interface



    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: repo-valhalla
    • Fix Version/s: repo-valhalla
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
    • OS:


      From https://openjdk.java.net/jeps/8251554:

      The PrimitiveObject and IdentityObject interfaces
      There are two new interfaces introduced as essential preview APIs:

      All primitive classes implicitly implement PrimitiveObject. All identity classes (including all preexisting concrete classes in the Java ecosystem) implicitly implement IdentityObject. Array types are also subtypes of IdentityObject.

      These interfaces help to distinguish between identity objects and primitive objects in three ways:

      An instanceof IdentityObject or instanceof PrimitiveObject test can be used to determine whether an object has identity (and similarly for reflection on the Class).

      A variable of type IdentityObject or PrimitiveObject can hold an arbitrary object with or without identity, respectively.

      An extends IdentityObject or extends PrimitiveObject type parameter bound can be used to require type arguments that guarantee values with or without identity, respectively.

      An interface can explicitly extend either IdentityObject or PrimitiveObject if the author determines that all implementing objects are expected to have or not have identity. It is an error if a class ends up implementing both interfaces (implicitly, explicitly, or by inheritance). By default, an interface extends neither interface and can be implemented by both kinds of concrete classes.

      An abstract class can similarly be declared to implement either IdentityObject or PrimitiveObject; or, if it declares a field, an instance initializer, a non-empty constructor, or a synchronized method, it implicitly implements IdentityObject. Otherwise, it extends neither interface and can be extended by both kinds of concrete classes.

      The class Object behaves like a simple abstract class: it implements neither IdentityObject nor PrimitiveObject. Calls to new Object() are re-interpreted as instance creation of a new, empty identity subclass of Object (name TBD).


      Compilation and run time
      Primitive classes are compiled to class files, with special treatment deeply integrated into the Java Virtual Machine.

      class file representation & interpretation
      A primitive class is declared in a class file using the ACC_PRIMITIVE modifier (0x0100). (Encoding of modifiers indicating a reference-favoring or validation-enforcing class is TBD.) At class load time, the class is considered to implement the interface PrimitiveObject; an error occurs if a primitive class is not final, has a non-final instance field, or implements—directly or indirectly—IdentityObject. At preparation time, an error occurs if a primitive class has a circularity in its instance field types.

      An abstract class that allows primitive subclasses declares this capability in its class file (details TBD). At class load time, an error occurs if the class is not abstract, declares an instance field, declares a synchronized method, or implements—directly or indirectly—IdentityObject.

      At class load time, a class (not an interface) is considered to implement the interface IdentityObject if it is not primitive and does not explicitly allow primitive subclasses. Every array type is also considered to implement IdentityObject. It is a load time error if any class or interface implements or extends—directly or indirectly—both PrimitiveObject and IdentityObject.


          Issue Links



              sadayapalam Srikanth Adayapalam
              sadayapalam Srikanth Adayapalam
              0 Vote for this issue
              1 Start watching this issue