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 20070813 Just try to add some Throws clause to the simpleCancellableTask in source editor and the follo exception appears: org.netbeans.editor.GuardedException: Attempt to insert into guarded block at position 7,321. at org.netbeans.editor.GuardedDocument.preInsertCheck(GuardedDocument.java:156) at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:554) at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:94) Caused: java.io.IOException at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:105) at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:67) at org.netbeans.modules.java.hints.errors.UncaughtException$AddThrowsClauseHintImpl.implement(UncaughtException.java:222) at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:543) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:539) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:964)
This issue is caused by java/editor module. Reassigning.
Should be OK now: Checking in UncaughtException.java; /cvs/java/hints/src/org/netbeans/modules/java/hints/errors/UncaughtException.java,v <-- UncaughtException.java new revision: 1.4; previous revision: 1.3 done Checking in Utilities.java; /cvs/java/hints/src/org/netbeans/modules/java/hints/errors/Utilities.java,v <-- Utilities.java new revision: 1.5; previous revision: 1.4 done Checking in CreateElement.java; /cvs/java/hints/src/org/netbeans/modules/java/hints/errors/CreateElement.java,v <-- CreateElement.java new revision: 1.12; previous revision: 1.11 done
build 20070821 The problem is still there, the follow exception appears whole the time. ={ org.netbeans.editor.GuardedException: Attempt to remove from guarded block at position 25,030. at org.netbeans.editor.GuardedDocument.preRemoveCheck(GuardedDocument.java:192) at org.netbeans.editor.BaseDocument.remove(BaseDocument.java:706) at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:100) Caused: java.io.IOException at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:105) at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:67) at org.netbeans.modules.java.hints.errors.Utilities.commitAndComputeChangeInfo(Utilities.java:216) at org.netbeans.modules.java.hints.errors.CreateMethodFix.implement(CreateMethodFix.java:177) at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:545) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:539) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:964)
What exactly are you doing? BTW: why is it P2 now?
Dupe of issue 90424?
We agree to increase the priority, because you can't add code in a mobile application without get the exception ={. and we can not test another parts of the product because of that.
I took another look at the second trace and it is different from the original one - I guess it probably should be covered by issue #90424 (it depends on exact use-case, it might also be a separate bug). The original problem of this issue (attempt to modify method header which is inside a guarded block) should be fixed by the above commit (the "Add throws clause" and "Add parameter" hints should not appear at all). Anyway, I tried to reproduce the second exception a bit, and I did not succeed. Could you please describe exact steps to reproduce? Thanks.
it is still reproducible. Duplicate issue 118681 has 5 duplicates in exception reporter database therefore I'm increasing priority to P2 again. Steps: 1, create new Visula MIDlet in Mobility project. The Visual Midlet opens with Flow view opened 2, in Navigator right click "MIDP Visual design > Resources" and choose "New/Add > Simple Cancellable Task" 3, right click the new task "Go to Source" 4, in source code write a line that provides you hint into one of following sections "write task-execution user code here", " write pre-init user code here", "write post-init user code here" - > for example newMethod(); 5, use hint "Create Method newMethod in" -> exception
*** Issue 118681 has been marked as a duplicate of this issue. ***
Ok, I did some changes which should ensure that the hints (or generate code dialog) fail gracefully in presence of guarded blocks. Not optimal, but acceptable for the time being, IMO. Checking in java/editor/src/org/netbeans/modules/java/editor/codegen/GeneratorUtils.java; /cvs/java/editor/src/org/netbeans/modules/java/editor/codegen/GeneratorUtils.java,v <-- GeneratorUtils.java new revision: 1.24; previous revision: 1.23 done Checking in java/editor/src/org/netbeans/modules/java/editor/codegen/Bundle.properties; /cvs/java/editor/src/org/netbeans/modules/java/editor/codegen/Bundle.properties,v <-- Bundle.properties new revision: 1.12; previous revision: 1.11 done Checking in java/editor/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGenerator.java; /cvs/java/editor/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGenerator.java,v <-- DelegateMethodGenerator.java new revision: 1.15; previous revision: 1.14 done Checking in java/editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java; /cvs/java/editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java,v <-- EqualsHashCodeGenerator.java new revision: 1.23; previous revision: 1.22 done Checking in java/editor/src/org/netbeans/modules/java/editor/codegen/GetterSetterGenerator.java; /cvs/java/editor/src/org/netbeans/modules/java/editor/codegen/GetterSetterGenerator.java,v <-- GetterSetterGenerator.java new revision: 1.13; previous revision: 1.12 done Checking in java/editor/src/org/netbeans/modules/java/editor/codegen/ImplementOverrideMethodGenerator.java; /cvs/java/editor/src/org/netbeans/modules/java/editor/codegen/ImplementOverrideMethodGenerator.java,v <-- ImplementOverrideMethodGenerator.java new revision: 1.10; previous revision: 1.9 done Checking in java/editor/src/org/netbeans/modules/java/editor/codegen/ConstructorGenerator.java; /cvs/java/editor/src/org/netbeans/modules/java/editor/codegen/ConstructorGenerator.java,v <-- ConstructorGenerator.java new revision: 1.14; previous revision: 1.13 done Checking in java/source/src/org/netbeans/api/java/source/ModificationResult.java; /cvs/java/source/src/org/netbeans/api/java/source/ModificationResult.java,v <-- ModificationResult.java new revision: 1.25; previous revision: 1.24 done Checking in editor/hints/src/org/netbeans/modules/editor/hints/Bundle.properties; /cvs/editor/hints/src/org/netbeans/modules/editor/hints/Bundle.properties,v <-- Bundle.properties new revision: 1.9; previous revision: 1.8 done Checking in editor/hints/src/org/netbeans/modules/editor/hints/HintsUI.java; /cvs/editor/hints/src/org/netbeans/modules/editor/hints/HintsUI.java,v <-- HintsUI.java new revision: 1.40; previous revision: 1.39 done
*** Issue 118703 has been marked as a duplicate of this issue. ***
*** Issue 111922 has been marked as a duplicate of this issue. ***
Should be already fixed. Please verify. *** This issue has been marked as a duplicate of 90424 ***
More problems were reported in this issue, partially covered by #90424, but definitely not a duplicate IMO.
reproduced in 20071016 b2 build -> definitely not duplicate of 90424 org.netbeans.editor.GuardedException: Attempt to remove from guarded block at position 6,590. at org.netbeans.editor.GuardedDocument.preRemoveCheck(GuardedDocument.java:214) at org.netbeans.editor.BaseDocument.remove(BaseDocument.java:748) at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:152) Caused: java.io.IOException at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:160) at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:108) at org.netbeans.modules.java.hints.errors.MagicSurroundWithTryCatchFix.implement(MagicSurroundWithTryCatchFix.java:129) at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:574) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561) [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986) the source code after us of the hint: //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem "> /** * Returns an initiliazed instance of stringItem component. * @return the initialized component instance */ public StringItem getStringItem() { if (stringItem == null) { try { // write pre-init user code here stringItem = new StringItem("Hello", "Hello, World!"); // write post-init user code here throw new Exception(); } return stringItem; } //</editor-fold> you can see missing catch + exception appears.
I forgot to provide the beginning of the exception WARNING [org.netbeans.modules.editor.hints.AnnotationHolder]: Incorrect highlight computed, please reopen issue #112566 and attach the following output: [6766-6757]=>[6766-6757] SEVERE
*** Issue 114472 has been marked as a duplicate of this issue. ***
As I wrote above, the hints should fail gracefully in presence of guarded blocks - a reasonable error message should be presented to the user. Also the commit should be atomic per file, so this shouldn't be breaking any code. Sorry, but it is not going to be generally (ie. for all hints) better for NB6.0. I went through almost all the fixes and made sure the error handling will get chance to present the proper error. All of this was on trunk.
this issue has more than 15 duplicates now. Do expect more.
Build: NetBeans IDE 6.0 Beta 2 (Build 200710212201) VM: Java HotSpot(TM) Client VM, 1.5.0_12-b04 OS: Windows XP, 5.1, x86 User Comments: 1, add "throw new Exception();" code to a pre/post code in a Form 2, go to source code ad use the "surround try-catch" hint -> exception
Created attachment 51392 [details] stacktrace
this issue is reproducible with java se project as well. The user scenario is little bit different then in mobility. In mobility you are writing code out of guarded block because the guarded block are split into small pieces. In Java SE(Form) the code that should be surrounded is _inside_ the guarded block. 1, Java SE <guarded block start/> throw new Exception(); <guarded block end/> 2, Mobility <guarded block start> ... a code ... <guarded block end> throw new Exception(); <guarded block start> ... a code ... <guarded block end>
Build: NetBeans IDE Dev (Build 200710280000) VM: Java HotSpot(TM) Client VM, 1.6.0_03-b05 OS: Windows XP, 5.1, x86 User Comments:
Created attachment 51856 [details] stacktrace
there isn't any exception anymore. There is a red message in status bar instead. BUT we cannot use the hints in mobility between the guarded blocks at all now -> issue 120599
the exception is throwing again :( I tried to use hint which should implement all abstract methods => exception occurred Code which arises this hint is placed in guarded block - off course (e.g. jTable1.setModel(new AbstractTableModel(); ) Product Version: NetBeans IDE 6.0.1 (Build 200801020000) Java: 1.6.0_04; Java HotSpot(TM) Client VM 10.0-b19 System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)
Max volunteered :)
Works ok with anonymous AbstractTableModel: jTable1.setModel(new AbstractTableModel() {});
I'll fix the last case..
Fixed. Jano, please verify, thanks. --- http://hg.netbeans.org/main/rev/3adc3b5f7c0e