Project: AspectJ
Bug 59596 Null pointer exception while weaving java.awt.Label
Reported: 2004-04-22 05:11:34 | Status: resolved fixed

I tried to add an Aspect to java.awt.Label. I compile the aspect via: ajc -inpath /usr/local/j2sdk_nb/j2sdk1.4.2/jre/lib/rt.jar Timestamp.java Here is the aspect Timestamp.java: aspect Timestamp { private int java.awt.Label._ts_read = 0; private int java.awt.Label._ts_write = 0; pointcut writeOp(): call (void java.awt.Label.setText (String)); pointcut readOp(): call (String java.awt.Label.getText()); after (java.awt.Label b) returning: readOp() && target (b) { b._ts_read++; } after (java.awt.Label b) returning: writeOp() && target (b) { b._ts_write++; System.out.println (b._ts_write); } public static void main (String[] args) { java.awt.Label b1 = new java.awt.Label(); b1.setText ("abc"); } } Here is the error message I get from ajc: null java.lang.NullPointerException at org.aspectj.ajdt.internal.core.builder.EclipseAdapterUtils.makeLocationContext(EclipseAdapterUtils.java:50) at org.aspectj.ajdt.internal.core.builder.EclipseAdapterUtils.makeSourceLocation(EclipseAdapterUtils.java:120) at org.aspectj.ajdt.internal.core.builder.EclipseAdapterUtils.makeMessage(EclipseAdapterUtils.java:129) at org.aspectj.ajdt.internal.core.builder.AjBuildManager$4.acceptResult(AjBuildManager.java:663) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.acceptResult(AjCompilerAdapter.java:178) at org.aspectj.ajdt.internal.compiler.WeaverAdapter.finishedWith(WeaverAdapter.java:203) at org.aspectj.ajdt.internal.compiler.WeaverAdapter.weaveCompleted(WeaverAdapter.java:167) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:570) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompilerAdapter.java:239) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling(AjCompilerAdapter.java:114) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:376) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:600) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:160) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:94) at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:102) at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:53) at org.aspectj.tools.ajc.Main.run(Main.java:280) at org.aspectj.tools.ajc.Main.runMain(Main.java:217) at org.aspectj.tools.ajc.Main.main(Main.java:79) 1 fail|abort

Files changed in fix:
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java