Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Incremental Compilation problems.


Thanks to Wes for putting Miks initial changes into aspectj.  I'm now trying to get incremental working under AJDT - with mixed results.  The first job was exposing the option to set incremental compilation on/off - which I did by extending (in aspectj) ProjectPropertiesAdapter and enhancing CompilerAdapter.configureProjectOptions - if we think thats the right way to do it, I'll post a patch.

But, on to the important stuff.  Now I've got a configuration option at the project level for incremental.  It seems to actually work in terms of building a new system incrementally - but the outline view is a bit shaky.  Sometimes it goes blank (showing 'compile to view structure'), but the worst thing I've been seeing is an NPE from this new bit of code in AsmBuilder.java.  The NPE is on the line 'child.getSourceLocation().getSourceFile().equals(file)':

// if the node already exists remove before adding
ProgramElementNode duplicate = null;        
for (Iterator itt = StructureModelManager.INSTANCE.getStructureModel().getRoot().getChildren().iterator(); itt.hasNext(); ) {
  ProgramElementNode child = (ProgramElementNode)itt.next();
  if (child.getSourceLocation().getSourceFile().equals(file)) {
    duplicate = child;
  }
}
if (duplicate != null) {
  StructureModelManager.INSTANCE.getStructureModel().getRoot().removeChild(duplicate);
}
StructureModelManager.INSTANCE.getStructureModel().getRoot().addChild(cuNode);

I instrumented it (in an ugly fashion) like this:

// if the node already exists remove before adding
ProgramElementNode duplicate = null;        
StructureNode sn = StructureModelManager.INSTANCE.getStructureModel().getRoot();
String info = new String(sn.toString()+" kind = "+sn.getKind());
for (Iterator itt = sn.getChildren().iterator(); itt.hasNext(); ) {
  ProgramElementNode child = (ProgramElementNode)itt.next();
  if (child==null) {
    System.err.println(">> root "+info+"   child is null");
  } else {
    if (child.getSourceLocation()==null)
      System.err.println(">> root "+info+"    child is "+child+" but sourceloc is null");
    else if (child.getSourceLocation().getSourceFile()==null)
      System.err.println(">> root "+info+"    child is "+child+" but sourcefile is null");
                         
    if (child.getSourceLocation().getSourceFile().equals(file)) {
      duplicate = child;
    }
  }
}
if (duplicate != null) {
  StructureModelManager.INSTANCE.getStructureModel().getRoot().removeChild(duplicate);
}
StructureModelManager.INSTANCE.getStructureModel().getRoot().addChild(cuNode);

And get these kinds of results out:

>> root default.lst  kind = java source file    child is figures but sourceloc is null
java.lang.NullPointerException
        at org.aspectj.ajdt.internal.core.builder.AsmBuilder.internalBuild(AsmBuilder.java:147)
        at org.aspectj.ajdt.internal.core.builder.AsmBuilder.build(AsmBuilder.java:64)
        at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.finishedCompilationUnit(EclipseFactory.java:303)
        at org.aspectj.ajdt.internal.compiler.AjCompiler.process(AjCompiler.java:67)
        at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:338)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:475)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild(AjBuildManager.java:210)
        at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:89)
        at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:213)


Is it right that default.lst is considered a java source file?  So far, I've only seen it blow up reporting .lst files as the node it has having problems with.

It goes wrong like this intermittently, and I've seen the NPE at the same line (obtaining the sourcefile) in the other place in AsmBuilder.java where this code fragment is duplicated.  The duplicate works at a particular node in the tree rather than the root.

cheers,
Andy.

Andy Clement
AJDT Development

Back to the top