Skip to content

Commit

Permalink
Refactory visibility code for better clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Merlo committed Jan 24, 2022
1 parent 3822243 commit c60bf15
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,22 @@ 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;
boolean visible = isVisible(member.getModifiers());

//Due to recent changes involving reflection access to base java classes,
//we need to perform an additional check to ensure that members belonging
//to java/javax packages are public. Non-public members will always be considered not visible
if(visible){
Class<?> clazz = member.getDeclaringClass();
String className = clazz.getName();
if(className.startsWith("java.") || className.startsWith("javax.")){
if(!Modifier.isPublic(member.getModifiers())){
visible = false;
}
}
}

return isVisible(member.getModifiers());
return visible;
}

public final boolean isVisible(int modifiers) {
Expand Down

0 comments on commit c60bf15

Please sign in to comment.