コード例 #1
0
 /**
  * Return the current size of the cache of the BDD library. Returns -1 if value cannot be read.
  */
 private int readCacheSize() {
   if (factory instanceof JFactory) {
     // Unfortunately JFactory does not update its reported size on cache resizes.
     try {
       Field cacheField = JFactory.class.getDeclaredField("applycache");
       cacheField.setAccessible(true);
       Object cache = cacheField.get(factory);
       if (cache != null) {
         Field tableField = cache.getClass().getDeclaredField("table");
         tableField.setAccessible(true);
         Object table = tableField.get(cache);
         if (table instanceof Object[]) {
           return ((Object[]) table).length;
         }
       }
     } catch (ReflectiveOperationException | SecurityException e) {
       logger.logDebugException(e, "Could not access cache field of JFactory for statistics");
     }
     return -1;
   }
   return factory.getCacheSize();
 }