1 /* 2 HiddenField 3 ignoreFormat = (default)null 4 ignoreConstructorParameter = (default)false 5 ignoreSetter = (default)false 6 setterCanReturnItsClass = (default)false 7 ignoreAbstractMethods = (default)false 8 tokens = (default)VARIABLE_DEF, PARAMETER_DEF, PATTERN_VARIABLE_DEF, LAMBDA, RECORD_COMPONENT_DEF 9 10 11 */ 12 13 package com.puppycrawl.tools.checkstyle.checks.coding.hiddenfield; 14 15 import java.util.Comparator; 16 17 public class InputHiddenFieldStaticVisibility { 18 static int someField; 19 static Object other = null; 20 Object field = null; 21 22 static void method(Object field, Object other) { // violation, ''other' hides a field' 23 // field 'field' can not be referenced form a static context 24 // static field 'other' can be referenced from a static context 25 } 26 27 static class B { 28 void method(Object field, Object other) { // violation, ''other' hides a field' 29 // field 'field' can not be referenced form a static context 30 // static field 'other' can be referenced from a static context 31 } 32 } 33 34 static Comparator<Object> COMP = new Comparator<Object>() { 35 @Override 36 public int compare(Object field, Object other) { // violation, ''other' hides a field' 37 // field 'field' can not be referenced form a static context 38 // static field 'other' can be referenced from a static context 39 return 0; 40 } 41 }; 42 43 static Comparator<Object> createComp() { 44 return new Comparator<Object>() { 45 @Override 46 public int compare(Object field, Object other) { // violation, ''other' hides a field' 47 // field 'field' can not be referenced form a static context 48 // static field 'other' can be referenced from a static context 49 return 0; 50 } 51 }; 52 } 53 54 static void foo1(int a) {} 55 56 void foo2(int a) {} 57 58 static void foo3(int someField) {} // violation, ''someField' hides a field' 59 }