Abstract interface methods are added to implementing classes

Issue #282 resolved
Jesper Öqvist created an issue

JastAdd 2.2.2 weaves an abstract method declaration in an interface into all subtypes implementing the interface. This is demonstrated by the following JastAdd code:


abstract Declarator;

FieldDecl : Declarator;
VarDecl : Declarator;


aspect Test {
  public interface Variable {

  boolean Variable.needsQualifier();

  Declarator implements Variable;

  @Override public boolean FieldDecl.needsQualifier() {
    return true;

  @Override public boolean VarDecl.needsQualifier() {
    return false;

This leads to a compile error because JastAdd adds the needsQualifier declaration to Declarator:

public abstract class Declarator extends ASTNode<ASTNode> implements Cloneable, Variable {
         * @aspect Test
         * @declaredat tests/weaving/interface_decl_02p/Test.jrag:5
        boolean needsQualifier();

Compile error:

    [junit] [FAIL] runTest[weaving/interface_decl_02p](tests.jastadd2.TestShouldPass)
    [junit] Compilation failed when expected to pass:
    [junit] tmp/weaving/interface_decl_02p/Declarator.java:14: error: needsQualifier() in Declarator cannot implement needsQualifier() in Variable
    [junit]     boolean needsQualifier();
    [junit]             ^
    [junit]   attempting to assign weaker access privileges; was public

Comments (2)

  1. Log in to comment