Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 12
Registered: ‎04-07-2010
My Device: 9530
My Carrier: N/A

NoClassDefFoundError on JDE 7.1 device

[ Edited ]

Hi All,

 

I am facing very weird problem on JDE 7.1 device. I have used inheritance of interface like below:

 

package mypackage;

public interface TitleGetter {

	String getTitle();
}



package mypackage;


public interface SubTitleGetter extends TitleGetter{

}


package mypackage;

public class TitleGetterImpl implements SubTitleGetter {

	public String getTitle() {
		return "MyTitle";
	}

}

 

 Now if i use the following API in my application, it throws NoClassDefFoundError.

SubTitleGetter titleGetter = new TitleGetterImpl();

titleGetter.getTitle();

 

But if i cast titleGetter to TitleGetter class and call getTitle() like ((TitleGetter)titleGetter).getTitle() then it works.

 

It seems that there is some class loading issue in JDE 7.1 OS.

 

P.S. I have tested this on Blackberry 9360 device having version 7.1.0.258.

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: NoClassDefFoundError on JDE 7.1 device

[ Edited ]

You do not *extend* an interface, you *implement* an interface.

 

If you have a class that implements two interfaces, then you implement both.

 

I'm guessing "SubTitleGetter" should be an abstract class, not an interface.

 

Contributor
Posts: 12
Registered: ‎04-07-2010
My Device: 9530
My Carrier: N/A

Re: NoClassDefFoundError on JDE 7.1 device

But this works perfactly on other JDEs. I found problem on JDE 7.1 only.

Developer
Posts: 16,786
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: NoClassDefFoundError on JDE 7.1 device

RexDoug, i think you are mistaken here. With java you can extend interfaces, and there are some usecases where it makes sense.

"A Java class may implement, and an interface may extend, any number of interfaces; however an interface may not implement an interface."
http://en.wikipedia.org/wiki/Interface_(Java)

@vidhi_thakrar: I have a similar usecase and did not see any problems on OS 7.1, in fact the software is running on my 7.1 device here.

can you reproduce the problem with an otherwise empty project?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 12
Registered: ‎04-07-2010
My Device: 9530
My Carrier: N/A

Re: NoClassDefFoundError on JDE 7.1 device

Thanks Simon,

 

Can you please tell me the software version of your JDE 7.1 device?

Contributor
Posts: 12
Registered: ‎04-07-2010
My Device: 9530
My Carrier: N/A

Re: NoClassDefFoundError on JDE 7.1 device

[ Edited ]

Also please note that if i build application with JDE 7.0 and run on JDE 7.1 device. It works perfactly.

May be my JDE 7.1 installation have some problem.

Developer
Posts: 16,786
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: NoClassDefFoundError on JDE 7.1 device

ok, that may be the case here, our build process only goes up to 6.0 so far, as we don't use any newer features.
no time to check a 7.1 build right now.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: NoClassDefFoundError on JDE 7.1 device

[ Edited ]

"A Java class may implement, and an interface may extend, any number of interfaces; however an interface may not implement an interface."

 

Simon: Yup, I see that you are correct.

 

Having said that, the comment from the o.p. regarding casting the resulting object to the original interface type is a clue that the compiler is confused.

 

My advice is to refactor this a little so that you have two interfaces, the class should then "implement" both interfaces. If nothing else, it might give us more info to go on.

 

[Edit: one other thing to try: make the getTitle() method in the first interface public]
 

Developer
Posts: 16,786
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: NoClassDefFoundError on JDE 7.1 device

interface methods of a public interface are public by default, and having interfaces extend eachother is generally fine.

i suspect that the problem is somewhere else, therefor my suggestion to reproduce the problem in an otherwise empty test project.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 18
Registered: ‎01-21-2011
My Device: BB7 - BB10
My Carrier: Developer

Re: NoClassDefFoundError on JDE 7.1 device

I'm facing with a similar problem, only on 7.1 while on other OS ,such a s7.0, all works perfectly.

 

I have a class extended from an abstract class that is an implementation of an interface. I have a lot of this type of derived class in my application, but the NoClassdefFoundError happens only with a particular class and only on 7.1