Bug 113531 - NullPointerException during incremental compilation of aspect
Summary: NullPointerException during incremental compilation of aspect
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-24 09:22 EDT by Matthew Webster CLA
Modified: 2012-04-03 14:24 EDT (History)
2 users (show)

See Also:


Attachments
Test project (1.81 KB, application/octet-stream)
2005-10-24 09:25 EDT, Matthew Webster CLA
no flags Details
patch containing failing testcase (4.57 KB, patch)
2005-10-25 10:28 EDT, Helen Beeken CLA
aclement: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Webster CLA 2005-10-24 09:22:16 EDT
Eclipse 3.1.1
AJDT:   org.eclipse.aspectj_1.2.1.20050624095428

The NPE seems to occur during an incremental compilation if there is an 
outstanding error from a previous incremental compilation

java.lang.NullPointerException
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1015)
at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave
(AjCompilerAdapter.java:300)
at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling
(AjCompilerAdapter.java:178)
at 
org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspec
tj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:70)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile
(Compiler.java:367)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation
(AjBuildManager.java:759)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild
(AjBuildManager.java:249)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild
(AjBuildManager.java:158)
at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:117)
at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run
(AspectJBuildManager.java:191)

NullPointerException thrown: null

1. Create the attached project
2. Swap the commented lines in SwtThreadSafetey and incrementally compile 
(save). You will get an error
3. Create a new aspect in the default package
Comment 1 Matthew Webster CLA 2005-10-24 09:25:28 EDT
Created attachment 28680 [details]
Test project
Comment 2 Matt Chapman CLA 2005-10-24 09:33:00 EDT
Over the fence...
Comment 3 Helen Beeken CLA 2005-10-25 10:02:01 EDT
This bug is a duplicate of bug 112529.

I was able to reproduce the NPE with AJDT 1.3.0.20051003160848, however, not
with AJDT 1.3.0.20051019121930. The fix went into AspectJ on 20051014, so any
builds available on the AJDT download page should contain the fix.

The fix is actually to improve the exception handling, so rather than throwing
an NPE, throw a BCException with extra info. With the most recent AspectJ, the
exception you now get is:

!ENTRY org.eclipse.ajdt.ui 4 0 2005-10-25 11:40:16.883
!MESSAGE BCException thrown: Can't find bcel delegate for
ui.views.ViewsThreadSafety type=class org.aspectj.weaver.ReferenceType
when weaving aspects 
when weaving 
when incrementally building
BuildConfig[C:\eclipse_installations\aspectj\eclipse\runtime-workspace-20050923-testcaseInvestigation\.metadata\.plugins\org.eclipse.ajdt.core\websterm.generated.lst]
#Files=3

!STACK 0
org.aspectj.weaver.BCException: Can't find bcel delegate for
ui.views.ViewsThreadSafety type=class org.aspectj.weaver.ReferenceType
when weaving aspects 
when weaving 
when incrementally building
BuildConfig[C:\eclipse_installations\aspectj\eclipse\runtime-workspace-20050923-testcaseInvestigation\.metadata\.plugins\org.eclipse.ajdt.core\websterm.generated.lst]
#Files=3

	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1019)
	at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompilerAdapter.java:300)
	at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling(AjCompilerAdapter.java:178)
	at
org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:70)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:367)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:759)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:249)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild(AjBuildManager.java:158)
	at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:117)
	at
org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191)

Comment 4 Helen Beeken CLA 2005-10-25 10:28:32 EDT
Created attachment 28752 [details]
patch containing failing testcase

Apply the patch to the tests project.

This produces an exception of the form:

org.aspectj.weaver.BCException: Can't find bcel delegate for pack1.A1
type=class org.aspectj.weaver.ReferenceType
when weaving aspects 
when weaving 
when incrementally building
BuildConfig[C:\eclipse_installations\ajdt_3_1_0_development\eclipse\workspace-bugs20050818\.metadata\.plugins\org.eclipse.ajdt.core\test.generated.lst]
#Files=3

  at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1019)
  at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompilerAdapter.java:300)

  at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling(AjCompilerAdapter.java:178)

  at
org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:70)

  at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:367)

  at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:759)

  at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:249)

  at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild(AjBuildManager.java:158)

  at
org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:117)
  at
org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191)
Comment 5 Andrew Clement CLA 2005-10-25 11:13:18 EDT
excellent work Helen !  I still need to puzzle through what it means tho :(
Comment 6 Andrew Clement CLA 2005-11-07 06:22:36 EST
I've checked in the test patch from Helen.  Currently commented out in
MultiProjectIncrementalTests
Comment 7 Andrew Clement CLA 2005-11-11 13:23:00 EST
Right.  fix checked in.  when the compile error occurs on the intermediate
compile we are left with a referencetype containing an eclipse source type
(implementation of delegate) that records the errors - if there were no errors
it would have become a bcel delegate which can be woven.  On the third compile
we get hold of the reference type and ask for its bcel delegate - this return
NULL since it doesnt have one, it still has an eclipsesourcetype delegate. 
Given that we can only have not transformed it into a bcel delegate if there was
an error during compilation, I'm allowing the weaving process to skip weaving
the type for which it cant find the bcel delegate.  this works fine ;)

fix checked in.
Comment 8 Andrew Clement CLA 2005-11-12 13:54:22 EST
fix available.