goiri commented on a change in pull request #1751: MAPREDUCE-7251: Present 
friendlier error for non-static main
URL: https://github.com/apache/hadoop/pull/1751#discussion_r356185943
 
 

 ##########
 File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/RunJar.java
 ##########
 @@ -315,6 +316,11 @@ public void run() {
     Thread.currentThread().setContextClassLoader(loader);
     Class<?> mainClass = Class.forName(mainClassName, true, loader);
     Method main = mainClass.getMethod("main", String[].class);
+    
+    if (!Modifier.isStatic(main.getModifiers())) {
+      throw new IOException("Method main must be static: " + mainClassName);
 
 Review comment:
   Can we add a unit test to make sure we trigger this instead of NPE?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to