/** * Retrieve the main entry class. * * @return The main entry class. * @throws ClassNotFoundException If the class cannot be found. * @throws NoSuchRealmException If the specified main entry realm does not exist. */ public Class getMainClass() throws ClassNotFoundException, NoSuchRealmException { return getMainRealm().loadClass( getMainClassName() ); }
/** Retrieve the main entry class. * * @return The main entry class. * * @throws ClassNotFoundException If the class cannot be found. * @throws NoSuchRealmException If the specified main entry realm does not exist. */ public Class getMainClass() throws ClassNotFoundException, NoSuchRealmException { return getMainRealm().loadClass(getMainClassName()); }
/** * Retrieve the enhanced main entry method. * * @return The enhanced main entry method. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected Method getEnhancedMainMethod() throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException { Method[] methods = getMainClass().getMethods(); Class cwClass = getMainRealm().loadClass( ClassWorld.class.getName() ); Method m = getMainClass().getMethod( "main", new Class[] { String[].class, cwClass } ); int modifiers = m.getModifiers(); if ( Modifier.isStatic( modifiers ) && Modifier.isPublic( modifiers ) ) { if ( m.getReturnType() == Integer.TYPE || m.getReturnType() == Void.TYPE ) { return m; } } throw new NoSuchMethodException( "public static void main(String[] args, ClassWorld world)" ); }
InvocationTargetException, NoSuchMethodException, NoSuchRealmException ClassRealm mainRealm = getMainRealm();
InvocationTargetException, NoSuchMethodException, NoSuchRealmException ClassRealm mainRealm = getMainRealm(); Class mainClass = getMainClass(); Method mainMethod = getMainMethod();
InvocationTargetException, NoSuchMethodException, NoSuchRealmException ClassRealm mainRealm = getMainRealm(); Class mainClass = getMainClass(); Method mainMethod = getEnhancedMainMethod();
InvocationTargetException, NoSuchMethodException, NoSuchRealmException ClassRealm mainRealm = getMainRealm();