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

MethodHandle.Lookup functionality to define a nestmate class

    Details

      Description

      The method Unsafe.defineAnonymousClass:

          public Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches) {

      is used in a few areas to define anonymous classes such as LambdaMetaFactory (although only one use leverages the constant pool patch ing).

      The defining of a class (anonymous or otherwise) within the context of a hosted class can be referred to as defining a "nest mate" class.

      A subset of such functionality could be supported as a method on MethodHandle.Lookup:

        public Class<?> defineNestmate(boolean anonymous, byte[] bytes)

      Where the lookup class is the context for the nest, and where the method only functions if the lookup supports private access.

      Code in LambdaMethodFactory and StringConcatFactory could be updated to use the public method.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mchung Mandy Chung
                Reporter:
                psandoz Paul Sandoz
              • Votes:
                0 Vote for this issue
                Watchers:
                15 Start watching this issue

                Dates

                • Created:
                  Updated: