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

Ignore non public members for base java classes #177

Merged
merged 3 commits into from
Jan 25, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ public VisibilityFilter(int... modifier) {
* @return true if this member is visible according to this filter.
*/
public final boolean isVisible(Member member) {
Class<?> clazz = member.getDeclaringClass();
String className = clazz.getName();
if(className.startsWith("java.") || className.startsWith("javax.")){
if(!Modifier.isPublic(member.getModifiers())){
return false;
}
}

return isVisible(member.getModifiers());
Copy link
Contributor

Choose a reason for hiding this comment

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

You forgot to include what I mentioned in the other PR, you want to leverage the same filter as isVisible. Otherwise this will include all fields/methods that are public. Some might be static, transient, etc, these shouldn't be included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is slightly different from the other PR. The main difference being the ! in front of Modifiers.isPublic. In this PR, any non-public field in a base class is excluded. Otherwise, we perform the additional call to isVisible (line 81)

The previous PR was automatically including all public fields in base classes without considering the additional filters. I can see how this might not be the clearest code however. I will modify the PR to be a bit more clear

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops my bad! Thanks for the explanation.

}

Expand Down