Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Stumped - class cast is not working
Stumped - class cast is not working [message #86735] Mon, 16 April 2007 16:06 Go to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
I have a piece of code that looks something like:

Object object = someFunctionCall();
Type[] types = object.getClass().getGenericInterfaces();

inspection of the types[] array shows two interfaces:

test.Foo
test.Bar

the following code causes a ClassCastException

test.Foo foo = (test.Foo) object;

Some things to note:

someFunctionCall() is in a different bundle
test.Foo is in a defferent bundle

Does anybody know how this situation can happen? I'm totally stumped.

Bryan
Re: Stumped - class cast is not working [message #86822 is a reply to message #86735] Mon, 16 April 2007 18:39 Go to previous message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
It turns out that if I Import-Package on test.Foo instead of
Require-Bundle that contains test.Foo, it works. Is this a bug?

Bryan


On 2007-04-16 11:06:53 -0500, Bryan Hunt <bhunt@mac.com> said:

> I have a piece of code that looks something like:
>
> Object object = someFunctionCall();
> Type[] types = object.getClass().getGenericInterfaces();
>
> inspection of the types[] array shows two interfaces:
>
> test.Foo
> test.Bar
>
> the following code causes a ClassCastException
>
> test.Foo foo = (test.Foo) object;
>
> Some things to note:
>
> someFunctionCall() is in a different bundle
> test.Foo is in a defferent bundle
>
> Does anybody know how this situation can happen? I'm totally stumped.
>
> Bryan
Previous Topic:How to obtain sample project from EclipseCon 2006 OSGi Component Programming tutorial
Next Topic:Eclipse 2.1->3.2 migration problem w.r.t. WizardNewFileCreationPage
Goto Forum:
  


Current Time: Thu Apr 25 09:21:16 GMT 2024

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

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

Back to the top