Buggy code:
public class AspectDeclaration extends TypeDeclaration { private Aspect aspectAttribute ; public PerClause perClause ; public ResolvedMember aspectOfMethod ; public ResolvedMember hasAspectMethod ; public Map accessForInline = new HashMap ( ) ; public Map superAccessForInline = new HashMap ( ) ; public boolean isPrivileged ; private int declaredModifiers ; public EclipseSourceType concreteName ; public ReferenceType typeX ; public EclipseFactory factory ; public int adviceCounter = 1 ; public int declareCounter = 1 ; public TypePattern dominatesPattern ; public AspectDeclaration ( CompilationResult compilationResult ) { } public boolean isAbstract ( ) { } public void resolve ( ) { } public void checkSpec ( ClassScope scope ) { } private FieldBinding initFailureField = null ; public void addAtAspectJAnnotations ( ) { } public void generateCode ( ClassFile enclosingClassFile ) { } public boolean needClassInitMethod ( ) { } protected void generateAttributes ( ClassFile classFile ) { } private void addVersionAttributeIfNecessary ( ClassFile classFile ) { } private static char [ ] weaverVersionChars = "org.aspectj.weaver.WeaverVersion" . toCharArray ( ) ; private void generateInlineAccessMembers ( ClassFile classFile ) { } private void generatePerSupportMembers ( ClassFile classFile ) { } private static interface BodyGenerator { public void generate ( CodeStream codeStream ) { } } private void generateMethod ( ClassFile classFile , ResolvedMember member , AspectDeclaration . BodyGenerator gen ) { } private void generateMethod ( ClassFile classFile , MethodBinding methodBinding , AspectDeclaration . BodyGenerator gen ) { } protected List makeEffectiveSignatureAttribute ( ResolvedMember sig , Shadow . Kind kind , boolean weaveBody ) { } private void generateMethod ( ClassFile classFile , MethodBinding methodBinding , List additionalAttributes , AspectDeclaration . BodyGenerator gen ) { } private void generatePerCflowAspectOfMethod ( ClassFile classFile ) { } private void generatePerCflowHasAspectMethod ( ClassFile classFile ) { } private void generatePerCflowPushMethod ( ClassFile classFile ) { } private void generatePerCflowAjcClinitMethod ( ClassFile classFile ) { } private TypeBinding generatePerObjectInterface ( ClassFile classFile ) { } private void generatePerTypeWithinAspectOfMethod ( ClassFile classFile ) { } private void generatePerObjectAspectOfMethod ( ClassFile classFile , final TypeBinding interfaceType ) { } private void generatePerObjectHasAspectMethod ( ClassFile classFile , final TypeBinding interfaceType ) { } private void generatePerTypeWithinHasAspectMethod ( ClassFile classFile ) { } private void generatePerObjectBindMethod ( ClassFile classFile , final TypeBinding interfaceType ) { } private void generatePerTypeWithinGetInstanceMethod ( ClassFile classFile ) { } private void generatePerTypeWithinCreateAspectInstanceMethod ( ClassFile classFile ) { } private void generatePerSingletonAspectOfMethod ( ClassFile classFile ) { } private void generatePerSingletonHasAspectMethod ( ClassFile classFile ) { } private void generatePerSingletonAjcClinitMethod ( ClassFile classFile ) { } private void generateSuperAccessMethod ( ClassFile classFile , final MethodBinding accessMethod , final ResolvedMember method ) { } private void generateInlineAccessMethod ( ClassFile classFile , final Binding binding , final ResolvedMember member ) { } private void generateInlineAccessors ( ClassFile classFile , final InlineAccessFieldBinding accessField , final ResolvedMember field ) { } private void generateInlineAccessMethod ( ClassFile classFile , final MethodBinding accessMethod , final ResolvedMember method ) { } private Kind lookupPerClauseKind ( ReferenceBinding binding ) { PerClause perClause ; if ( binding instanceof BinaryTypeBinding ) { ResolvedType superTypeX = factory . fromEclipse ( binding ) ; perClause = superTypeX . getPerClause ( ) ; } else if ( binding instanceof SourceTypeBinding ) { SourceTypeBinding sourceSc = ( ( SourceTypeBinding ) ( binding ) ) ; if ( ( sourceSc . scope . referenceContext ) instanceof AspectDeclaration ) { perClause = ( ( AspectDeclaration ) ( sourceSc . scope . referenceContext ) ) . perClause ; } else { return null ; } } else if ( binding instanceof ParameterizedTypeBinding ) { ParameterizedTypeBinding pBinding = ( ( ParameterizedTypeBinding ) ( binding ) ) ; if ( ( pBinding . type ) instanceof SourceTypeBinding ) { SourceTypeBinding sourceSc = ( ( SourceTypeBinding ) ( pBinding . type ) ) ; <START_BUG> if ( ( sourceSc . scope . referenceContext ) instanceof AspectDeclaration ) { <END_BUG> perClause = ( ( AspectDeclaration ) ( sourceSc . scope . referenceContext ) ) . perClause ; } else { return null ; } } else { perClause = null ; } } else { return null ; } if ( perClause == null ) { return lookupPerClauseKind ( binding . superclass ( ) ) ; } else { return perClause . getKind ( ) ; } } private void buildPerClause ( ClassScope scope ) { } private PerClause resolvePerClause ( ) { } public void buildInterTypeAndPerClause ( ClassScope classScope ) { } public StringBuffer printHeader ( int indent , StringBuffer output ) { } public int getDeclaredModifiers ( ) { } }

Fix:
if ( ( ( sourceSc . scope ) != null ) && ( ( sourceSc . scope . referenceContext ) instanceof AspectDeclaration ) ) {