Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » Generic Aspects Problem - The method ... from the type ... refers to the missing type ...(AJDT reports the above mentioned problem for some of the methods defined by using ITD)
Generic Aspects Problem - The method ... from the type ... refers to the missing type ... [message #1707812] Wed, 09 September 2015 13:49 Go to next message
Bogdan Va is currently offline Bogdan VaFriend
Messages: 2
Registered: September 2015
Junior Member
Hi all,

//Short story
I have a problem that's been bugging me for a relatively long time, and, as mentioned in the title, refers to Generic Aspects.

More specifically, when I use an ITD method, I get in eclipse the error "The method ... from the type ... refers to the missing type ...". The code compiles with some warnings, but it works in the end.

I have the same problem even if I use Java 7, AspectJ 1.8.1 or older and eclipse Kepler or Mars... in any combination Smile.

Do you have any advices for me on how I could make that error disappear?


//Loooooooong story
In my projects I need to implement an aspect similar to the one described here (ParentChildRelationship)


I define an interface for the child:
@SuppressWarnings("rawtypes")
	public interface ChildHasParent<PARENT extends ParentHasChildren> {

		int getCategoryId();

		void setCategoryId(int categoryId);

		PARENT getParent();

		void setParent(PARENT entity);

	}


... and one for the parent:
@SuppressWarnings("rawtypes")
	public static  interface ParentHasChildren<CHILD extends ChildHasParent> {

		public void addChild(CHILD child);

		public Class<CHILD> getChildrenClass();

		public Set<CHILD> getChildren();

		public CHILD getChild(Integer categoryId);

		public void setChildren(Set<CHILD> children);
	}

.. which will be injected in the selected objects.

These interfaces are defined in the following aspect:
public abstract aspect TranslatableDefaultImpl<PARENT, CHILD> {


I inject the function definitions for the parent in the following way:
	

private java.util.Set<C> ParentHasChildren<C>.children;
	
...

	public void ParentHasChildren<C>.addChild(C child) {
		Set<C> children = this.getChildren();
		if(children == null) {
			children = new HashSet<C>();
			setChildren(children);
		}
		children.add(child);
	}

	public java.util.Set<C> ParentHasChildren<C>.getChildren() {
		return this.children;
	}

	public void ParentHasChildren<C>.setChildren(java.util.Set<C> children) {
		this.children = children;
	}

...



I apply the aspect on two classes:
Parent : Ent_Language
Child : Ent_LanguageTr
public aspect Ent_LanguageTranslatableDefaultImpl extends TranslatableDefaultImpl<Ent_Language, Ent_LanguageTr> {

	declare parents: Ent_Language implements ParentHasChildren<Ent_LanguageTr>;
	declare parents: Ent_LanguageTr implements ChildHasParent<Ent_Language>;

	...
}


When I open Ent_LanguageTest in the editor, Eclipse reports the error "The method getChildren() from the type Ent_Language refers to the missing type CHILD" on the parent.getChildren() call, but NOT on parent.addChild(tr1):
		Ent_Language parent = new Ent_Language();
		Ent_LanguageTr tr1 = new Ent_LanguageTr();
		Ent_LanguageTr tr2 = new Ent_LanguageTr();
		
		Assert.assertNull( parent.getChildren() );// ERROR
		
		parent.addChild(tr1);//OK
		parent.addChild(tr2);//OK
		
		Assert.assertNotNull( parent.getChildren() );//ERROR
		Assert.assertTrue( parent.getChildren().size() == 2 );//ERROR


I would say that CHILD should never appear in the classes definitions, because I understand that in the case of abstract aspects it serves as a placeholder...



//Project setup

You can download the test project from the attachment.

I currently have the following system setup:

    Windows 7 x64

    JDK 1.8.0_60

    Eclipse STS 3.7.0 , x64

    Maven 3.2.3

    AspectJ 1.8.6 (defined in pom)



I have created a simplified test project, from which I eliminated all other aspects and classes/interfaces, which I attached to this message.

In order to import the project in eclipse, I use the maven-eclipse-plugin to generate the project settings, by running mvn eclipse:eclipse. After that the project can be imported in eclipse with "Import existing projects into workspace" (not import Maven project)

It would be great if you could test it on your machine.
Or please tell me what should I do to help solve this problem faster.

Thank you in advance for your time and support,
Bogdan
Re: Generic Aspects Problem - The method ... from the type ... refers to the missing type ... [message #1707864 is a reply to message #1707812] Thu, 10 September 2015 03:22 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
First question, is this compiling for you on the command line? Is this only an editor problem?
Re: Generic Aspects Problem - The method ... from the type ... refers to the missing type ... [message #1707909 is a reply to message #1707864] Thu, 10 September 2015 12:50 Go to previous messageGo to next message
Bogdan Va is currently offline Bogdan VaFriend
Messages: 2
Registered: September 2015
Junior Member
Hi Andrew,

Thank you for responding this quickly.

The project compiles and the small test that I defined works. So in my opinion this is only an editor problem, and should be related to AJDT from what I know.

I used the command "mvn clean install" on the attached project and the test runs fine.
Re: Generic Aspects Problem - The method ... from the type ... refers to the missing type ... [message #1707931 is a reply to message #1707909] Thu, 10 September 2015 15:38 Go to previous message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
Unfortunately, as far as I know, there is no one working on AJDT at the moment. So, I am not sure if this issue can be addressed.
Previous Topic:Run project from another project
Next Topic:Understanding the source code of aspectj compiler
Goto Forum:
  


Current Time: Thu Apr 25 20:17:19 GMT 2024

Powered by FUDForum. Page generated in 0.03918 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top