/** * Obtain a {@code Class<?>} reference for the class named by this {@link ClassInfo} object. Causes the * ClassLoader to load the class, if it is not already loaded. * * @return The class reference, or null, if ignoreExceptions is true and there was an exception or error loading * the class. * @throws IllegalArgumentException * if ignoreExceptions is false and there were problems loading the class. */ @Override public Class<?> loadClass(final boolean ignoreExceptions) { return super.loadClass(ignoreExceptions); }
/** * Obtain a {@code Class<?>} reference for the class named by this {@link ClassInfo} object. Causes the * ClassLoader to load the class, if it is not already loaded. * * @return The class reference. * @throws IllegalArgumentException * if there were problems loading the class. */ @Override public Class<?> loadClass() { return super.loadClass(/* ignoreExceptions = */ false); }
/** * Load the class named returned by {@link #getClassInfo()}, or if that returns null, the class named by * {@link #getClassName()}. Returns a {@code Class<?>} reference for the class. * * @return The {@code Class<?>} reference for the referenced class, or null if the class could not be loaded and * ignoreExceptions is true. * @throws IllegalArgumentException * if the class could not be loaded and ignoreExceptions was false. */ Class<?> loadClass() { return loadClass(/* ignoreExceptions = */ false); } }
/** * Load the class named returned by {@link #getClassInfo()}, or if that returns null, the class named by * {@link #getClassName()}. Returns a {@code Class<?>} reference for the class, cast to the requested superclass * or interface type. * * @param superclassOrInterfaceType * The type to cast the resulting class reference to. * @return The {@code Class<?>} reference for the referenced class, or null if the class could not be loaded (or * casting failed) and ignoreExceptions is true. * @throws IllegalArgumentException * if the class could not be loaded or cast, and ignoreExceptions was false. */ <T> Class<T> loadClass(final Class<T> superclassOrInterfaceType) { return loadClass(superclassOrInterfaceType, /* ignoreExceptions = */ false); }
/** * Obtain a {@code Class<?>} reference for the class named by this {@link ClassInfo} object, casting it to the * requested interface or superclass type. Causes the ClassLoader to load the class, if it is not already * loaded. * * <p> * <b>Important note:</b> since {@code superclassOrInterfaceType} is a class reference for an already-loaded * class, it is critical that {@code superclassOrInterfaceType} is loaded by the same classloader as the class * referred to by this {@code ClassInfo} object, otherwise the class cast will fail. * * @param superclassOrInterfaceType * The type to cast the loaded class to. * @return The class reference. * @throws IllegalArgumentException * if there were problems loading the class or casting it to the requested type. */ @Override public <T> Class<T> loadClass(final Class<T> superclassOrInterfaceType) { return super.loadClass(superclassOrInterfaceType, /* ignoreExceptions = */ false); }
/** * Obtain a {@code Class<?>} reference for the class named by this {@link ClassInfo} object, casting it to the * requested interface or superclass type. Causes the ClassLoader to load the class, if it is not already * loaded. * * <p> * <b>Important note:</b> since {@code superclassOrInterfaceType} is a class reference for an already-loaded * class, it is critical that {@code superclassOrInterfaceType} is loaded by the same classloader as the class * referred to by this {@code ClassInfo} object, otherwise the class cast will fail. * * @param superclassOrInterfaceType * The type to cast the loaded class to. * @param ignoreExceptions * If true, return null if any exceptions or errors thrown during classloading, or if attempting to * cast the resulting {@code Class<?>} reference to the requested superclass or interface type fails. * If false, {@link IllegalArgumentException} is thrown if the class could not be loaded or could not * be cast to the requested type. * @return The class reference, or null, if ignoreExceptions is true and there was an exception or error loading * the class. * @throws IllegalArgumentException * if ignoreExceptions is false and there were problems loading the class, or casting it to the * requested type. */ @Override public <T> Class<T> loadClass(final Class<T> superclassOrInterfaceType, final boolean ignoreExceptions) { return super.loadClass(superclassOrInterfaceType, ignoreExceptions); }
final Class<?> classRef = super.loadClass(); if (!classRef.isEnum()) { throw new IllegalArgumentException("Class " + className + " is not an enum");