cptaffe 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_r356249967
 
 

 ##########
 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:
   I've added a test, but I couldn't get Hadoop to run locally—seeing this 
error:
   
   ```
   Plugin org.apache.hadoop:hadoop-maven-plugins:3.3.0-SNAPSHOT or one of its 
dependencies could not be resolved: Could not find artifact 
org.apache.hadoop:hadoop-maven-plugins:jar:3.3.0-SNAPSHOT
   ```
   
   Guidance from the [Dev Environment 
Setup](https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute#HowToContribute-DevEnvironmentSetup)
 was no help unfortunately. The suggested docker script also fails to build.

----------------------------------------------------------------
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