jdk/src/share/classes/sun/launcher/LauncherHelper.java
static Method getMainMethod(PrintStream ostream, Class<?> clazz) {
{- -------------------------------------------
(1) class 引数で指定されたクラスの main() メソッドを取得する.
もし存在しなければ, ここで abort.
---------------------------------------- -}
String classname = clazz.getName();
Method method = null;
try {
method = clazz.getMethod("main", String[].class);
} catch (NoSuchMethodException nsme) {
abort(ostream, null, "java.launcher.cls.error4", classname);
}
{- -------------------------------------------
(1) 取得した main() メソッドが, static でかつ返値が void であることを確認する.
もしそうでなければ, ここで abort.
---------------------------------------- -}
/*
* getMethod (above) will choose the correct method, based
* on its name and parameter type, however, we still have to
* ensure that the method is static and returns a void.
*/
int mod = method.getModifiers();
if (!Modifier.isStatic(mod)) {
abort(ostream, null, "java.launcher.cls.error2", "static", classname);
}
if (method.getReturnType() != java.lang.Void.TYPE) {
abort(ostream, null, "java.launcher.cls.error3", classname);
}
{- -------------------------------------------
(1) 結果をリターン
---------------------------------------- -}
return method;
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.