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

secondary mirrors, low-level trusted factory API

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: repo-valhalla
    • Fix Version/s: repo-valhalla
    • Component/s: hotspot
    • Labels:

      Description

      In a jdk.internal package somewhere, make a factory method which builds new instances of java.lang.Class.

      package jdk.internal.vm;

      public class ClassMirrors {
      /**
      Make a fresh non-classfile mirror with the given name.
      If primary is non-null, the mirror will be secondary to the given one.
      That means, in part, that all operational reflective API points will delegate
      from the secondary to the primary.
      If primary is null there is no delegation.
      The userData may be null; it is available to other clients.
      */
      public static native Class<?> makeSecondaryMirror(String name, Class<?> primary, Object userData);

      public static native Class<?> primaryOf(Class<?> secondary);
      public static native Object userDataOf(Class<?> secondary);
      }

      The purpose of this is to allow reflection to create mirrors which correspond to variant view of classes. For example, given a primitive class P with two mirrors P.ref.class and P.val.class, perhaps P.ref.class is the "real" mirror (the primary, created when P is loaded) and P.val.class is a secondary which points back to P.ref.class. (Or vice versa.)

      One could validate the design by re-implementing int.class (Integer.TYPE) using this mechanism, instead of the ad hoc JVM logic that currently support int.class.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jrose John Rose
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: