srowen commented on a change in pull request #23896: [SPARK-26977][CORE] Fix 
warn against subclassing scala.App
URL: https://github.com/apache/spark/pull/23896#discussion_r260343343
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
 ##########
 @@ -828,9 +828,12 @@ private[spark] class SparkSubmit extends Logging {
     val app: SparkApplication = if 
(classOf[SparkApplication].isAssignableFrom(mainClass)) {
       mainClass.newInstance().asInstanceOf[SparkApplication]
     } else {
-      // SPARK-4170
-      if (classOf[scala.App].isAssignableFrom(mainClass)) {
-        logWarning("Subclasses of scala.App may not work correctly. Use a 
main() method instead.")
+      // SPARK-4170, SPARK-26977
+      Try {
+        if 
(classOf[scala.App].isAssignableFrom(Utils.classForName(s"$childMainClass$$"))) 
{
+          logWarning("Subclasses of scala.App may not work correctly. " +
+            "Use a main() method instead.")
+        }
 
 Review comment:
   Oh nevermind me, I think the way this displays just made it look like the 
brace was misaligned.
   
   If the new check throws ClassNotFoundException, then that's fine, you just 
do nothing. It doesn't match the condition we're trying to detect.
   
   I think I'm still confused from the discussion at 
https://github.com/apache/spark/pull/3497#pullrequestreview-205672379
   
   If I specify a main class "com.foo.MyApp" and `class com.foo.MyApp exends 
scala.App`, then there will be a class of that name in the bytecode that 
extends `scala.App`, right? It can have static methods, and unless this whole 
thing just never worked, it has a main() method, that we call -- Scala makes a 
synthetic method that forwards or whatever.
   
   I understand `object` is a potentially different case but don't you just 
need to look for `com.foo.MyApp$`? I wasn't getting the dependence on 
`childMainClass` here; that seems like a Scala implementation detail that's 
unnecessary to look for.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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