Esempio n. 1
0
 private static CleanerHandles FindHandlesForOldCleaner(MethodHandles.Lookup lookup)
 {
     try
     {
         Type oldCleaner = Type.GetType("sun.misc.Cleaner");
         return(CleanerHandles.Of(FindCreationMethod("create", lookup, oldCleaner), FindCleanMethod(lookup, oldCleaner)));
     }
     catch (Exception oldCleanerException) when(oldCleanerException is ClassNotFoundException || oldCleanerException is NoSuchMethodException || oldCleanerException is IllegalAccessException)
     {
         throw new LinkageError("Unable to find cleaner methods.", oldCleanerException);
     }
 }
Esempio n. 2
0
 private static CleanerHandles FindHandlesForNewCleaner(MethodHandles.Lookup lookup)
 {
     try
     {
         Objects.requireNonNull(_globalCleanerInstance);
         Type         newCleaner     = _globalCleanerInstance.GetType();
         Type         newCleanable   = Type.GetType("java.lang.ref.Cleaner$Cleanable");
         MethodHandle registerHandle = FindCreationMethod("register", lookup, newCleaner);
         registerHandle = registerHandle.bindTo(_globalCleanerInstance);
         return(CleanerHandles.Of(registerHandle, FindCleanMethod(lookup, newCleanable)));
     }
     catch (Exception newCleanerException) when(newCleanerException is ClassNotFoundException || newCleanerException is NoSuchMethodException || newCleanerException is IllegalAccessException)
     {
         throw new LinkageError("Unable to find cleaner methods.", newCleanerException);
     }
 }