/** * 指定のクラスローダーからクラスをロードし、そのクラスのインスタンスを生成して返す。 * * @param loader クラスローダー * @param name クラスの名前 * @param arguments 引数の一覧 * @return 生成したインスタンス */ protected Object create(ClassLoader loader, Name name, Object... arguments) { try { Class<?> loaded = loader.loadClass(name.toNameString()); for (Constructor<?> ctor : loaded.getConstructors()) { if (ctor.getParameterTypes().length == arguments.length) { return ctor.newInstance(arguments); } } throw new AssertionError(); } catch (Exception e) { throw new AssertionError(e); } }