Bug 36046 - inter-type declaration bug with abstract classes
Summary: inter-type declaration bug with abstract classes
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 2000
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-03 18:21 EST by Ron Bodkin CLA
Modified: 2003-04-10 18:20 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ron Bodkin CLA 2003-04-03 18:21:57 EST
This error occurs when you do an inter-type declaration on an interface, use 
declare parents to make an abstract base class implement it, and then try to 
use the declared (method), it fails. If you make the base class concrete, then 
this doesn't fail.

The following code demonstrates the error. If you run java Driver you get:
java.lang.AbstractMethodError: Derived.getExecutions(Ljava/lang/String;)I
	at Driver.main(Driver.java:23)
Exception in thread "main" 

public class Driver {
    public static void main(String args[]) {
        Derived generator = new Derived();
        System.out.println(generator.getExecutions("processEvents"));
    }
    static aspect MonitorBase {
        declare parents: Base implements ExecutionMonitor.MonitoredItem;
    }    
}

class Derived extends Base {
    public String getName() {
        return null;
    }
}

abstract class Base {
    abstract public String getName();
}

aspect ExecutionMonitor {
    /** marker interface to indicate the execution monitor should track calls 
and executions on this class. */
    public interface MonitoredItem {
        int getExecutions(String methodName);
    }

    /** a Map of events to mutable integers */
    public int MonitoredItem.getExecutions(String methodName) {
        return 0;
    }
}
Comment 1 Jim Hugunin CLA 2003-04-10 18:20:15 EDT
fixed in current tree, revealed a more serious problem in overriding existing
abstract methods with concrete inter-type declarations.  test in 
bugs/interAbstract.