Skip to content
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

Merged
merged 1 commit into from Apr 22, 2016

Conversation

ionspin
Copy link

@ionspin ionspin commented Apr 14, 2016

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.

@@ -0,0 +1,79 @@
/*
* Copyright (C) 2016 Ugljesa Jovanovic
Copy link
Collaborator

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

@swankjesse
Copy link
Collaborator

Looks good but I’ve got some comments

@ionspin
Copy link
Author

ionspin commented Apr 20, 2016

@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) {
Copy link
Collaborator

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.

@swankjesse
Copy link
Collaborator

LGTM!

@swankjesse
Copy link
Collaborator

Yes, please squash into one commit.

@ionspin
Copy link
Author

ionspin commented Apr 20, 2016

@swankjesse Done! Thanks for the comments!

@swankjesse swankjesse merged commit 0f66f4f into google:master Apr 22, 2016
@swankjesse
Copy link
Collaborator

Thanks!

sebasjm pushed a commit to sebasjm/gson that referenced this pull request Mar 11, 2018
Check if class can be instantiated based on class modifiers. Fix for google#817
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants