Class ReflectionUtils


  • public class ReflectionUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K,​V>
      void
      clearMapField​(java.lang.Class<?> clazz, java.lang.Object instance, java.lang.String mapName, java.util.function.Predicate<java.util.Map.Entry<K,​V>> shouldRemove)
      Used by the in-jvm dtest framework to remove entries from private map fields that otherwise would prevent collection of classloaders (which causes metaspace OOMs) or otherwise interfere with instance restart.
      static java.lang.reflect.Field getField​(java.lang.Class<?> clazz, java.lang.String fieldName)  
      static java.lang.reflect.Field getModifiersField()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getModifiersField

        public static java.lang.reflect.Field getModifiersField()
                                                         throws java.lang.NoSuchFieldException
        Throws:
        java.lang.NoSuchFieldException
      • getField

        public static java.lang.reflect.Field getField​(java.lang.Class<?> clazz,
                                                       java.lang.String fieldName)
                                                throws java.lang.NoSuchFieldException
        Throws:
        java.lang.NoSuchFieldException
      • clearMapField

        public static <K,​V> void clearMapField​(java.lang.Class<?> clazz,
                                                     java.lang.Object instance,
                                                     java.lang.String mapName,
                                                     java.util.function.Predicate<java.util.Map.Entry<K,​V>> shouldRemove)
        Used by the in-jvm dtest framework to remove entries from private map fields that otherwise would prevent collection of classloaders (which causes metaspace OOMs) or otherwise interfere with instance restart.
        Type Parameters:
        K - The type of the map key
        V - The type of the map value
        Parameters:
        clazz - The class which has the map field to clear
        instance - an instance of the class to clear (pass null for a static member)
        mapName - the name of the map field to clear
        shouldRemove - a predicate which determines if the entry in question should be removed