/** * Performs a standard check whether the class can be instantiated by {@code Class#newInstance()}. * * @param clazz The class to check. * @throws RuntimeException Thrown, if the class cannot be instantiated by {@code Class#newInstance()}. */ public static void checkForInstantiation(Class<?> clazz) { final String errorMessage = checkForInstantiationError(clazz); if (errorMessage != null) { throw new RuntimeException("The class '" + clazz.getName() + "' is not instantiable: " + errorMessage); } }
/** * Adds a class under the given key. */ public void putClass(String key, Class<?> clazz) { checkNotNull(key); checkNotNull(clazz); final String error = InstantiationUtil.checkForInstantiationError(clazz); if (error != null) { throw new ValidationException("Class '" + clazz.getName() + "' is not supported: " + error); } put(key, clazz.getName()); }
/** * Performs a standard check whether the class can be instantiated by {@code Class#newInstance()}. * * @param clazz The class to check. * @throws RuntimeException Thrown, if the class cannot be instantiated by {@code Class#newInstance()}. */ public static void checkForInstantiation(Class<?> clazz) { final String errorMessage = checkForInstantiationError(clazz); if (errorMessage != null) { throw new RuntimeException("The class '" + clazz.getName() + "' is not instantiable: " + errorMessage); } }
/** * Performs a standard check whether the class can be instantiated by {@code Class#newInstance()}. * * @param clazz The class to check. * @throws RuntimeException Thrown, if the class cannot be instantiated by {@code Class#newInstance()}. */ public static void checkForInstantiation(Class<?> clazz) { final String errorMessage = checkForInstantiationError(clazz); if (errorMessage != null) { throw new RuntimeException("The class '" + clazz.getName() + "' is not instantiable: " + errorMessage); } }
private org.apache.hadoop.fs.FileSystem instantiateFileSystem(Class<? extends org.apache.hadoop.fs.FileSystem> fsClass) throws IOException { try { return fsClass.newInstance(); } catch (ExceptionInInitializerError e) { throw new IOException("The filesystem class '" + fsClass.getName() + "' throw an exception upon initialization.", e.getException()); } catch (Throwable t) { String errorMessage = InstantiationUtil.checkForInstantiationError(fsClass); if (errorMessage != null) { throw new IOException("The filesystem class '" + fsClass.getName() + "' cannot be instantiated: " + errorMessage); } else { throw new IOException("An error occurred while instantiating the filesystem class '" + fsClass.getName() + "'.", t); } } }
/** * Adds a class under the given key. */ public void putClass(String key, Class<?> clazz) { checkNotNull(key); checkNotNull(clazz); final String error = InstantiationUtil.checkForInstantiationError(clazz); if (error != null) { throw new ValidationException("Class '" + clazz.getName() + "' is not supported: " + error); } put(key, clazz.getName()); }
/** * Adds a class under the given key. */ public void putClass(String key, Class<?> clazz) { checkNotNull(key); checkNotNull(clazz); final String error = InstantiationUtil.checkForInstantiationError(clazz); if (error != null) { throw new ValidationException("Class '" + clazz.getName() + "' is not supported: " + error); } put(key, clazz.getName()); }