Buggy code:
public class TrimArea { private class TrimLine { List controls = new ArrayList ( ) ; int minorMax ; int resizableCount ; int availableSpace ; public TrimLine ( int majorHint ) { } void addControl ( Control ctrl , int tileLength , int minorSize , Control dragHandle ) { } int terminate ( ) { } } private static final IWindowTrim defaultData = new WindowTrimProxy ( null , null , null , 0 , true ) ; private static IWindowTrim getData ( Control control ) { } private int fId ; private String fDisplayName ; private List lines = new ArrayList ( ) ; private ArrayList fTrim ; private static final String PREFSIZE_DATA_ID = "prefSize" ; private static final int MIN_BANNER_LEFT = 150 ; private static int TILE_SPACING = 2 ; private static int LINE_SPACING = 2 ; private Rectangle curRect = new Rectangle ( 0 , 0 , 0 , 0 ) ; public TrimArea ( int id , String displayName ) { } public boolean isEmpty ( ) { } public Rectangle getCurRect ( ) { } public List getTrims ( ) { } public List getDescriptors ( ) { } private Point getPrefSize ( Control ctrl ) { } public int computeWrappedTrim ( int majorHint ) { int totalMinor = 0 ; lines . clear ( ) ; boolean isHorizontal = ! ( isVertical ( ) ) ; TrimArea . TrimLine curLine = new TrimArea . TrimLine ( majorHint ) ; lines . add ( curLine ) ; TrimCommonUIHandle dragHandle = null ; List caches = getCaches ( ) ; for ( Iterator cacheIter = caches . iterator ( ) ; cacheIter . hasNext ( ) ; ) { SizeCache cache = ( ( SizeCache ) ( cacheIter . next ( ) ) ) ; Control ctrl = cache . getControl ( ) ; <START_BUG> if ( ( ctrl == null ) || ( ! ( ctrl . isVisible ( ) ) ) ) <END_BUG> continue ; if ( ctrl instanceof TrimCommonUIHandle ) { dragHandle = ( ( TrimCommonUIHandle ) ( ctrl ) ) ; Point dhSize = dragHandle . getSize ( ) ; if ( ( ( dhSize . x ) == 0 ) || ( ( dhSize . y ) == 0 ) ) dragHandle . setSize ( dragHandle . computeSize ( DEFAULT , DEFAULT ) ) ; continue ; } Point prefSize = getPrefSize ( ctrl ) ; int tileLength = ( isHorizontal ) ? prefSize . x : prefSize . y ; int minorSize = ( isHorizontal ) ? prefSize . y : prefSize . x ; if ( dragHandle != null ) { Point dhSize = dragHandle . getSize ( ) ; tileLength += ( isHorizontal ) ? dhSize . x : dhSize . y ; } tileLength += TrimArea . TILE_SPACING ; if ( ( tileLength < ( curLine . availableSpace ) ) || ( ( curLine . controls . size ( ) ) == 0 ) ) { curLine . addControl ( ctrl , tileLength , minorSize , dragHandle ) ; } else { totalMinor += curLine . terminate ( ) ; curLine = new TrimArea . TrimLine ( majorHint ) ; lines . add ( curLine ) ; curLine . addControl ( ctrl , tileLength , minorSize , dragHandle ) ; } dragHandle = null ; } totalMinor += curLine . terminate ( ) ; totalMinor += ( ( lines . size ( ) ) + 1 ) * ( TrimArea . LINE_SPACING ) ; return totalMinor ; } static int tileCount = 0 ; public void tileTrim ( int anchorX , int anchorY , int major ) { } public boolean isVertical ( ) { } public int getId ( ) { } public String getDisplayName ( ) { } public void addTrim ( TrimDescriptor desc ) { } public void addTrim ( TrimDescriptor desc , TrimDescriptor beforeMe ) { } public void removeTrim ( TrimDescriptor desc ) { } public boolean contains ( TrimDescriptor desc ) { } public List getCaches ( ) { } }

Fix:
if ( ( ctrl == null ) || ( ! ( ctrl . getVisible ( ) ) ) )