Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Inheritance - eclipse plugins vs. java
Inheritance - eclipse plugins vs. java [message #755869] Wed, 09 November 2011 16:57 Go to next message
Jiri Janecek is currently offline Jiri Janecek
Messages: 12
Registered: February 2011
Junior Member
Hello,

I discovered an interesting situation shown on the figure. Please can smb. explain me why it is not possible to access method M1() when instantiating B in C? When I add generic covering of M1 to B (only calling super) everything seems to be ok but without this M1 is not visible in B when I create an instance of B in C and try to call b.M1().

Or if it is possible what could be wrong?

Normally there is no need to cover every method from super object in subobject ...

http://www.image-share.com/upload/1046/15.png

Sorry for improvised diagram I have no tool at the moment.

Example is attached.

Thanks

Jiri

Re: Inheritance - eclipse plugins vs. java [message #756011 is a reply to message #755869] Thu, 10 November 2011 08:16 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Plugin C can't see A.M1 unless it imports the package that contains A or requires plugin A (or plugin B re-exports stuff from plugin A, which is generally frowned upon).

It's not about inheritance, but about classloaders and runtime. In your plain java example, everything is in one classloader so there's no problem.

PW


Re: Inheritance - eclipse plugins vs. java [message #756080 is a reply to message #756011] Thu, 10 November 2011 14:36 Go to previous messageGo to next message
Jiri Janecek is currently offline Jiri Janecek
Messages: 12
Registered: February 2011
Junior Member
I tried to re-export A in B and in my example it is working but I am not sure if I understand
good, so is re-export correct solution for my problem or am I misusing re-export?

Thanks Paul for your help.
Re: Inheritance - eclipse plugins vs. java [message #756209 is a reply to message #756080] Fri, 11 November 2011 08:47 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You've tightly coupled A and B, and re-exporting is the sledge hammer. In effect you're saying that consumers should use B and that A is a meaningless module ... which begs the question, why not just suck A into B and get rid of the extraneous plugin?

C should simply import the A package or require the A bundle. It obviously has a dependency on A, especially at the superclass level since it needs A.M1.

PW


Re: Inheritance - eclipse plugins vs. java [message #756210 is a reply to message #756080] Fri, 11 November 2011 08:48 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5292
Registered: July 2009
Senior Member
Are you talking about compile time or runtime. If you are talking about
compile time there's a mismatch between:
* javac (only has a flat class hierarchy)
* java (has a hierarchical class model)

See http://mcaffer.com/2011/01/managing-development-time-dependencies/

Tom

Am 10.11.11 20:36, schrieb Jiri Janecek:
> I tried to re-export A in B and in my example it is working but I am not
> sure if I understand
> good, so is re-export correct solution for my problem or am I misusing
> re-export?
>
> Thanks Paul for your help.
Re: Inheritance - eclipse plugins vs. java [message #756213 is a reply to message #756209] Fri, 11 November 2011 09:04 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5292
Registered: July 2009
Senior Member
Hi,

If I get the problem right the problem is something that is a mismatch
between PDE&javac und JVM.

Bundle A:
---------
class A {
public void m() {
}
}

Bundle B requires A:
--------------------
class B extends A {
public void m2() {
}
}


Bundle C requires B:
--------------------
class C {
void main() {
new B().m(); // javac will cry
}
}


The problem here really is the compile time as Jeff described in his
blog because at runtime this would work perfectly.

Tom

Am 11.11.11 14:47, schrieb Paul Webster:
> You've tightly coupled A and B, and re-exporting is the sledge hammer.
> In effect you're saying that consumers should use B and that A is a
> meaningless module ... which begs the question, why not just suck A into
> B and get rid of the extraneous plugin?
>
> C should simply import the A package or require the A bundle. It
> obviously has a dependency on A, especially at the superclass level
> since it needs A.M1.
>
> PW
>
Previous Topic:can't open link from eclipse console
Next Topic:Need Help Creating a Project
Goto Forum:
  


Current Time: Thu Aug 28 03:30:15 EDT 2014

Powered by FUDForum. Page generated in 0.06375 seconds