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
Check if class can be instantiated based on class modifiers. Fix for #817 #829
Conversation
@@ -0,0 +1,79 @@ | |||
/* | |||
* Copyright (C) 2016 Ugljesa Jovanovic |
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.
Sorry, we won’t accept pull requests unless you assign copyright to either Google or Gson Authors. (We don’t want to have to get your permission later if we need to change the license of the whole project.)
Looks good but I’ve got some comments |
@swankjesse Should I squash this into one commit? |
* throw an {@link java.lang.UnsupportedOperationException} | ||
* @param c instance of the class to be checked | ||
*/ | ||
private static void assertInstantiable(Class c) { |
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.
supernit: should be Class<?>
because Class
is a raw type.
LGTM! |
Yes, please squash into one commit. |
…hrow an unsupported operation exception.
@swankjesse Done! Thanks for the comments! |
Thanks! |
Check if class can be instantiated based on class modifiers. Fix for google#817
If class can't be instantiated throw an unsupported operation exception. On different android devices attempt to instantiate interface or abstract class would crash the VM sometimes with only a segmentation fault message and no other useful logs (Issue #817). Checking for interface or abstract class modifiers before trying to allocate instance and throwing an exception will help debugging.