Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Possible bug in resolver
Possible bug in resolver [message #75122] Fri, 20 October 2006 09:35 Go to next message
Paul Kendall is currently offline Paul KendallFriend
Messages: 40
Registered: July 2009
Member
Hi,
I'm using fragment bundles as my container for unit tests and I have a
problem with them as follows.

bundleA has an interface a.X
package a is exported from the bundle
fragmentA has a mock implementation of X called a.MockX

bundleB has a class b.Y which has interface X from bundleA as an
argument to a method.
package a is imported in this bundle
fragmentB has a test class Z for b.Y which passes a new a.MockX object
from bundleA

Ok, this should work if I'm reading the spec right. But I get compile errors
for fragmentB saying "the import a cannot be resolved". Also, the Plug-in
Depenencies object in the project shows package in it!

I have tried added exports to fragmentA & imports to fragmentB to no avail.

Can someone steer me in the right direction.

Cheers,
Paul
Re: Possible bug in resolver [message #75140 is a reply to message #75122] Fri, 20 October 2006 15:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

IIRC a fragment's classes can't be exported to other dependent bundles. So I don't think that fragment B would be able to instantiate a.MockA. Also, I don't think the bundle A would be able to see A's fragment classes, either.

You probably need to do something like:

Bundle A
Bundle-Classpath: mock.jar, .
  :

// Bundle A
class Factory {
  X getThing() { return null; };
}

// Fragment A, stored in 'mock.jar'

class Factory {
  X getThing() { return new MockX(); };
}


That way, at run time, your Factory is replaced with the Factory from the fragment, which knows how to instantiate MockX things. You could then return them to B (or B's fragment).

However, I'm not certain this would work, since I don't think that B would be able to access instances of type MockX anyway...

Alex.
Re: Possible bug in resolver [message #75154 is a reply to message #75140] Sat, 21 October 2006 02:07 Go to previous messageGo to next message
Paul Kendall is currently offline Paul KendallFriend
Messages: 40
Registered: July 2009
Member
Alex Blewitt wrote:

> IIRC a fragment's classes can't be exported to other dependent bundles. So
> I don't think that fragment B would be able to instantiate a.MockA. Also,
> I don't think the bundle A would be able to see A's fragment classes,
> either.
.... 8< ...

From re-reading the OSGi spec, section 3.14 it says on page 69, "Fragments
are treated as part of the host." and on page 71 section 3.14.2 it also
says "Fragment bundles are treated as if they are an intrinsic part of
their host."

So I think what I'm trying to do should work!

Can you point me at the part where you think it says "a fragments classes
can't be exported to other dependent bundles"?

>
> Alex.

Cheers,
Paul
Re: Possible bug in resolver [message #75171 is a reply to message #75122] Sat, 21 October 2006 12:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jeff_mcaffer.REMOVE.ca.ibm.com

Paul,

The may be a PDE issue as it seems like this should work. Try reloading
your target. That is, go to Window > Preferences > PDE > Target
Platform and click the Reload button. That should trigger PDE to
recompute the state and all the wirings etc. If that doesn't work,
perhaps you should open a bug in Eclipse/PDE/UI and attach the manifests
for the 4 bundles involved?

Jeff

Paul Kendall wrote:
> Hi,
> I'm using fragment bundles as my container for unit tests and I have a
> problem with them as follows.
>
> bundleA has an interface a.X
> package a is exported from the bundle
> fragmentA has a mock implementation of X called a.MockX
>
> bundleB has a class b.Y which has interface X from bundleA as an
> argument to a method.
> package a is imported in this bundle
> fragmentB has a test class Z for b.Y which passes a new a.MockX object
> from bundleA
>
> Ok, this should work if I'm reading the spec right. But I get compile errors
> for fragmentB saying "the import a cannot be resolved". Also, the Plug-in
> Depenencies object in the project shows package in it!
>
> I have tried added exports to fragmentA & imports to fragmentB to no avail.
>
> Can someone steer me in the right direction.
>
> Cheers,
> Paul
Re: Possible bug in resolver [message #75205 is a reply to message #75140] Sat, 21 October 2006 19:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

Sorry, I may have misunderstood, but I thought if you had package com.example.foo in the bundle, and com.example.foo in the fragment, then you wouldn't necessarily see that by dependent bundles. But I may have been misremembering from when I tried to replace classes in the main bundle -- in that case, I was using the same class as well as package name.

Alex.
Re: Possible bug in resolver [message #75222 is a reply to message #75171] Sun, 22 October 2006 00:56 Go to previous messageGo to next message
Paul Kendall is currently offline Paul KendallFriend
Messages: 40
Registered: July 2009
Member
Jeff McAffer wrote:

> Paul,
>
> The may be a PDE issue as it seems like this should work. Try reloading
> your target. That is, go to Window > Preferences > PDE > Target
> Platform and click the Reload button. That should trigger PDE to
> recompute the state and all the wirings etc. If that doesn't work,
> perhaps you should open a bug in Eclipse/PDE/UI and attach the manifests
> for the 4 bundles involved?
>
> Jeff

Tried what you said and it did not work, so I have raised a ticket with PDE
and attached a tar ball with 4 simple projects that exhibit the described
behavior.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=161853

Cheers,
Paul
Re: Possible bug in resolver [message #75409 is a reply to message #75222] Tue, 24 October 2006 19:36 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Paul,

PDE-UI is more sensitive than the Equinox Framework WRT placing
fragments on the classpath of bundles that import/require the host. In
order to indicate to PDE that you want to do such a thing you need to
add the following header to you host bundles

Eclipse-ExtensibleAPI: true

This header has no meaning at all to Equinox, but it does indicate to
PDE that if the host is added to a bundles classpath then any attached
fragments of the host must be added also.

Tom


Paul Kendall wrote:
> Jeff McAffer wrote:
>
>> Paul,
>>
>> The may be a PDE issue as it seems like this should work. Try reloading
>> your target. That is, go to Window > Preferences > PDE > Target
>> Platform and click the Reload button. That should trigger PDE to
>> recompute the state and all the wirings etc. If that doesn't work,
>> perhaps you should open a bug in Eclipse/PDE/UI and attach the manifests
>> for the 4 bundles involved?
>>
>> Jeff
>
> Tried what you said and it did not work, so I have raised a ticket with PDE
> and attached a tar ball with 4 simple projects that exhibit the described
> behavior.
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=161853
>
> Cheers,
> Paul
Re: Possible bug in resolver [message #75537 is a reply to message #75409] Wed, 25 October 2006 03:15 Go to previous messageGo to next message
Paul Kendall is currently offline Paul KendallFriend
Messages: 40
Registered: July 2009
Member
Tom Watson wrote:

> Paul,
>
> PDE-UI is more sensitive than the Equinox Framework WRT placing
> fragments on the classpath of bundles that import/require the host. In
> order to indicate to PDE that you want to do such a thing you need to
> add the following header to you host bundles
>
> Eclipse-ExtensibleAPI: true
>
> This header has no meaning at all to Equinox, but it does indicate to
> PDE that if the host is added to a bundles classpath then any attached
> fragments of the host must be added also.
>
> Tom

Thanks Tom,
Perhaps PDE should treat this manifest entry as true for OSGi bundles i.e.
If I have deselected "Plug-in Development -> Always show the Extension
Point tabs" check-box in the project properties! As this seems to be the
only difference when creating an OSGi project rather than an Eclipse
project.

Oh, and adding that manifest entry works a treat!

Should I close the ticket I raised or add this email to it about the OSGi
stuff.

Cheers,
Paul
Re: Possible bug in resolver [message #75554 is a reply to message #75537] Wed, 25 October 2006 03:32 Go to previous message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Paul,

The team over in PDE-land would need to decide that. Eclipse has had a
long standing best-practice that fragments do not provide new API. PDE
is kinda enforcing this rule. Of coarse we can come up with valid
usecases that go against this best practice. For example, SWT fragments
provide almost all the content and API for SWT. This is why they
decided to add header so that developers can clearly state there
intentions WRT fragments adding API to their hosts for development time
purposes. The header is only a tool time header. No OSGi Framework
implementation is going to actually use that header so there are no
runtime side-effects.

I think you should continue this discussion in the PDE bug report.

Tom.


Paul Kendall wrote:
>
> Thanks Tom,
> Perhaps PDE should treat this manifest entry as true for OSGi bundles i.e.
> If I have deselected "Plug-in Development -> Always show the Extension
> Point tabs" check-box in the project properties! As this seems to be the
> only difference when creating an OSGi project rather than an Eclipse
> project.
>
> Oh, and adding that manifest entry works a treat!
>
> Should I close the ticket I raised or add this email to it about the OSGi
> stuff.
>
> Cheers,
> Paul
>
Previous Topic:How to use the registry with straight osgi?
Next Topic:Problems with tomcat again
Goto Forum:
  


Current Time: Fri Apr 26 19:53:21 GMT 2024

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

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

Back to the top