Interface instanceof

W

willy gates

Hello I came across something funny in JBuider today and I thought it
worth posting just in case someone can shine some light on what is
going on. (I didn't post to borland.public.jbuilder because I
couldn't work out which one to post in to get a sensible response)

Interface NoisyAnimal;

Interface BarkingAnimal extends NoisyAnimal;

Class Mammel;

Class HairyMammel extends Mammel;

Class Dog Extends HairyMammel Implements BarkingAnimal;

{
Mammel fido = new Dog();

fido instanceof Dog --- TRUE
fido instanceof Mammel --- TRUE
fido instanceof HairyMammel --- TRUE
fido instanceof BarkingAnimal --- TRUE
fido instanceof NoisyAnimal --- TRUE
}

....but in JBuilder when I evaluate the last expression using the
debugger It get false ( all the others return true). JBuilder
debugger also fails to cast fido into a NoisyAnimal . Is this most
likely to be a JBuilder 7 bug? or was it a bug in an old jre which the
JBuilder debugger uses.
 
R

Roedy Green

...but in JBuilder when I evaluate the last expression using the
debugger It get false ( all the others return true). JBuilder
debugger also fails to cast fido into a NoisyAnimal . Is this most
likely to be a JBuilder 7 bug? or was it a bug in an old jre which the
JBuilder debugger uses.

you did not post the exact code. You could have made some error. Try
posting a sscce that others can test. see
http://mindprod.com/jgloss/ssccee.html

Most likely you have found a bug.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top