Bug 386049 - Error "must implement abstract inter-type declaration" even though build is fine
Summary: Error "must implement abstract inter-type declaration" even though build is fine
Status: VERIFIED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.7.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.7.1   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-26 10:15 EDT by Alexander Kriegisch CLA
Modified: 2012-08-23 14:41 EDT (History)
2 users (show)

See Also:


Attachments
Simplified project that reproduces the error (5.19 KB, application/x-zip-compressed)
2012-08-21 13:42 EDT, Andrew Eisenberg CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kriegisch CLA 2012-07-26 10:15:19 EDT
Build Identifier: Version: 4.2.0 Build id: I20120608-1400

I have an AspectJ project with Java classes like this (schematically, not the full code):

public abstract class BasicFilter {
    protected abstract String getLogMessage();
}

public class PreJTidyFilter extends BasicFilter
{
    @Override
    protected String getLogMessage() {
        return "Fixing HTML so as to enable JTidy to parse it";
    }
}

public class JTidyFilter extends BasicFilter {
    @Override
    protected String getLogMessage() {
        return "Converting to clean, pretty-printed XHTML";
    }
}

public class XOMUnclutterFilter extends BasicFilter {
    @Override
    protected String getLogMessage() {
        return "Removing clutter (header, footer, navigation, ads) and fixing structure";
    }
}

###################################

I also have this aspect:

privileged aspect LoggingAspect {
    pointcut runFilter() : execution(* BasicFilter.run());

    void around(BasicFilter filter) : runFilter() && this(filter) {
        String message = filter.getLogMessage();
        SimpleLogger.verbose(message, IndentMode.INDENT_AFTER);
        proceed(filter);
        SimpleLogger.dedent();
    }
}

###################################

The aspects compile and run fine, but the Eclipse error view always shows two errors:

must implement abstract inter-type declaration:
    java.lang.String de.scrum_master.galileo.filter.BasicFilter.getLogMessage()
    (XOMUnclutterFilter.java)

must implement abstract inter-type declaration:
    java.lang.String de.scrum_master.galileo.filter.BasicFilter.getLogMessage()
    (JTidyFilter.java)

The errors even re-occur after cleaning and rebuilding the project. But as I said, the code runs just fine.

Please note: The funny thing is that in those two classes I just need to add and remove whitespace, then save the file, and the error goes away file by file. As soon as I rebuild though, the errors are there again.

Please also note: The errors always are shown for subclasses XOMUnclutterFilter and JTidyFilter, but strangely *not* for subclass PreJTidyFilter, even though it is affected by the same pointcut and advice as the others and also subclassing the same base class.

Reproducible: Always

Steps to Reproduce:
I do not know if there is a way for you to reproduce this behaviour with the little code snippets I provided above, but here it happens all the time.

If you would like to clone my project, it is located at https://github.com/kriegaex/Galileo-Openbook-Cleaner.

My Eclipse was configured via Yoxos, but AJDT
  Version: 2.2.0.e42x-RELEASE-20120703-2200
  AspectJ version: 1.7.0.20120703164200
was installed by me manually because right after the Juno release AJDT were not available via Yoxos yet (I do not know if they are now).
Comment 1 Alexander Kriegisch CLA 2012-08-21 03:02:55 EDT
Because this still occurs all the time, I have tested with and without automatic build. The result is the same. Even after a clean and manual build from the IDE, this happens. Only when I pseudo-edit (add + remove a space, then save) the file affected by the error, it goes away until the next build.
Comment 2 Andrew Eisenberg CLA 2012-08-21 11:48:04 EDT
This looks like an AJDT problem.  My understanding is that you see this error in the editor, but not in problems view?

I am trying your code snippets out right now, but I can't see the problem.  Did you leave something out of your code snippet below?  The error message implies that there is something amiss with ITDs, but your snippet does not have any ITDs.
Comment 3 Alexander Kriegisch CLA 2012-08-21 12:25:30 EDT
No, Andrew, I see it in both the problems view and the editor.

Feel free to clone my little playground repository at https://github.com/kriegaex/Galileo-Openbook-Cleaner in order to reproduce the bug. Meanwhile, now that I have your attention, I am trying to reduce the problem, trying to create a minimal test sample without the other classes around the main problem.

BTW, the three warnings you will also see when cloning my project are the ones I mentioned in https://bugs.eclipse.org/bugs/show_bug.cgi?id=387568, if you want to take care of that one too.
Comment 4 Andrew Eisenberg CLA 2012-08-21 12:47:45 EDT
I stand corrected then.  This may not be an AJDT problem, but a compiler problem.  I'll have a look at your repo.
Comment 5 Alexander Kriegisch CLA 2012-08-21 12:52:31 EDT
Okay, I have reduced the problem to these three entities (2 classes, 1 aspect), just create a project with those entities and do "Project - Clean" (with auto-rebuild on) or manually clean + recompile (with auto-build off):


package filter;

public abstract class BasicFilter implements Runnable {
	public void run() {
		System.out.println("running BasicFilter");
	}

	protected abstract void filter();
	protected abstract String getLogMessage();
}

// ##############################################################################

package filter;

public class JsoupFilter extends BasicFilter {
	@Override
	protected String getLogMessage() {
		return "Cleaning up HTML, removing clutter, fixing structure";
	}

	@Override
	protected void filter() {
		System.out.println("running JsoupFilter");
	}
}

// ##############################################################################

import filter.BasicFilter;

privileged aspect LoggingAspect {
	pointcut runFilter() : execution(* BasicFilter.run());

	void around(BasicFilter filter) : runFilter() && this(filter) {
		System.out.println(filter.getLogMessage());
		proceed(filter);
	}
}
Comment 6 Alexander Kriegisch CLA 2012-08-21 12:53:42 EDT
Damn, I want to be able to edit a comment...

It is crucial that the filter classes be in a sub-package which the aspect needs to import. The problem seems to go away when all three are in the same package.
Comment 7 Andrew Eisenberg CLA 2012-08-21 13:42:01 EDT
Created attachment 220115 [details]
Simplified project that reproduces the error

Thanks for the sample project.  I was able to reproduce the error.  I simplified it and I'm attaching the simplified project.

It looks like the problem is that BasicFilter.getLogMessage() is referenced inside of an advice, but getLogMessage is protected.  If I change from protected to public, the error goes away.

To reproduce, import the attached project into your workspace and do a full build.
Comment 8 Andrew Eisenberg CLA 2012-08-21 13:42:37 EDT
This is an AspectJ bug, so moving it back to that project.
Comment 9 Andrew Eisenberg CLA 2012-08-21 14:01:17 EDT
(In reply to comment #5)
> Okay, I have reduced the problem to these three entities (2 classes, 1
> aspect), just create a project with those entities and do "Project - Clean"
> (with auto-rebuild on) or manually clean + recompile (with auto-build off):

Oh well, looks like our comments crossed-paths.  We now know why the problem is occurring.
Comment 10 Andrew Clement CLA 2012-08-22 15:48:59 EDT
all fixed.  Problem was due to the abstract nature of the member that we were granting privileged access to.  The check didn't go far enough and verify what it was looking at was a real ITD (privileged access is handled in an ITD like mechanism).  The solution was just to extend the check and avoid the error if it isn't a 'real' itd. committed changes into AJDT master, should appear in 4.2 dev builds shortly.
Comment 11 Alexander Kriegisch CLA 2012-08-23 07:44:19 EDT
I tried the build by Andrew Eisenberg of ca. 10 hours ago directly from Bamboo server (one failed test seems to have stopped it from being pushed to the update site), but there it is not fixed yet. The same applies to the other bug you fixed. Maybe the changed were not part of that build, I just wanted to provide some early feedback.
Comment 12 Andrew Clement CLA 2012-08-23 12:05:59 EDT
I spoke in haste as I had committed locally but when it came to push i couldn't yesterday (for some reason), just pushed all these changes a few mins ago so should appear in a build later today.
Comment 13 Alexander Kriegisch CLA 2012-08-23 14:41:15 EDT
I just verified this with the latest build https://build.springsource.org/browse/AJDT-E42-37 and can acknowledge that the problem is gone in my project. Thank you very much.