code: public static boolean shouldCacheThrowable(Throwable throwable, int numFrames) {
          // only cache frames when 'in app' packages are provided
          if (appPackages.isEmpty()) {
              return false;
          }
  
          // many libraries/frameworks seem to rethrow the same object with trimmed
          // stacktraces, which means later ("smaller") throws would overwrite the existing
          // object in cache. for this reason we prefer the throw with the greatest stack
          // length...
          Map<Throwable, Frame[]> weakMap = cache.get();
          Frame[] existing = weakMap.get(throwable);
          if (existing != null && numFrames <= existing.length) {
              return false;
          }
  
          // check each frame against all "in app" package prefixes
          for (StackTraceElement stackTraceElement : throwable.getStackTrace()) {
              for (String appFrame : appPackages) {
                  if (stackTraceElement.getClassName().startsWith(appFrame)) {
                      return true;
                  }
              }
          }
  
          return false;
      }
docs: Check whether the provided {@link Throwable} should be cached or not. Called by
  the native agent code so that the Java side (this code) can check the existing
  cache and user configuration, such as which packages are "in app".
  
  @param throwable Throwable to be checked
  @param numFrames Number of frames in the Throwable's stacktrace
  @return true if the Throwable should be processed and cached