Class ClosureCleaner


  • @Internal
    public class ClosureCleaner
    extends Object
    The closure cleaner is a utility that tries to truncate the closure (enclosing instance) of non-static inner classes (created for inline transformation functions). That makes non-static inner classes in many cases serializable, where Java's default behavior renders them non-serializable without good reason.
    • Constructor Detail

      • ClosureCleaner

        public ClosureCleaner()
    • Method Detail

      • clean

        public static void clean​(Object func,
                                 ExecutionConfig.ClosureCleanerLevel level,
                                 boolean checkSerializable)
        Tries to clean the closure of the given object, if the object is a non-static inner class.
        Parameters:
        func - The object whose closure should be cleaned.
        level - the clean up level.
        checkSerializable - Flag to indicate whether serializability should be checked after the closure cleaning attempt.
        Throws:
        InvalidProgramException - Thrown, if 'checkSerializable' is true, and the object was not serializable after the closure cleaning.
        RuntimeException - A RuntimeException may be thrown, if the code of the class could not be loaded, in order to process during the closure cleaning.
      • ensureSerializable

        public static void ensureSerializable​(Object obj)