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 270142 - ClassCastException: java.desktop/javax.swing.text.AbstractDocument$DefaultDocumentEventUndoableWrapper cannot be cast to java.desktop/javax.swing.text.AbstractDocument$DefaultDocumentEvent
Summary: ClassCastException: java.desktop/javax.swing.text.AbstractDocument$DefaultDoc...
Status: NEW
Alias: None
Product: connecteddeveloper
Classification: Unclassified
Component: Issuetracking Framework (show other bugs)
Version: Dev
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Tomas Stupka
URL:
Keywords: JDK_9
Depends on:
Blocks:
 
Reported: 2017-03-20 22:25 UTC by muellermi
Modified: 2017-10-05 17:26 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 223463


Attachments
stacktrace (3.58 KB, text/plain)
2017-03-20 22:25 UTC, muellermi
Details
stacktrace (3.58 KB, text/plain)
2017-10-05 17:26 UTC, alied
Details

Note You need to log in before you can comment on or make changes to this bug.
Description muellermi 2017-03-20 22:25:32 UTC
Build: NetBeans IDE Dev (Build 201703160002)
VM: Java HotSpot(TM) 64-Bit Server VM, 9-ea+161, Java(TM) SE Runtime Environment, 9-ea+161
OS: Linux

User Comments:
GUEST: Modifing description  in a bug report

muellermi: after each char I enter in the comment of a bugzilla task

muellermi: editing comment in task

muellermi: entering data into task




Stacktrace: 
java.lang.ClassCastException: java.desktop/javax.swing.text.AbstractDocument$DefaultDocumentEventUndoableWrapper cannot be cast to java.desktop/javax.swing.text.AbstractDocument$DefaultDocumentEvent
   at org.netbeans.modules.bugtracking.commons.UndoRedoSupport$CompoundUndoManager.undoableEditHappened(UndoRedoSupport.java:161)
   at javax.swing.text.AbstractDocument.fireUndoableEditUpdate(AbstractDocument.java:293)
   at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:761)
   at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:716)
   at javax.swing.text.PlainDocument.insertString(PlainDocument.java:131)
   at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:675)
Comment 1 muellermi 2017-03-20 22:25:34 UTC
Created attachment 163901 [details]
stacktrace
Comment 2 Exceptions Reporter 2017-08-16 13:20:03 UTC
This bug already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=223463
Comment 3 jn0101 2017-09-21 08:14:57 UTC
This bug i due to a change in Java 9 where the edit of the argument (a 
DefaultDocumentEvent) is first wrapped in a DefaultDocumentEventUndoableWrapper which hides the line number and other important stuff (I can't understand why!!), before 

   public void undoableEditHappened(UndoableEditEvent e)

is invoked.

https://github.com/netroby/jdk9-dev/blob/master/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java#L279

This makes this cast break:
		AbstractDocument.DefaultDocumentEvent event =
			(AbstractDocument.DefaultDocumentEvent)e.getEdit();

The problem is that this cast is widely used in all kinds of code - originating from this post from 2008: https://tips4java.wordpress.com/2008/10/27/compound-undo-manager/

Here is a possible fix:
https://github.com/nordfalk/jsyntaxpane/commit/5fc75594f8bc4df6e8f7096d4a440490b768fd46#diff-b3f8826824f551219879f1c798618c12R67
Comment 4 alied 2017-10-05 17:26:41 UTC
Created attachment 165248 [details]
stacktrace

was filing an issue for Netbeans.