Bug 227455 - NPE with declare parents and unimplemented abstract method
Summary: NPE with declare parents and unimplemented abstract method
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.6.0   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-16 19:39 EDT by Martin Bravenboer CLA
Modified: 2008-04-24 00:01 EDT (History)
1 user (show)

See Also:


Attachments
Core dump (8.20 KB, text/plain)
2008-04-16 19:39 EDT, Martin Bravenboer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Bravenboer CLA 2008-04-16 19:39:05 EDT
Created attachment 96362 [details]
Core dump

ajc 1.5.4 reports an internal compiler error for an abstract method that is not implemented.

Given:
------------------------------------
public interface FigureElement {
  public void moveBy(int dx, int dy);
}

public class Point implements FigureElement {
  private int x = 0, y = 0;
  
  Point(int x, int y) {
    super();
    this.x = x;
    this.y = y;
  }
 
  public void moveBy(int dx, int dy) {
    x += dx;
    y += dy;
  }

  public String toString() {
    return "(" + x + ", " + y + ")";
  }
}

public interface Drawable {
  public void draw();
}
------------------------------------

The aspect:
------------------------------------
public aspect Draw {

  declare parents: FigureElement extends Drawable;

  /*
  public void Point.draw() {
    System.out.println("drawing point: " + this);
   }
   */
}
------------------------------------

Resutls in an NPE and writes a core dump (attached).

java.lang.NullPointerException at org.aspectj.ajdt.internal.compiler.problem.AjProblemReporter.abstractMethodMustBeImplemented(AjProblemReporter.java:231)

Changing the declare parents to Point extends Drawable results in a clean error report, so the interface FigureElement is essential for this bug.

Of course, uncommenting the inter-type method declaration solves the problem as well.
Comment 1 Andrew Clement CLA 2008-04-16 20:02:35 EDT
From Bugzilla it looks like the NPE has been addressed in AspectJ1.6.0rc1 - there are a number of bug reports with the same NPE on AjProblemReporter.java:231.
Comment 2 Andrew Clement CLA 2008-04-24 00:01:01 EDT
Fixed in 1.6.0 final, I just tried it.