Buggy code:
public class Accessible { static NSString [ ] baseAttributes = new NSString [ ] { OS . NSAccessibilityRoleAttribute , OS . NSAccessibilityRoleDescriptionAttribute , OS . NSAccessibilityHelpAttribute , OS . NSAccessibilityFocusedAttribute , OS . NSAccessibilityParentAttribute , OS . NSAccessibilityChildrenAttribute , OS . NSAccessibilityPositionAttribute , OS . NSAccessibilitySizeAttribute , OS . NSAccessibilityWindowAttribute , OS . NSAccessibilityTopLevelUIElementAttribute } ; static NSString [ ] baseTextAttributes = new NSString [ ] { OS . NSAccessibilityNumberOfCharactersAttribute , OS . NSAccessibilitySelectedTextAttribute , OS . NSAccessibilitySelectedTextRangeAttribute , OS . NSAccessibilityInsertionPointLineNumberAttribute , OS . NSAccessibilitySelectedTextRangesAttribute , OS . NSAccessibilityVisibleCharacterRangeAttribute , OS . NSAccessibilityValueAttribute } ; static NSString [ ] baseParameterizedAttributes = new NSString [ ] { OS . NSAccessibilityStringForRangeParameterizedAttribute , OS . NSAccessibilityRangeForLineParameterizedAttribute } ; NSMutableArray attributeNames = null ; NSMutableArray parameterizedAttributeNames = null ; NSMutableArray actionNames = null ; Vector accessibleListeners = new Vector ( ) ; Vector accessibleControlListeners = new Vector ( ) ; Vector accessibleTextListeners = new Vector ( ) ; Control control ; Map children = new HashMap ( ) ; Accessible ( Control control ) { } public static Accessible internal_new_Accessible ( Control control ) { } public void addAccessibleListener ( AccessibleListener listener ) { } public void addAccessibleControlListener ( AccessibleControlListener listener ) { } public void addAccessibleTextListener ( AccessibleTextListener listener ) { } public id internal_accessibilityActionDescription ( NSString action , int childID ) { } public NSArray internal_accessibilityActionNames ( int childID ) { } public NSArray internal_accessibilityAttributeNames ( int childID ) { } public id internal_accessibilityAttributeValue ( NSString attribute , int childID ) { } public id internal_accessibilityAttributeValue_forParameter ( NSString attribute , id parameter , int childID ) { } public id internal_accessibilityFocusedUIElement ( int childID ) { } public id internal_accessibilityHitTest ( NSPoint point , int childID ) { } public boolean internal_accessibilityIsAttributeSettable ( NSString attribute , int childID ) { } public boolean internal_accessibilityIsIgnored ( int childID ) { } public NSArray internal_accessibilityParameterizedAttributeNames ( int childID ) { } public void internal_accessibilityPerformAction ( NSString action , int childID ) { } public Control getControl ( ) { } public void internal_dispose_Accessible ( ) { } id getExpandedAttribute ( int childID ) { } id getHelpAttribute ( int childID ) { } NSString getRoleAttribute ( int childID ) { } id getSubroleAttribute ( int childID ) { } id getRoleDescriptionAttribute ( int childID ) { } id getTitleAttribute ( int childID ) { } id getValueAttribute ( int childID ) { } id getEnabledAttribute ( int childID ) { } id getFocusedAttribute ( int childID ) { } id getParentAttribute ( int childID ) { } id getChildrenAttribute ( int childID ) { } id getTabsAttribute ( int childID ) { } id getWindowAttribute ( int childID ) { } id getTopLevelUIElementAttribute ( int childID ) { } id getPositionAttribute ( int childID ) { } id getSizeAttribute ( int childID ) { } id getDescriptionAttribute ( int childID ) { } id getInsertionPointLineNumberAttribute ( int childID ) { } id getNumberOfCharactersAttribute ( int childID ) { } id getRangeForLineParameterizedAttribute ( id parameter , int childID ) { } id getSelectedTextAttribute ( int childID ) { } id getSelectedTextRangeAttribute ( int childID ) { } id getStringForRangeAttribute ( id parameter , int childID ) { id returnValue = null ; NSValue parameterObject = new NSValue ( parameter . id ) ; NSRange range = parameterObject . rangeValue ( ) ; AccessibleControlEvent event = new AccessibleControlEvent ( this ) ; event . childID = childID ; event . result = null ; for ( int i = 0 ; i < ( accessibleControlListeners . size ( ) ) ; i ++ ) { AccessibleControlListener listener = ( ( AccessibleControlListener ) ( accessibleControlListeners . elementAt ( i ) ) ) ; listener . getValue ( event ) ; } String appValue = event . result ; if ( appValue != null ) { <START_BUG> returnValue = NSString . stringWith ( appValue . substring ( range . location , ( ( range . location ) + ( range . length ) ) ) ) ; <END_BUG> } return returnValue ; } id getSelectedTextRangesAttribute ( int childID ) { } id getVisibleCharacterRangeAttribute ( int childID ) { } int lineNumberForOffset ( String text , int offset ) { } NSRange rangeForLineNumber ( int lineNumber , String text ) { } public void removeAccessibleListener ( AccessibleListener listener ) { } public void removeAccessibleControlListener ( AccessibleControlListener listener ) { } public void removeAccessibleTextListener ( AccessibleTextListener listener ) { } static NSArray retainedAutoreleased ( NSArray inObject ) { } public void selectionChanged ( ) { } public void setFocus ( int childID ) { } public void textCaretMoved ( int index ) { } public void textChanged ( int type , int startIndex , int length ) { } public void textSelectionChanged ( ) { } id childIDToOs ( int childID ) { } NSString concatStringsAsRole ( NSString str1 , NSString str2 ) { } String roleToOs ( int role ) { } int osToRole ( NSString osRole ) { } void checkWidget ( ) { } boolean isValidThread ( ) { } }

Fix:
returnValue = NSString . stringWith ( appValue . substring ( ( ( int ) ( range . location ) ) , ( ( int ) ( ( range . location ) + ( range . length ) ) ) ) ) ;