This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 142405 - [65cat] ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
Summary: [65cat] ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Max Sauer
URL: http://statistics.netbeans.org/except...
Keywords:
: 142407 142946 143928 144365 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-07-31 13:33 UTC by dafreels
Modified: 2009-09-29 17:16 UTC (History)
15 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 84672


Attachments
stacktrace (1023 bytes, text/plain)
2008-07-31 21:12 UTC, dynamite
Details
stacktrace (988 bytes, text/plain)
2008-08-01 22:17 UTC, substance
Details
stacktrace (1023 bytes, text/plain)
2008-08-01 23:31 UTC, tkellerer
Details
stacktrace (1023 bytes, text/plain)
2008-08-03 20:51 UTC, jlaskowski
Details
stacktrace (1023 bytes, text/plain)
2008-08-04 11:37 UTC, _ theanuradha
Details
PATCH (1.29 KB, patch)
2008-08-04 12:13 UTC, _ theanuradha
Details | Diff
stacktrace (1023 bytes, text/plain)
2008-08-05 13:37 UTC, Jana Maleckova
Details
stacktrace (1023 bytes, text/plain)
2008-08-05 15:43 UTC, ranbato
Details
stacktrace (1023 bytes, text/plain)
2008-08-05 17:33 UTC, Jindrich Sedek
Details
stacktrace (988 bytes, text/plain)
2008-08-05 20:41 UTC, substance
Details
update patch according to jlahoda comments,msauer please review updated patch (1.27 KB, patch)
2008-08-06 06:40 UTC, _ theanuradha
Details | Diff
stacktrace (1023 bytes, text/plain)
2008-08-06 09:13 UTC, Lukas Hasik
Details
stacktrace (1023 bytes, text/plain)
2008-08-06 12:00 UTC, jlaskowski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dafreels 2008-07-31 13:33:34 UTC
Build: NetBeans IDE Dev (Build 200807310201)
VM: Java HotSpot(TM) Client VM, 10.0-b19, Java(TM) SE Runtime Environment, 1.6.0_04-b12
OS: Windows XP, 5.1, x86

User Comments: 
Changing a boolean to a string in a map.

Stacktrace: 
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:102)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 1 Jan Lahoda 2008-07-31 13:39:53 UTC
*** Issue 142407 has been marked as a duplicate of this issue. ***
Comment 2 dynamite 2008-07-31 21:12:32 UTC
Build: NetBeans IDE Dev (Build 200807310201)
VM: Java HotSpot(TM) Client VM, 10.0-b23, Java(TM) SE Runtime Environment, 1.6.0_07-b06
OS: Windows XP, 5.1, x86

User Comments: 
I have:

String day(int dayNo)
{
String msg;
switch (dayNo)
{
case 0: msg="sun"; break;
}
}

I cut-and-paste the case line several times to form a list.  I then tried to update the index that went next to each case and got this exception.

Stacktrace: 
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:102)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 3 dynamite 2008-07-31 21:12:45 UTC
Created attachment 66224 [details]
stacktrace
Comment 4 Petr Dvorak 2008-08-01 02:57:30 UTC
From nbusers, NetBeans Dev 200807301401 (windows 2000,sp4,jdk1.6.0_06-b02):

Hi,all:
 
I get a strange bug,the code below works fine in 6.5M1,but in NetBeans Dev 200807301401,when ever I double click the
number(16,24,28,etc,) and select it,the ide report a exception.(windows 2000,sp4,jdk1.6.0_06-b02)
 
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
 at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:102)
 at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
 at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
 at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
 at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
 at java.util.concurrent.FutureTask.run(FutureTask.java:138)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
[catch] at java.lang.Thread.run(Thread.java:619)
 
code:
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
/**
 *
 * @author Administrator
 */
public class NewClass {
 
    public static int _c2(int c) {
        int k = 2;
        for (int i = 0; i < c; i++) {
            k = k * 2;
        }
        return k;
    }
 
    public static void main(String args[]) {
        System.out.println(_c2(16));
        System.out.println(_c2(24));
        System.out.println(_c2(28));
        System.out.println(_c2(30));
        System.out.println(_c2(31));
    }
}
Comment 5 Exceptions Reporter 2008-08-01 10:42:30 UTC
This issue has already 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=84672
Comment 6 substance 2008-08-01 22:17:12 UTC
Build: NetBeans IDE Dev (Build 200807311401)
VM: Java HotSpot(TM) Client VM, 1.5.0_13-119, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_13-b05-237
OS: Mac OS X, 10.5.4, i386

User Comments: 
Selected text from the source editor.

Stacktrace: 
java.lang.ClassCastException: java.lang.Integer
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:102)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
Comment 7 substance 2008-08-01 22:17:28 UTC
Created attachment 66364 [details]
stacktrace
Comment 8 tkellerer 2008-08-01 23:31:09 UTC
Build: NetBeans IDE Dev (Build 200808010201)
VM: Java HotSpot(TM) Client VM, 1.6.0_03-b05, Java(TM) SE Runtime Environment, 1.6.0_03-b05
OS: Windows XP, 5.1, x86

User Comments: 


Stacktrace: 
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:102)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 9 tkellerer 2008-08-01 23:31:24 UTC
Created attachment 66367 [details]
stacktrace
Comment 10 jlaskowski 2008-08-03 20:51:13 UTC
Build: NetBeans IDE Dev (Build 200808010201)
VM: Java HotSpot(TM) Client VM, 10.0-b23, Java(TM) SE Runtime Environment, 1.6.0_07-b06
OS: Windows XP, 5.1, x86

User Comments: 


Stacktrace: 
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:102)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 11 jlaskowski 2008-08-03 20:51:17 UTC
Created attachment 66419 [details]
stacktrace
Comment 12 _ theanuradha 2008-08-04 11:37:30 UTC
Build: NetBeans IDE Dev (Build 080801)
VM: Java HotSpot(TM) Client VM, 11.0-b14, Java(TM) SE Runtime Environment, 1.6.0_10-rc-b27
OS: Windows XP, 5.1, x86

User Comments: 
type 
public class NetCatClass {
  private int i=100;
}

add double click and select '100'

Stacktrace: 
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:102)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 13 _ theanuradha 2008-08-04 11:37:34 UTC
Created attachment 66462 [details]
stacktrace
Comment 14 _ theanuradha 2008-08-04 12:12:35 UTC
I have fix bug will attach patch
Comment 15 _ theanuradha 2008-08-04 12:13:43 UTC
Created attachment 66467 [details]
PATCH
Comment 16 _ theanuradha 2008-08-04 12:15:10 UTC
jlahoda can you review patch

Thanks 
Comment 17 Jana Maleckova 2008-08-05 13:37:07 UTC
Build: NetBeans IDE Dev (Build 20080801110327)
VM: Java HotSpot(TM) Client VM, 11.0-b13, Java(TM) SE Runtime Environment, 1.6.0_10-rc-b26
OS: Windows XP, 5.1, x86

User Comments: 
my case:
have method
public void test (int n){
}

test(1) - exception is thrown when integer is selected

Stacktrace: 
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:103)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 18 Jana Maleckova 2008-08-05 13:37:11 UTC
Created attachment 66592 [details]
stacktrace
Comment 19 _ theanuradha 2008-08-05 13:42:25 UTC
any update on patch review ?
Comment 20 ranbato 2008-08-05 15:43:50 UTC
Build: NetBeans IDE Dev (Build 200808021401)
VM: Java HotSpot(TM) Client VM, 10.0-b22, Java(TM) SE Runtime Environment, 1.6.0_06-b02
OS: Windows XP, 5.1, x86

User Comments: 
I typed 
i = 0;
without putting int in front of it.

section of code now reads
Owasp o = Owasp();
i = 0;
while(true)

Stacktrace: 
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:103)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 21 ranbato 2008-08-05 15:43:56 UTC
Created attachment 66604 [details]
stacktrace
Comment 22 Jan Lahoda 2008-08-05 15:46:57 UTC
*** Issue 142946 has been marked as a duplicate of this issue. ***
Comment 23 Jindrich Sedek 2008-08-05 17:33:01 UTC
Build: NetBeans IDE Dev (Build 200808040201)
VM: Java HotSpot(TM) Client VM, 11.0-b13, Java(TM) SE Runtime Environment, 1.6.0_10-rc-b26
OS: SunOS, 5.11, x86

User Comments: 
just select some number in java editor and wait a second

Stacktrace: 
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:103)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 24 Jindrich Sedek 2008-08-05 17:33:09 UTC
Created attachment 66614 [details]
stacktrace
Comment 25 Jan Lahoda 2008-08-05 18:11:06 UTC
The patch will fix the problem IMO. There are two "formal" problems with it:
-the formatting is not the usual NetBeans formatting (we use spaces after if, before '{', around '=', before
'instanceof', etc.). Also, the parenthesis around the initializer of 'lt' variable are superfluous.
-there is no test for the change.

Also, the maintainer of the module (the default owner of the java/hints category) should do the review, IMO.
Comment 26 substance 2008-08-05 20:41:24 UTC
Build: NetBeans IDE Dev (Build 200808021401)
VM: Java HotSpot(TM) Client VM, 1.5.0_13-119, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_13-b05-237
OS: Mac OS X, 10.5.4, i386

User Comments: 
Double clicked a variable name in editor window

Stacktrace: 
java.lang.ClassCastException: java.lang.Boolean
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:103)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
Comment 27 substance 2008-08-05 20:41:28 UTC
Created attachment 66622 [details]
stacktrace
Comment 28 _ theanuradha 2008-08-06 06:40:42 UTC
Created attachment 66641 [details]
update patch according to jlahoda comments,msauer please review updated patch
Comment 29 Lukas Hasik 2008-08-06 09:12:58 UTC
Build: NetBeans IDE Dev (Build 200808050125)
VM: Java HotSpot(TM) Client VM, 11.0-b11, Java(TM) SE Runtime Environment, 1.6.0_10-beta-b14
OS: Windows XP, 5.1, x86

User Comments: 
-have a method call where one of parameters is boolean. e.g. zavolejMiDoKlubu(test, true);
-select the true by double click (word selection) -> CCE

Stacktrace: 
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:103)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 30 Lukas Hasik 2008-08-06 09:13:07 UTC
Created attachment 66647 [details]
stacktrace
Comment 31 jlaskowski 2008-08-06 12:00:35 UTC
Build: NetBeans IDE Dev (Build 200808010201)
VM: Java HotSpot(TM) Client VM, 10.0-b23, Java(TM) SE Runtime Environment, 1.6.0_07-b06
OS: Windows XP, 5.1, x86

User Comments: 


Stacktrace: 
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
        at org.netbeans.modules.java.hints.errors.Utilities.guessName(Utilities.java:102)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.computeError(IntroduceHint.java:359)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:294)
        at org.netbeans.modules.java.hints.introduce.IntroduceHint.run(IntroduceHint.java:125)
        at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1675)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 32 jlaskowski 2008-08-06 12:00:45 UTC
Created attachment 66666 [details]
stacktrace
Comment 33 Max Sauer 2008-08-06 12:24:06 UTC
Thanks for the patch, I've just fixed it. It is already covered by testIntroduceFieldFix9.
---
http://hg.netbeans.org/main/rev/14720ccbbed7
Comment 34 Lukas Hasik 2008-08-08 15:50:20 UTC
pity that's in beta :( I'm increasing priority even if it has no sense
Comment 35 _ alexlamsl 2008-08-11 12:20:50 UTC
Reproduced on dev:

    private final AtomicBoolean reloading = new AtomicBoolean(fa|


Product Version: NetBeans IDE Dev (Build 200808021401)
Java: 1.6.0_07; Java HotSpot(TM) Client VM 10.0-b23
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)
Comment 36 Jan Lahoda 2008-08-11 12:31:29 UTC
alexlamsl: your build number suggests that your build has been build on Aug 2nd, while the bug was fixed on Aug 6th -
are you sure you are using an up-to-date build?
Comment 37 _ alexlamsl 2008-08-11 13:22:05 UTC
Ignore me, my eyes are not working properly today - somehow I keep thinking that I have a 0808 build...

Downloading 0811 to verify...
Comment 38 _ alexlamsl 2008-08-11 14:46:50 UTC
Verified on 200808110201.
Comment 39 pribyl 2008-08-13 13:54:38 UTC
Still reproducible on latest beta

Product Version: NetBeans IDE 6.5 Beta (Build 200808111757)
Java: 1.6.0_10-rc; Java HotSpot(TM) Client VM 11.0-b15
System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb)
Comment 40 pribyl 2008-08-13 13:58:43 UTC
I am sorry, I just tried latest trunk, and it works without problem...

Verified on Product Version: NetBeans IDE Dev (Build 200808130201)
Comment 41 rptmaestro 2008-08-14 04:06:43 UTC
Still happens in latest 6.5 BETA when selecting a literal integer value.
Comment 42 _ alexlamsl 2008-08-14 10:54:46 UTC
I think the fix went into dev after it got branched for beta release - I have been using the latest dev builds and 
have not been able to reproduce it since.
Comment 43 Jan Lahoda 2008-08-15 14:43:18 UTC
*** Issue 143928 has been marked as a duplicate of this issue. ***
Comment 44 Jiri Prox 2008-08-19 12:00:08 UTC
*** Issue 144365 has been marked as a duplicate of this issue. ***
Comment 45 tboerkel 2008-09-01 16:07:05 UTC
Shouldn't this be backported to 6.1, given the number of reports?

http://statistics.netbeans.org/analytics/detail.do?id=84672
Comment 46 Jiri Prox 2008-09-02 08:25:50 UTC
Unfortunately there is no plan to make a patch4, which would backport the fixes to 6.1. 
Comment 47 myopic4141 2008-09-29 08:56:54 UTC
I do not know about the error being fixed because I downloaded and installed NetBeans on 28Sep08.
Comment 48 _ alexlamsl 2008-09-30 15:30:02 UTC
myopic4141, do you mean you have reproduced the issue on the nightly build 20080928?

I'm using the last few days' build and it has been working for me so far...
Comment 49 myopic4141 2008-10-01 18:45:40 UTC
I do not know when this Beta version was built; but, it was the one I down loaded and ran at 04:21 29Sep08 from
http://download.netbeans.org/netbeans/6.5/beta/index.html?cid=926302.  If this is an earlier version, then the problem
is that the beta site source is not being properly updated.
Comment 50 myopic4141 2008-10-02 07:54:15 UTC
I looked up the build number.  It is 200008111757
Comment 51 _ alexlamsl 2008-10-02 22:31:19 UTC
That's way before the market collapsed - and rest assured, the basis of our IDE is now stronger than ever ;-)

If you want to try out the latest nightly builds, you can download it from http://bits.netbeans.org/dev/nightly/latest/
Comment 52 myopic4141 2008-10-03 09:17:03 UTC
You mean NetBeans has been around since before 1929?
I downloaded the latest build and there is no longer the error.  Thank you.