code: public static Class<?> safeClassForName(ClassLoader classLoader, String className) {
          try {
              if (className.startsWith("com.sun.") || className.startsWith("com.apple.")) {
                  return null;
              } else {
                  return Class.forName(className, true, classLoader);
              }
          } catch (ClassNotFoundException e) {
              return null;
          } catch (NoClassDefFoundError e) {
              return null;
          }
      }
docs: Get the class for the given className via the given classLoader
  
  @param classLoader classloader to be used
  @param className fully qualified class name
  @return {@code Class} instance matching the class name or null if not found