Buggy code:
private IClassFile getClassFile ( char [ ] fileName ) { } private ICompilationUnit getCompilationUnit ( char [ ] fileName ) { } public ITypeBinding getComponentType ( ) { } public IVariableBinding [ ] getDeclaredFields ( ) { } public IMethodBinding [ ] getDeclaredMethods ( ) { } public int getDeclaredModifiers ( ) { } public ITypeBinding [ ] getDeclaredTypes ( ) { } public IMethodBinding getDeclaringMethod ( ) { } public ITypeBinding getDeclaringClass ( ) { } public int getDimensions ( ) { } public ITypeBinding getElementType ( ) { } public ITypeBinding getTypeDeclaration ( ) { } public ITypeBinding getErasure ( ) { } public ITypeBinding [ ] getInterfaces ( ) { } public IJavaElement getJavaElement ( ) { } private JavaElement getUnresolvedJavaElement ( ) { } private JavaElement getUnresolvedJavaElement ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding ) { if ( typeBinding == null ) return null ; switch ( typeBinding . kind ( ) ) { case Binding . ARRAY_TYPE : typeBinding = ( ( ArrayBinding ) ( typeBinding ) ) . leafComponentType ( ) ; return getUnresolvedJavaElement ( typeBinding ) ; case Binding . BASE_TYPE : case Binding . WILDCARD_TYPE : return null ; default : if ( typeBinding . isCapture ( ) ) return null ; } ReferenceBinding referenceBinding ; if ( ( typeBinding . isParameterizedType ( ) ) || ( typeBinding . isRawType ( ) ) ) referenceBinding = ( ( ReferenceBinding ) ( typeBinding . erasure ( ) ) ) ; else referenceBinding = ( ( ReferenceBinding ) ( typeBinding ) ) ; char [ ] fileName = referenceBinding . getFileName ( ) ; if ( ( referenceBinding . isLocalType ( ) ) || ( referenceBinding . isAnonymousType ( ) ) ) { if ( Util . isClassFileName ( fileName ) ) { int jarSeparator = CharOperation . indexOf ( IDependent . JAR_FILE_ENTRY_SEPARATOR , fileName ) ; int pkgEnd = CharOperation . lastIndexOf ( '//' , fileName ) ; if ( pkgEnd == ( - 1 ) ) pkgEnd = CharOperation . lastIndexOf ( File . separatorChar , fileName ) ; if ( ( jarSeparator != ( - 1 ) ) && ( pkgEnd < jarSeparator ) ) pkgEnd = jarSeparator ; if ( pkgEnd == ( - 1 ) ) return null ; IPackageFragment pkg = getPackageFragment ( fileName , pkgEnd , jarSeparator ) ; char [ ] constantPoolName = referenceBinding . constantPoolName ( ) ; if ( constantPoolName == null ) { ClassFile classFile = ( ( ClassFile ) ( getClassFile ( fileName ) ) ) ; return classFile == null ? null : ( ( JavaElement ) ( classFile . getType ( ) ) ) ; } pkgEnd = CharOperation . lastIndexOf ( '//' , constantPoolName ) ; char [ ] classFileName = CharOperation . subarray ( constantPoolName , ( pkgEnd + 1 ) , constantPoolName . length ) ; ClassFile classFile = ( ( ClassFile ) ( pkg . getClassFile ( ( ( new String ( classFileName ) ) + ( SuffixConstants . SUFFIX_STRING_class ) ) ) ) ) ; return ( ( JavaElement ) ( classFile . getType ( ) ) ) ; } ICompilationUnit cu = getCompilationUnit ( fileName ) ; if ( cu == null ) return null ; try { int sourceStart = ( ( LocalTypeBinding ) ( referenceBinding ) ) . sourceStart ; return ( ( JavaElement ) ( cu . getElementAt ( sourceStart ) ) ) ; } catch ( JavaModelException e ) { return null ; } } else if ( referenceBinding . isTypeVariable ( ) ) { final String typeVariableName = new String ( referenceBinding . sourceName ( ) ) ; Binding declaringElement = ( ( TypeVariableBinding ) ( referenceBinding ) ) . declaringElement ; IBinding declaringTypeBinding = null ; if ( declaringElement instanceof MethodBinding ) { declaringTypeBinding = this . resolver . getMethodBinding ( ( ( MethodBinding ) ( declaringElement ) ) ) ; IMethod declaringMethod = ( ( IMethod ) ( declaringTypeBinding . getJavaElement ( ) ) ) ; return ( ( JavaElement ) ( declaringMethod . getTypeParameter ( typeVariableName ) ) ) ; } else { ITypeBinding typeBinding2 = this . resolver . getTypeBinding ( ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) ( declaringElement ) ) ) ; <START_BUG> if ( typeBinding == null ) <END_BUG> return null ; declaringTypeBinding = typeBinding2 ; IType declaringType = ( ( IType ) ( declaringTypeBinding . getJavaElement ( ) ) ) ; return ( ( JavaElement ) ( declaringType . getTypeParameter ( typeVariableName ) ) ) ; } } else { if ( fileName == null ) return null ; ITypeBinding declaringTypeBinding = null ; if ( this . isArray ( ) ) { declaringTypeBinding = this . getElementType ( ) . getDeclaringClass ( ) ; } else { declaringTypeBinding = this . getDeclaringClass ( ) ; } if ( declaringTypeBinding == null ) { if ( Util . isClassFileName ( fileName ) ) { ClassFile classFile = ( ( ClassFile ) ( getClassFile ( fileName ) ) ) ; if ( classFile == null ) return null ; return ( ( JavaElement ) ( classFile . getType ( ) ) ) ; } ICompilationUnit cu = getCompilationUnit ( fileName ) ; if ( cu == null ) return null ; return ( ( JavaElement ) ( cu . getType ( new String ( referenceBinding . sourceName ( ) ) ) ) ) ; } else { IType declaringType = ( ( IType ) ( declaringTypeBinding . getJavaElement ( ) ) ) ; if ( declaringType == null ) return null ; return ( ( JavaElement ) ( declaringType . getType ( new String ( referenceBinding . sourceName ( ) ) ) ) ) ; } } } public String getKey ( ) { } public int getKind ( ) { } public int getModifiers ( ) { }

Fix:
if ( typeBinding2 == null )