private Class<?> asClass(final Object code) { if (code instanceof Class) return (Class<?>) code; if (code instanceof String) return Types.load((String) code); return null; }
private Class<?> getClass(final Object code) { if (code instanceof Class) return (Class<?>) code; if (code instanceof String) return Types.load((String) code); return null; }
/** * Loads the class with the given name, using the current thread's context * class loader, or null if it cannot be loaded. * * @param name The name of the class to load. * @return The loaded class, or null if the class could not be loaded. * @see #load(String, ClassLoader, boolean) */ public static Class<?> load(final String name) { return load(name, null, true); }
private synchronized void initCommandClass() { if (ij1Class != null) return; ij1Class = Types.load(className, classLoader, true); } }
/** * Loads the class with the given name, using the current thread's context * class loader, or null if it cannot be loaded. * * @param name The name of the class to load. * @return The loaded class, or null if the class could not be loaded. * @see #load(String, ClassLoader, boolean) */ public static Class<?> load(final String name) { return load(name, null, true); }
private Class<?> getClass(final Object code) { if (code instanceof Class) return (Class<?>) code; if (code instanceof String) return Types.load((String) code); return null; }
/** @deprecated Use {@link Types#load(String, ClassLoader)} instead. */ @Deprecated public static Class<?> loadClass(final String name, final ClassLoader classLoader) { return Types.load(name, classLoader); }
/** @deprecated Use {@link Types#load(String, boolean)} instead. */ @Deprecated public static Class<?> loadClass(final String className, final boolean quietly) { return Types.load(className, quietly); }
/** @deprecated Use {@link Types#load(String, ClassLoader)} instead. */ @Deprecated public static boolean hasClass(final String className, final ClassLoader classLoader) { return Types.load(className, classLoader) != null; }
/** @deprecated Use {@link Types#load(String)} instead. */ @Deprecated public static Class<?> loadClass(final String name) { return Types.load(name); }
/** * @deprecated Use {@link Types#load(String, ClassLoader, boolean)} instead. */ @Deprecated public static Class<?> loadClass(final String name, final ClassLoader classLoader, final boolean quietly) { return Types.load(name, classLoader, quietly); }
/** @deprecated Use {@link Types#load(String)} instead. */ @Deprecated public static boolean hasClass(final String className) { return Types.load(className) != null; }
/** @deprecated Use {@link Types#load(String)} instead. */ @Deprecated public static boolean hasClass(final String className) { return Types.load(className) != null; }
/** @deprecated Use {@link Types#location} and {@link Types#load} instead. */ @Deprecated public static URL getLocation(final String className) { return Types.location(Types.load(className)); }
/** @deprecated Use {@link Types#location} and {@link Types#load} instead. */ @Deprecated public static URL getLocation(final String className, final ClassLoader classLoader) { return Types.location(Types.load(className, classLoader)); }
/** @deprecated Use {@link Types#field} instead. */ @Deprecated public static Field getField(final String className, final String fieldName) { try { return Types.field(Types.load(className), fieldName); } catch (final IllegalArgumentException e) { return null; } }
/** Gets the service of the given class name (useful for scripts). */ public Service getService(final String className) { final Class<?> c = Types.load(className); if (c == null) return null; if (!Service.class.isAssignableFrom(c)) return null; // not a service class @SuppressWarnings("unchecked") final Class<? extends Service> serviceClass = (Class<? extends Service>) c; return getService(serviceClass); }
/** @deprecated Use {@link Types#field} instead. */ @Deprecated public static Field getField(final String className, final String fieldName) { try { return Types.field(Types.load(className), fieldName); } catch (final IllegalArgumentException e) { return null; } }
/** Tests {@link Types#load}. */ @Test(expected = IllegalArgumentException.class) public void testLoadFailureLoud() { Types.load("a.non.existent.class", false); }
/** Tests {@link Types#load}. */ @Test public void testLoadFailureQuiet() { // test quiet failure assertNull(Types.load("a.non.existent.class")); }