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

Add NoSuchMethodError section to troubleshooting guide #2300

Merged
merged 3 commits into from
Jan 16, 2023

Conversation

Marcono1234
Copy link
Collaborator

Inspired by #2296 and similar questions on Stack Overflow

@@ -189,4 +191,22 @@ If you want to prevent using reflection on third-party classes in the future you

**Reason:** You used `GsonBuilder.excludeFieldsWithModifiers` to overwrite the default excluded modifiers

**Solution:** When calling `GsonBuilder.excludeFieldsWithModifiers` you overwrite the default excluded modifiers. Therefore, you have to explicitly exclude `static` fields if desired. This can be done by adding `| Modifier.STATIC` to the argument.
**Solution:** When calling `GsonBuilder.excludeFieldsWithModifiers` you overwrite the default excluded modifiers. Therefore, you have to explicitly exclude `static` fields if desired. This can be done by adding `Modifier.STATIC` as additional argument.
Copy link
Collaborator Author

@Marcono1234 Marcono1234 Jan 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed this because I forgot to consider that the parameter of excludeFieldsWithModifiers is varargs so it is easier to just pass Modifier.STATIC as separate argument than having to do bitwise operations.

Copy link
Member

@eamonnmcmanus eamonnmcmanus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just one small thing...

Troubleshooting.md Outdated Show resolved Hide resolved
@eamonnmcmanus eamonnmcmanus merged commit d7fb0e4 into google:master Jan 16, 2023
@Marcono1234 Marcono1234 deleted the patch-3 branch January 16, 2023 00:56
tibor-universe pushed a commit to getuniverse/gson that referenced this pull request Jan 20, 2023
* Mention exclusion of fields in troubleshooting guide

* Add `NoSuchMethodError` section to troubleshooting guide

* Add missing word

(cherry picked from commit d7fb0e4)
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.

2 participants