Ejemplo n.º 1
0
  protected static boolean wasCalledDuringClassLoading() {
    if (LOCK.isHeldByCurrentThread()) return true;
    LOCK.lock();

    try {
      StackTrace st = new StackTrace(new Throwable());
      int n = st.getDepth();

      for (int i = 3; i < n; i++) {
        StackTraceElement ste = st.getElement(i);

        if ("ClassLoader.java".equals(ste.getFileName())
            && "loadClass".equals(ste.getMethodName())) {
          return true;
        }
      }

      return false;
    } finally {
      LOCK.unlock();
    }
  }