@@ -69,7 +69,8 @@ public static String execute(String generatedClassName, String code) throws Exce
6969 boolean hasMain = false ;
7070
7171 for (int j = 0 ; j < classes .get (i ).getMethods ().size (); j ++) {
72- if (classes .get (i ).getMethods ().get (j ).getName ().equals ("main" )) {
72+ if (classes .get (i ).getMethods ().get (j ).getName ().equals ("main" ) && classes .get (i )
73+ .getMethods ().get (j ).getModifiers ().toString ().contains ("static" )) {
7374 mainClassName = classes .get (i ).getName ();
7475 hasMain = true ;
7576 break ;
@@ -83,8 +84,9 @@ public static String execute(String generatedClassName, String code) throws Exce
8384
8485 // if there isn't Main method, will retuen error
8586 if (mainClassName == null ) {
86- logger .error ("Exception for Main method" , "There isn't any class containing Main method." );
87- throw new Exception ("There isn't any class containing Main method." );
87+ logger .error ("Exception for Main method" , "There isn't any class "
88+ + "containing static main method." );
89+ throw new Exception ("There isn't any class containing static main method." );
8890 }
8991
9092 // replace name of class containing Main method with generated name
@@ -152,7 +154,7 @@ public static String execute(String generatedClassName, String code) throws Exce
152154 logger .error ("Exception in Interpreter while execution" , e );
153155 System .err .println (e );
154156 e .printStackTrace (newErr );
155- throw new Exception (baosErr .toString ());
157+ throw new Exception (baosErr .toString (), e );
156158
157159 } finally {
158160
0 commit comments