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 39718 - IllegalStateException when clicking error in output window
Summary: IllegalStateException when clicking error in output window
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: PC Windows XP
: P2 blocker (vote)
Assignee: Dusan Balek
URL:
Keywords:
: 39445 39794 39999 40095 40745 41044 41324 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-02-06 18:35 UTC by thepriz
Modified: 2007-11-05 13:44 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Ide.log file of crash (29.88 KB, text/plain)
2004-02-06 18:37 UTC, thepriz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description thepriz 2004-02-06 18:35:17 UTC
I clicked on an error message in the output 
window after a compile and it opened the file in 
the editor window then It crashed. The error 
message was:

Import.java [133:1] reference to Statement is 
ambiguous, both class java.sql.Statement in 
java.sql and class java.beans.Statement in 
java.beans match
            Statement stmt = conn.createStatement 
();
Comment 1 thepriz 2004-02-06 18:37:37 UTC
Created attachment 13308 [details]
Ide.log file of crash
Comment 2 Jan Chalupa 2004-02-07 17:47:40 UTC
Reassigning to editor (based on last exceptions in the log file),
although I'm not sure if they could have anything to do with the IDE
crash.
Comment 3 Miloslav Metelka 2004-02-09 09:40:09 UTC
What do you mean by "it crashed"? Was there any data loss?
Anyway this should be fixed into 3.6.
Comment 4 Martin Roskanin 2004-02-09 12:43:12 UTC
This could caused by inconsistency problem of error annotations
handled in java module - JavaEditor class.

Try the following:
open ColorPreview class from examples package
Create i.e. three errors by adding extra letter to a text
for example on lines
29: java.beans.APropertyChangeSupport
36: propertyChangeSupport.AaddPropertyChangeListener
43: propertyChangeSupport.AremovePropertyChangeListener

wait until parser finish and error annotations are added into the
glyph area.

comile source via F9, click on the last error (43 line) in output
window. The cursor jumps into the editor on 43 line. Correct the
problem, delete A and immediately save the source.

Result: all error annotations are removed from glyph gutter.

Reassigning to java module for evaluation.
Comment 5 Jan Pokorsky 2004-02-09 13:34:12 UTC
I am also able to reproduce the issue with parser annotations as
described by Martin. But I do not see any connection to the problem
reported by the user. It is a separate issue.
Comment 6 Martin Roskanin 2004-02-09 13:48:54 UTC
I thouhgt that it could be connected if there is inconsistent state of
annotations. Anyway, I haven't reproduced the user problem yet...
Comment 7 Martin Roskanin 2004-02-09 14:04:55 UTC
I have overlooked they are two different types of error annos. 
org-netbeans-core-compiler-error and
org-netbeans-modules-java-parser_annotation. Reassigning the issue
back, sorry for the confusion. Please file a separate issue for java
error annos problem. Thanks.
Comment 8 Miloslav Metelka 2004-02-09 14:50:24 UTC
The exception is thrown because that the compiler's annotation is
being added to the document second time (without first being removed
from it). Document implementation has a consistency check that
prevents it.

I've looked into CompilerDisplayer and there is no extra
synchronization of its AnnotationImpl.attach() method at line 497. Not
sure whether adding/removing annotations can only happen in AWT there
so not blaming the compiler here.

However IMHO we could prevent this (or clearly point to this) by
1) syncing Annotation.attach() and detach() so the physical
attaching/detaching is thread-safe.
2) not posting NbDocument.addAnnotation() and
NbDocument.removeAnnotation() into AWT which is currently being done
in case the operation is not performed in AWT.

BTW regarding 2) there can in theory be problem in case 
  a) Thread-1 calls Annotation.attach() => AWT-task gets scheduled for
this in NbDocument.addAnnotation(). The added annotation gets
remembered in an internal set inside the module.
  b) AWT is running some sort of a refreshing task containing BTW
removal of all attached annotations including the one added in a).
  c) As b) runs directly in AWT the NbDocument.removeAnnotation() will
not post annotation removing into AWT.
  d) However the NbDocument.removeAnnotation() may fail in case the
AWT task from a) gets scheduled _after_ task from b) which IMHO can
happen.
Comment 9 thepriz 2004-02-10 09:55:42 UTC
> What do you mean by "it crashed"?

I thought that Netbeans had crashed and that I was going to loose
data. So I filled out the report and added the log before I pressed
the Ok button on the error dialog.

> Was there any data loss?

No, Netbeans seemed to continue working after the error message and I
was able to save my work.
Comment 10 Jan Chalupa 2004-02-10 12:44:47 UTC
Based on the latest comment from the reporter, I'm downgrading the
priority to P2 (see no evidence of crash, nor data loss). It still
needs to be addressed for 3.6 though.

Someone please consider replacing the current Summary line with a more
descriptive text.
Comment 11 Martin Roskanin 2004-02-15 08:58:39 UTC
*** Issue 40095 has been marked as a duplicate of this issue. ***
Comment 12 Maros Sandor 2004-02-23 16:26:04 UTC
*** Issue 39999 has been marked as a duplicate of this issue. ***
Comment 13 Miloslav Metelka 2004-02-25 13:07:10 UTC
*** Issue 39794 has been marked as a duplicate of this issue. ***
Comment 14 Miloslav Metelka 2004-03-02 14:50:15 UTC
Assigning to Dusan who will try the fix with black list of annotations
that are being added the second time or that are being removed but
they were not added yet. We should hold the use weak refs (for holding
the not yet added) annotations to make sure that we introduce no leaks.
Comment 15 _ gtzabari 2004-03-02 15:25:14 UTC
Milo,

   I'm not sure I understand your solution 100%, but aren't we fixing
the symptomes instead of the source of the problem here? Can't we
prevent this event from occuring in the first place by adding
synchronizations?
Comment 16 Miloslav Metelka 2004-03-02 16:44:53 UTC
Yes, you are right. We were analyzing the situation and we decided
that we will attempt this fix for this version as we are in danger of
the potential deadlocks that we could introduce by adding an extra
locking (which would be necessary because currently it's in fact
single-threaded because the request only come from AWT).
 After 3.6 we will revise the
NbDocument.addAnnotation()/removeAnnotation() and add a lock on the
editor side. IMHO we should revise the overall Annotations threading
model as well.
Comment 17 Dusan Balek 2004-03-04 07:28:59 UTC
*** Issue 40745 has been marked as a duplicate of this issue. ***
Comment 18 Dusan Balek 2004-03-04 11:01:57 UTC
A black list of annotations implemented as a hotfix. The list contains
weak references to annotations being added more than once or being
removed when not added yet.

Fixed in [maintrunk].

/cvs/editor/src/org/netbeans/modules/editor/NbEditorDocument.java,v 
<--  NbEditorDocument.java
new revision: 1.37; previous revision: 1.36
done

Mila, could you please review the fix.

Visual diff:
http://editor.netbeans.org/source/browse/editor/src/org/netbeans/modules/editor/NbEditorDocument.java.diff?r1=1.36&r2=1.37
Comment 19 Miloslav Metelka 2004-03-04 12:45:44 UTC
I approve the fix.
Comment 20 pfelenda 2004-03-08 13:55:27 UTC
I tried some actions with annotations and it looks good.
Verified in dev 200403071900.
Comment 21 Dusan Balek 2004-03-08 14:59:49 UTC
Integrated into release36 branch.

/cvs/editor/src/org/netbeans/modules/editor/NbEditorDocument.java,v 
<--  NbEditorDocument.java
new revision: 1.36.10.1; previous revision: 1.36
done
Comment 22 Miloslav Metelka 2004-03-16 18:49:33 UTC
*** Issue 41044 has been marked as a duplicate of this issue. ***
Comment 23 Miloslav Metelka 2004-04-07 13:56:51 UTC
*** Issue 41324 has been marked as a duplicate of this issue. ***
Comment 24 Miloslav Metelka 2004-08-20 12:18:39 UTC
*** Issue 39445 has been marked as a duplicate of this issue. ***
Comment 25 Max Sauer 2005-07-14 11:44:34 UTC
Looks like there has been some mistake. Thsi issue should be already verified by
pfelenda. Anyway, the annotations work fine in 200507131800. Marking as verified.