< prev index next >

src/com/sun/javatest/Script.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


1023     protected void setDefaultCommandStreamNames(String out1Name, String out2Name) {
1024         cmdOut1Name = out1Name;
1025         cmdOut2Name = out2Name;
1026     }
1027 
1028     /**
1029      * Create and run a Command object.
1030      * @param className The name of the class to load and instantiate.
1031      * @param args      The args to pass to the `run' method of the loaded object.
1032      * @return          The result identifies any problems that may occur in trying
1033      *                  to create and run the specified object, or if it succeeds,
1034      *                  it returns the result from calling the object's `run' method.
1035      * @see Command
1036      */
1037     private Status invokeClass(String className, String[] args,
1038                                PrintWriter out1, PrintWriter out2) {
1039         // this is the central place where we get to run what the user
1040         // says in the environment file:
1041         Command testCommand;
1042         try {
1043             Class c = (loader == null ? Class.forName(className) : loader.loadClass(className));
1044             testCommand = (Command)(c.newInstance());
1045         }
1046         catch (ClassCastException e) {
1047             return Status.error(i18n.getString("script.cantRunClass",
1048                                                new Object[] { className, Command.class.getName() }));
1049         }
1050         catch (ClassNotFoundException ex) {
1051             return Status.error(i18n.getString("script.cantFindClass",
1052                                                new Object[] { className, env.getName() }));
1053         }
1054         catch (IllegalAccessException ex) {
1055             return Status.error(i18n.getString("script.cantAccessClass",
1056                                                new Object[] { className, env.getName() }));
1057         }
1058         catch (IllegalArgumentException ex) {
1059             return Status.error(i18n.getString("script.badClassName",
1060                                                new Object[] { className, env.getName() }));
1061         }
1062         catch (InstantiationException ex) {
1063             return Status.error(i18n.getString("script.cantCreateClass",




1023     protected void setDefaultCommandStreamNames(String out1Name, String out2Name) {
1024         cmdOut1Name = out1Name;
1025         cmdOut2Name = out2Name;
1026     }
1027 
1028     /**
1029      * Create and run a Command object.
1030      * @param className The name of the class to load and instantiate.
1031      * @param args      The args to pass to the `run' method of the loaded object.
1032      * @return          The result identifies any problems that may occur in trying
1033      *                  to create and run the specified object, or if it succeeds,
1034      *                  it returns the result from calling the object's `run' method.
1035      * @see Command
1036      */
1037     private Status invokeClass(String className, String[] args,
1038                                PrintWriter out1, PrintWriter out2) {
1039         // this is the central place where we get to run what the user
1040         // says in the environment file:
1041         Command testCommand;
1042         try {
1043             Class<?> c = (loader == null ? Class.forName(className) : loader.loadClass(className));
1044             testCommand = (Command)(c.newInstance());
1045         }
1046         catch (ClassCastException e) {
1047             return Status.error(i18n.getString("script.cantRunClass",
1048                                                new Object[] { className, Command.class.getName() }));
1049         }
1050         catch (ClassNotFoundException ex) {
1051             return Status.error(i18n.getString("script.cantFindClass",
1052                                                new Object[] { className, env.getName() }));
1053         }
1054         catch (IllegalAccessException ex) {
1055             return Status.error(i18n.getString("script.cantAccessClass",
1056                                                new Object[] { className, env.getName() }));
1057         }
1058         catch (IllegalArgumentException ex) {
1059             return Status.error(i18n.getString("script.badClassName",
1060                                                new Object[] { className, env.getName() }));
1061         }
1062         catch (InstantiationException ex) {
1063             return Status.error(i18n.getString("script.cantCreateClass",


< prev index next >