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

API for archiving Java objects that need special clean up/restore

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • tbd
    • None
    • core-libs

      A general solution for JDK-8311071 may be new API to clean up and restore archived Java objects.

      For example, something like this can be used:

      - dump time: remove SoftReferences before the object is archived
      - run time: recreate the SoftReferences after the object is materialized

      class LambdaFormEditor$Transform implements CDSCleaner, CDSRestorer {
          Object cache;

          private Transform(long packedBytes, byte[] fullBytes, LambdaForm result) {
              cache = new SoftReference<LambdaForm>(result);
              this.packedBytes = packedBytes;
              this.fullBytes = fullBytes;
              CDSCleaner.register(this);
          }

          public void cleanForCDS() { // CDSCleaner
              SoftReference<LambdaForm> ref = (SoftReference<LambdaForm>)cache;
              cache = ref.get();
          }

          public void restoreFromCDS() { // CDSRestorer
              cache = new SoftReference<LambdaForm>((LambdaForm)cache);
          }
      }

            Unassigned Unassigned
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: