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.
Build: NetBeans IDE 6.5 (Build 200811100001) 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: jonathanramsey: The exception triggered on one of two changes I made to this code: private Object[][] data1 = new Object[][] { { new Round("DO", "XYZ"), "XYZ" }, { new Round("RE", "ABC"), "ABC" }, { new Round("OR", "123"), "123" }, }; First change: I inserted a 3 into the first set of square brackets. private Object[3][] data1 = new Object[][] { { new Round("DO", "XYZ"), "XYZ" }, { new Round("RE", "ABC"), "ABC" }, { new Round("OR", "123"), "123" }, }; Second change: I inserted a 2 into the second set of square brackets. private Object[3][2] data1 = new Object[][] { { new Round("DO", "XYZ"), "XYZ" }, { new Round("RE", "ABC"), "ABC" }, { new Round("OR", "123"), "123" }, }; I did both of these changes absent mindedly. I should have put the array sizes into the second set of square brackets e.g. private Object[][] data1 = new Object[3][2] {. I'm fairly sure it isn't valid Java syntax to put sizes into the first set of square brackets. I think the editor should ju jonathanramsey: I typed Collection< in front of Object[], and got this exception. jblume: right after typing "HashMap<" in a Java file tnleeuw: 1. I invoked code-completion on an incomplete identifier 2. I cancellded the code-completion 3. I invoked the 'emacs-like' alt-/ word expansion (forgot the name of the command, sorry, that's why I have to describe it like that) The identifier was expanded to the desired result but immediately afterwards this exception was raised. Stacktrace: java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCArrayTypeTree cannot be cast to com.sun.source.tree.IdentifierTree at org.netbeans.modules.maven.hints.errors.SearchClassDependencyInRepo.run(SearchClassDependencyInRepo.java:238) at org.netbeans.modules.java.hints.infrastructure.CreatorBasedLazyFixList.compute(CreatorBasedLazyFixList.java:144) at org.netbeans.modules.java.hints.infrastructure.LazyHintComputation.run(LazyHintComputation.java:109) at org.netbeans.modules.java.hints.infrastructure.LazyHintComputation.run(LazyHintComputation.java:55) at org.netbeans.api.java.source.JavaSource$CompilationJob.run(JavaSource.java:1729) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Created attachment 80043 [details] stacktrace
Build: NetBeans IDE Dev (Build 200904011705) VM: Java HotSpot(TM) Client VM, 1.5.0_16-133, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_16-b06-284 OS: Mac OS X, 10.5.6, i386 User Comments: Stacktrace: java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCPrimitiveTypeTree at org.netbeans.modules.maven.hints.errors.SearchClassDependencyInRepo.run(SearchClassDependencyInRepo.java:238) at org.netbeans.modules.java.hints.infrastructure.CreatorBasedLazyFixList.compute(CreatorBasedLazyFixList.java:144) at org.netbeans.modules.java.hints.infrastructure.LazyHintComputation.run(LazyHintComputation.java:109) at org.netbeans.modules.java.hints.infrastructure.LazyHintComputation.run(LazyHintComputation.java:55) at org.netbeans.modules.java.source.JavaSourceAccessor$CancelableTaskWrapper.run(JavaSourceAccessor.java:288) at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:681)
Created attachment 80180 [details] stacktrace
dbalek: any hints? the code looks like this: case NEW_ARRAY: { NewArrayTree arrayTree = (NewArrayTree) initializer; Tree type = arrayTree.getType(); if (type != null) { itName = ((IdentifierTree) type).getName(); } } break; the exception comes from the IdentifierTree cast..
reassigning to java for evaluation, please advice how to improve the code mentioned above
What is wrong in Java? Consider: -new Object[0] - is a new array, whose type is IdentifierTree "Object" -new Object[0][] - is a new array, whose type is ArrayTypeTree "Object[]" -int[0] - is a new array, whose type is PrimiteTypeTree "int" Not sure that code is supposed to do, but it should check whether the type is an identifier (through getKind ideally) before casting to an IdentifierTree, and possibly handle the other cases too.
http://hg.netbeans.org/main/rev/8d60f647ad73
Integrated into 'main-golden', will be available in build *200906270201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/8d60f647ad73 User: Milos Kleint <mkleint@netbeans.org> Log: #162595 prevent casting error
v.
The fix has been ported into the release67_fixes repository. http://hg.netbeans.org/release67_fixes/rev/e970030d5df5