Buggy code:
public abstract class JavaElement extends PlatformObject implements IJavaElement { public static final char JEM_JAVAPROJECT = '=' ; public static final char JEM_PACKAGEFRAGMENTROOT = Path . SEPARATOR ; public static final char JEM_PACKAGEFRAGMENT = '<' ; public static final char JEM_FIELD = '^' ; public static final char JEM_METHOD = '~' ; public static final char JEM_INITIALIZER = '|' ; public static final char JEM_COMPILATIONUNIT = '{' ; public static final char JEM_CLASSFILE = '(' ; public static final char JEM_TYPE = '[' ; public static final char JEM_PACKAGEDECLARATION = '%' ; public static final char JEM_IMPORTDECLARATION = '#' ; protected int fOccurrenceCount = 1 ; protected int fLEType = 0 ; protected IJavaElement fParent ; protected String fName ; protected static JavaModelManager fgJavaModelManager = JavaModelManager . getJavaModelManager ( ) ; protected static final Object NO_INFO = new Object ( ) ; protected JavaElement ( int type , IJavaElement parent , String name ) throws IllegalArgumentException { } public void close ( ) throws JavaModelException { } protected void closing ( Object info ) throws JavaModelException { } public boolean equals ( Object o ) { } protected boolean equalsDOMNode ( IDOMNode node ) throws JavaModelException { } public boolean exists ( ) { } public IDOMNode findNode ( IDOMCompilationUnit dom ) { } protected IDOMNode followPath ( ArrayList path , int position , IDOMNode node ) { } public IJavaElement getAncestor ( int ancestorType ) { } public IJavaElement [ ] getChildren ( ) throws JavaModelException { } public ArrayList getChildrenOfType ( int type ) throws JavaModelException { } public IClassFile getClassFile ( ) { } public ICompilationUnit getCompilationUnit ( ) { } public JavaElementInfo getElementInfo ( ) throws JavaModelException { } public String getElementName ( ) { } public int getElementType ( ) { } public String getHandleIdentifier ( ) { } public String getHandleMemento ( ) { } protected abstract char getHandleMementoDelimiter ( ) { } public IJavaModel getJavaModel ( ) { } public JavaModelManager getJavaModelManager ( ) { } public IJavaProject getJavaProject ( ) { } protected int getOccurrenceCount ( ) { } public IOpenable getOpenable ( ) { } public IOpenable getOpenableParent ( ) { } public IJavaElement getParent ( ) { } public Object getRawInfo ( ) throws JavaModelException { } protected IJavaElement getSourceElementAt ( int position ) throws JavaModelException { if ( ( this ) instanceof ISourceReference ) { IJavaElement [ ] children = getChildren ( ) ; int i ; for ( i = 0 ; i < ( children . length ) ; i ++ ) { IJavaElement aChild = children [ i ] ; if ( aChild instanceof SourceRefElement ) { SourceRefElement child = ( ( SourceRefElement ) ( children [ i ] ) ) ; ISourceRange range = child . getSourceRange ( ) ; if ( ( position < ( ( range . getOffset ( ) ) + ( range . getLength ( ) ) ) ) && ( position >= ( range . getOffset ( ) ) ) ) { <START_BUG> if ( ( child . getElementType ( ) ) == ( IJavaElement . TYPE ) ) { <END_BUG> return child . getSourceElementAt ( position ) ; } else { return child ; } } } } } else { Assert . isTrue ( false ) ; } return this ; } public SourceMapper getSourceMapper ( ) { } public abstract IResource getUnderlyingResource ( ) throws JavaModelException { } public IWorkspace getWorkspace ( ) { } public int hashCode ( ) { } protected boolean isAncestorOf ( IJavaElement e ) { } public boolean isReadOnly ( ) { } public boolean isStructureKnown ( ) throws JavaModelException { } protected JavaModelException newNotPresentException ( ) { } public void offsetSourceEndAndChildren ( int amount , IJavaElement child ) { } public void offsetSourceRange ( int amount ) { } protected void openHierarchy ( ) throws JavaModelException { } protected void opening ( Object info ) { } public String readableName ( ) { } protected void removeInfo ( ) { } public abstract IJavaElement rootedAt ( IJavaProject project ) { } protected void runOperation ( JavaModelOperation operation , IProgressMonitor monitor ) throws JavaModelException { } protected void setOccurrenceCount ( int count ) { } protected String tabString ( int tab ) { } public String toDebugString ( ) { } public String toString ( ) { } protected void toString ( int tab , StringBuffer buffer ) { } public String toStringWithAncestors ( ) { } protected void toStringAncestors ( StringBuffer buffer ) { } protected void toStringChildren ( int tab , StringBuffer buffer , Object info ) { } public Object toStringInfo ( int tab , StringBuffer buffer ) { } protected void toStringInfo ( int tab , StringBuffer buffer , Object info ) { } public void triggerSourceEndOffset ( int amount , int nameStart , int nameEnd ) { } public void triggerSourceRangeOffset ( int amount , int nameStart , int nameEnd ) { } }

Fix:
if ( child instanceof IParent ) {