-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-26963][MLLIB] SizeEstimator can't make some JDK fields accessible in Java 9+ #23866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" => | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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"
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The exception would just propagate, as before, if it's not matched by either case. That's what we want, if something else goes wrong. |
||
| // do nothing | ||
| } | ||
| sizeCount(pointerSize) += 1 | ||
| pointerFields = field :: pointerFields | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be inside the try:
it seems like we could still record it even if the setAccessible failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the point is that we don't want to try to access it below; it's not accessible