/** * Indicates whether or not the given class exists * * @param className Name of the class * @return {@code true} if the class exists, {@code false} otherwise */ public static boolean isClassDefined(String className) { try { tryLoadClass(className); return true; } catch (ClassNotFoundException e) { return false; } }
/** * Indicates whether or not the given class exists * * @param className Name of the class * @return {@code true} if the class exists, {@code false} otherwise */ public static boolean isClassDefined(String className) { try { tryLoadClass(className); return true; } catch (ClassNotFoundException e) { return false; } }
@SuppressWarnings("unchecked") private static <T> T newInstance0(ClassLoader classLoader, String className) throws Exception { Class klass = classLoader == null ? Class.forName(className) : tryLoadClass(className, classLoader); final Constructor constructor = klass.getDeclaredConstructor(); if (!constructor.isAccessible()) { constructor.setAccessible(true); } if (!shouldBypassCache(klass) && classLoader != null) { CONSTRUCTOR_CACHE.put(classLoader, className, constructor); } return (T) constructor.newInstance(); }
@SuppressWarnings("unchecked") private static <T> T newInstance0(ClassLoader classLoader, String className) throws Exception { Class klass = classLoader == null ? Class.forName(className) : tryLoadClass(className, classLoader); final Constructor constructor = klass.getDeclaredConstructor(); if (!constructor.isAccessible()) { constructor.setAccessible(true); } if (!shouldBypassCache(klass) && classLoader != null) { CONSTRUCTOR_CACHE.put(classLoader, className, constructor); } return (T) constructor.newInstance(); }
return tryLoadClass(className, theClassLoader); } catch (ClassNotFoundException ignore) { return tryLoadClass(className, theClassLoader);
return tryLoadClass(className, theClassLoader); } catch (ClassNotFoundException ignore) { return tryLoadClass(className, theClassLoader);
private ClassLoader loadScriptEngineFactoryClassLoader(String factoryName) { // We do not really need the class, but we need the classloader try { return ClassLoaderUtil.tryLoadClass(factoryName).getClassLoader(); } catch (ClassNotFoundException cnfe) { // may fail if script implementation is not in environment logger.warning("Found ScriptEngineFactory candidate for " + factoryName + ", but cannot load class! -> " + cnfe); if (logger.isFinestEnabled()) { logger.finest(cnfe); } return null; } }
private ClassLoader loadScriptEngineFactoryClassLoader(String factoryName) { // We do not really need the class, but we need the classloader try { return ClassLoaderUtil.tryLoadClass(factoryName).getClassLoader(); } catch (ClassNotFoundException cnfe) { // may fail if script implementation is not in environment logger.warning("Found ScriptEngineFactory candidate for " + factoryName + ", but cannot load class! -> " + cnfe); if (logger.isFinestEnabled()) { logger.finest(cnfe); } return null; } }