🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7615

Re: ClassCastException

#7615
From: Michael Rachow
Date: Wed, 13 Jun 2001 21:43
32 lines
1841 bytes
It had become a little bit of a puzzle meanwhile.

So the problem is the (String) content of handlerName.
Since no ClassNotFound Exception is thrown,
it must be StateHandlerSupport.
You cannot downcast to a more specialized class,
if the instance is of a type above (more general) in the hierarchy "only".

Your cast in printing is right but the cast at the assignment is the
"special".
Greetings
Michael

ct <cctang@yahoo.com> schrieb in im Newsbeitrag: 3b268680$1_2@dnews...
>
> The handler is declared as following,
>
> StateHandler handler = null;
> try {
>    Class c1 = Class.forName(handlerName);
>    Object o = c1.newInstance();
>    System.out.println("StateMachine: o = " + (SigninHandler)o);
>    handler = (StateHandler)o;  // exception throws
> } catch(Exception) {}
>
> "Michael Rachow" <michael@famrachow.de> wrote:
> >Sorry,
> >and of what type is the member   'handler'?
> >Mic
> >
> >
>
Technical Details
Message-ID: <3b27ddf4$1_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews
References: <3b214690$1_1@dnews> <3b2345b6$1_1@dnews> <3b24c313$1_1@dnews> <3b266e7e_2@dnews> <3b268680$1_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,8a0377b4254bc1e1
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-06-13 14:58:23 PST
From: "Michael Rachow" <michael@famrachow.de>
Newsgroups: borland.public.jbuilder.java.language
References: <3b214690$1_1@dnews>  <3b2345b6$1_1@dnews>  <3b24c313$1_1@dnews>  <3b266e7e_2@dnews>  <3b268680$1_2@dnews>
Subject: Re: ClassCastException
Date: Wed, 13 Jun 2001 23:43:41 +0200
Lines: 34
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
NNTP-Posting-Host: 217.227.18.157
Message-ID: <3b27ddf4$1_1@dnews>
X-Trace: dnews 992468468 217.227.18.157 (13 Jun 2001 14:41:08 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews