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.
Created attachment 113956 [details] warning dialog on inspect and transform For some "Inspect and Transform" operations, I get a weird warning dialog (see attached image). For instance, I just did a "Length one String in String.indexOf" inspect/transform and got mysterious "null" warnings on four files (out of some 4000 files inspected). Either this is a bug in "Inspect and Transform" or just a terribly user unfriendly warning message. Either way it should be addressed.
I am afraid that the stack trace of the exception is needed to evaluate - could you please attach {$nbuserdir}/var/log/messages.log? I hope the exceptions will be there. Thanks.
Jan, That's not a problem - since it happens every time. Attached is the message.log file (I simply started up NB and ran the inspect/transform I mentioned and got the dialog. Hope it helps.
Created attachment 114004 [details] messages.log file with exception
Thank you very much. Still not very clear to me what happens there (both by looking at the code and trying to run the transformation on all many projects I have open). There is probably something pretty specific in the code in the four files that is triggering this bug. It would be very helpful if you could try to enable hint (Tools/Options/Editor/Hints/Java/Performace/Length one String in String.indexOf), open one of the files and try whether/which of the warnings produces the exception (unfortunately, it will be necessary to actually perform the fix through Alt-Enter, the exception won't be thrown automatically in the editor). There will probably be something specific with the code that will trigger the bug. If you could share the constant value (the character value), or the overall structure of the String.indexOf/lastIndexOf call and surrounding code, that would be very helpful. Thank you very much.
Jan, I opened the editor on one of the files with the editor hint enabled and get a ClassCastException when trying to do the hint replace on a very simple construct: if(!File.separator.equals("/")) { See the exception below, followed by the bit of code that caused it, and a simple Test.java class that reproduces the problem independently. Tom java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCExpressionStatement cannot be cast to com.sun.source.tree.ExpressionTree at org.netbeans.modules.java.source.builder.TreeFactory.MethodInvocation(TreeFactory.java:406) at org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.rewriteChildren(ImmutableTreeTranslator.java:902) at org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.visitMethodInvocation(ImmutableTreeTranslator.java:427) at org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.visitMethodInvocation(ImmutableTreeTranslator.java:92) at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1338) at org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.translate(ImmutableTreeTranslator.java:134) at org.netbeans.api.java.source.TreeUtilities$1.translate(TreeUtilities.java:960) at org.netbeans.api.java.source.TreeUtilities.translate(TreeUtilities.java:969) at org.netbeans.api.java.source.WorkingCopy.processCurrentCompilationUnit(WorkingCopy.java:514) at org.netbeans.api.java.source.WorkingCopy.getChanges(WorkingCopy.java:672) at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:668) at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:655) at org.netbeans.api.java.source.JavaSource$MultiTask.run(JavaSource.java:482) at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:643) at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:154) at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:138) at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:211) at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:208) at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:168) at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:356) at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:71) at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:208) at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:106) at org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:432) at org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:403) at org.netbeans.api.java.source.JavaSource.runModificationTask(JavaSource.java:676) at org.netbeans.modules.java.hints.jackpot.impl.JavaFixImpl.implement(JavaFixImpl.java:83) [catch] at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:762) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1411) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1991) here's the bit of code with the indexOf() operation that caused the exception: ---------------------- public String getAlarmNameForHelpText(String helpString) throws DataServiceException { String alarmName = null; if(!File.separator.equals("/")) { --> if(helpString.indexOf("\\") != -1) { helpString = helpString.replaceAll("\\\\","/" ); } } ... } ----------------------------------- But it seems like you don't need a very complex example. I see the same exception if I just write a simple Java with that same construct: public class Test { public Test() { System.err.println("Construct"); } public void someMethod(String testString) { if (testString.indexOf("\\") != -1) { System.err.println("Hello world"); } } }
Ooops - I meant that the very simple construct was: if (testString.indexOf("\\") != -1) { an inadvertent bad copy/paste :-) tom (In reply to comment #5) > Jan, > I opened the editor on one of the files with the editor hint enabled and get a > ClassCastException when trying to do the hint replace on a very simple > construct: > if(!File.separator.equals("/")) { > See the exception below, followed by the bit of code that caused it, and a > simple Test.java class that reproduces the problem independently. > > Tom > > java.lang.ClassCastException: > com.sun.tools.javac.tree.JCTree$JCExpressionStatement cannot be cast to > com.sun.source.tree.ExpressionTree > at > org.netbeans.modules.java.source.builder.TreeFactory.MethodInvocation(TreeFactory.java:406) > at > org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.rewriteChildren(ImmutableTreeTranslator.java:902) > at > org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.visitMethodInvocation(ImmutableTreeTranslator.java:427) > at > org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.visitMethodInvocation(ImmutableTreeTranslator.java:92) > at > com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1338) > at > org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.translate(ImmutableTreeTranslator.java:134) > at > org.netbeans.api.java.source.TreeUtilities$1.translate(TreeUtilities.java:960) > at > org.netbeans.api.java.source.TreeUtilities.translate(TreeUtilities.java:969) > at > org.netbeans.api.java.source.WorkingCopy.processCurrentCompilationUnit(WorkingCopy.java:514) > at > org.netbeans.api.java.source.WorkingCopy.getChanges(WorkingCopy.java:672) > at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:668) > at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:655) > at > org.netbeans.api.java.source.JavaSource$MultiTask.run(JavaSource.java:482) > at > org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:643) > at > org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:154) > at > org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:138) > at > org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:211) > at > org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:208) > at > org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:168) > at > org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:356) > at > org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:71) > at > org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:208) > at > org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:106) > at > org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:432) > at > org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:403) > at > org.netbeans.api.java.source.JavaSource.runModificationTask(JavaSource.java:676) > at > org.netbeans.modules.java.hints.jackpot.impl.JavaFixImpl.implement(JavaFixImpl.java:83) > [catch] at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:762) > at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1411) > at > org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1991) > > here's the bit of code with the indexOf() operation that caused the exception: > ---------------------- > public String getAlarmNameForHelpText(String helpString) throws > DataServiceException { > String alarmName = null; > if(!File.separator.equals("/")) { > --> if(helpString.indexOf("\\") != -1) > { > helpString = helpString.replaceAll("\\\\","/" ); > } > } > ... > } > > ----------------------------------- > > But it seems like you don't need a very complex example. I see the same > exception if I just write a simple Java with that same construct: > public class Test { > public Test() { > System.err.println("Construct"); > } > public void someMethod(String testString) { > if (testString.indexOf("\\") != -1) { > System.err.println("Hello world"); > } > } > }
Raising it to P2 as the code construct that causes the exception is very common and keeps this inspect/transform from being very useful in large projects.
Thank you very much for the test case, its easy to reproduce. Not sure offhand what is the cause, but I will take a deeper look soon.
Thank you again for you help. This should fix the problem: http://hg.netbeans.org/jet-main/rev/7203c14d04af Marking as a candidate to a 7.1 patch release. If you see more of these problem (for other hints), please file them, I will be happy to fix them. Thanks.
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/7203c14d04af User: Jan Lahoda <jlahoda@netbeans.org> Log: #206141: fixing handling of escapes while converting string literal of length one to char literal.
verified Product Version: NetBeans IDE Dev (Build 20111212-5a337de68bd3) Java: 1.7.0_02; Java HotSpot(TM) Client VM 22.0-b10 System: Windows 7 version 6.1 running on x86; Cp1250; en_US (nb) User directory: C:\Users\jprox\.netbeans\dev Cache directory: C:\Users\jprox\.netbeans\dev\var\cache
release71_fixes: http://hg.netbeans.org/releases/rev/4d5bc971302c
verified in patch1
*** Bug 223829 has been marked as a duplicate of this bug. ***