Article View: borland.public.jbuilder.java.language
Article #7496Re: ClassCastException
From: ct
Date: Fri, 15 Jun 2001 16:48
Date: Fri, 15 Jun 2001 16:48
47 lines
2634 bytes
2634 bytes
John McGrath [TeamB] <ng-b@JPMcGrath.net> wrote:
>On 12 Jun 2001 14:15:44 -0700, ct wrote:
>
>> 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) {}
>
>I am not sure if I missed something here:
>
>First, I cannot see anywhere that you have said or shown what the value
>of "handlerName" is. This would seem to be a somewhat critical piece
>of information.
handleName = "packagename.SigninHandler";
>Second, how can you tell that an exception is being thrown from the
>line indicated in the code above. Your catch block for Exception does
>not do anything, so it would seem to be pretty hard to tell.
>
>I also note that your catch block is not syntactically correct, but I
>presume that this was just in your message.
>
>Could you change the code to the following and post the output?
I do have printstack in my code. The exception points
to line indicated in previous email.
I played more with my app. If I add
Object o2= new SigninHandler();
statement, no exception is thrown.
If we can explain this, maybe we are upto something.
Class c1 = Class.forName(handlerName);
Object o = c1.newInstance();
handler = (StateHandler)o; // exception throws
Object o2= new SigninHandler(); // add this line, no exception
ct
>---------------------------------------------------
>Before sending me e-mail, please read:
> http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<3b2a3c59$1_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsReferences:
<3b214690$1_1@dnews> <3b2345b6$1_1@dnews> <3b24c313$1_1@dnews> <3b266e7e_2@dnews> <3b268680$1_2@dnews> <MPG.1593a9b3b9ce251298a2a8@forums.borland.com>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-15 10:05:37 PST From: "ct" <cctang@yahoo.com> Sender: "ct" <cctang@yahoo.com> Reply-To: "ct" <cctang@yahoo.com> Subject: Re: ClassCastException Newsgroups: borland.public.jbuilder.java.language X-User-Info: 206.30.165.9 206.30.165.9 References: <3b214690$1_1@dnews> <3b2345b6$1_1@dnews> <3b24c313$1_1@dnews> <3b266e7e_2@dnews> <3b268680$1_2@dnews> <MPG.1593a9b3b9ce251298a2a8@forums.borland.com> NNTP-Posting-Host: 207.105.83.65 Message-ID: <3b2a3c59$1_2@dnews> Date: 15 Jun 2001 09:48:25 -0700 X-Trace: dnews 992623705 207.105.83.65 (15 Jun 2001 09:48:25 -0700) Lines: 48 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews