Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » OSGi: about import
OSGi: about import [message #28427] Sun, 13 July 2003 14:15 Go to next message
Eclipse UserFriend
Originally posted by: pascal_rapicault.yahoo.fr

Hello,

I have the question about imports.

Here is the test case:
Bundle A: Class A
Bundle B: Class B extends A

Bundle C: uses class B

The obvious imports are:
Bundle A: export A
Bundle B: import A, export B

Bundle C: import B,
does it also need to import A (because B extends A and A is required
to verify B)

Thanks,

PaScaL
Re: about import [message #28503 is a reply to message #28427] Tue, 15 July 2003 07:27 Go to previous messageGo to next message
Vasil Panushev is currently offline Vasil PanushevFriend
Messages: 14
Registered: July 2009
Junior Member
Hi

> Bundle C: import B,
> does it also need to import A (because B extends A and A is
required to verify B)

yes and no
"no" is because the classloader ot Bundle B takes care for loading class A
and bundle B imports the package of class A.
In OSGi every bundle is responsible for resolving its own classes. As an
example - class B may use some classes from bundle D - in this case bundle C
will NOT have to import the packages of D too.

"yes" is because of a little flaw in all JDK compilers prior to 1.4 (well,
maybe it is not a flaw but in this situation it is an obstacle )
in the following situation:
class A has mehtod foo()
class B which extedns A does NOT override foo()
class C calls B.foo()

all JDK compilers prior to 1.4 place in the bytecode of C a direct reference
to A (so the method call is in fact A.foo()).
In this case the classloader of class C will try to load class A and this
will fail unless bundle C imports the package of class A.

best regards
Vasil

"Pascal Rapicault" <pascal_rapicault@yahoo.fr> wrote in message
news:berphh$t3p$1@eclipse.org...
> Hello,
>
> I have the question about imports.
>
> Here is the test case:
> Bundle A: Class A
> Bundle B: Class B extends A
>
> Bundle C: uses class B
>
> The obvious imports are:
> Bundle A: export A
> Bundle B: import A, export B
>
> Bundle C: import B,
> does it also need to import A (because B extends A and A is
required
> to verify B)
>
> Thanks,
>
> PaScaL
>
>
>
>
>
Re: OSGi: about import [message #29332 is a reply to message #28427] Thu, 17 July 2003 20:36 Go to previous message
Eclipse UserFriend
Originally posted by: Peter.Kriens.aQute.se

C does not have to import A because it only refers to B. When class B is
loaded, it will come from Bundle B which has visibility of A and can load A.

It would be VERY bad practice if you were forced to know the
implementation dependencies of packages you used ...

Hope this helps, kind regards,

Peter Kriens

Pascal Rapicault wrote:

> Hello,
>
> I have the question about imports.
>
> Here is the test case:
> Bundle A: Class A
> Bundle B: Class B extends A
>
> Bundle C: uses class B
>
> The obvious imports are:
> Bundle A: export A
> Bundle B: import A, export B
>
> Bundle C: import B,
> does it also need to import A (because B extends A and A is required
> to verify B)
>
> Thanks,
>
> PaScaL
>
>
>
>
>
>
Previous Topic:Update on Enablement and Disablement Subproject
Next Topic:OSGi events should be batched
Goto Forum:
  


Current Time: Fri Apr 26 03:37:47 GMT 2024

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

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

Back to the top