You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/02/22 05:09:34 UTC

[GitHub] imatiach-msft commented on a change in pull request #23866: [SPARK-26963][MLLIB] SizeEstimator can't make some JDK fields accessible in Java 9+

imatiach-msft commented on a change in pull request #23866: [SPARK-26963][MLLIB] SizeEstimator can't make some JDK fields accessible in Java 9+
URL: https://github.com/apache/spark/pull/23866#discussion_r259214433
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/util/SizeEstimator.scala
 ##########
 @@ -334,9 +334,21 @@ object SizeEstimator extends Logging {
         if (fieldClass.isPrimitive) {
           sizeCount(primitiveSize(fieldClass)) += 1
         } else {
-          field.setAccessible(true) // Enable future get()'s on this field
+          // Note: in Java 9+ this would be better with trySetAccessible and canAccess
+          try {
+            field.setAccessible(true) // Enable future get()'s on this field
+            pointerFields = field :: pointerFields
+          } catch {
+            // If the field isn't accessible, we can still record the pointer size
+            // but can't know more about the field, so ignore it
+            case _: SecurityException =>
+              // do nothing
+            // Java 9+ can throw InaccessibleObjectException but the class is Java 9+-only
+            case re: RuntimeException
+                if re.getClass.getSimpleName == "InaccessibleObjectException" =>
 
 Review comment:
   minor comment/question: if it's not an InaccessibleObjectException, wouldn't it throw a case match error which might be confusing?  Just wondering if a default catch-all should re-raise the original "re: RuntimeException"

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org