<Swing Dev> [14] RFR JDK-8190763 - Class cast exception on (CompoundEdit) UndoableEditEvent.getEdit()

Tejpal Rebari tejpal.rebari at oracle.com
Fri Nov 8 10:26:00 UTC 2019


Hi Prasanta , 
I have added a  test to the fix.
Updated webrev : http://cr.openjdk.java.net/~trebari/swing/8190763/webrev1/ <http://cr.openjdk.java.net/~trebari/swing/8190763/webrev1/>

Regards
Tejpal


> On 31-Oct-2019, at 1:58 PM, Prasanta Sadhukhan <prasanta.sadhukhan at oracle.com> wrote:
> 
> Hi tejpal,
> 
> Can you add a testcase to the fix? I guess one is there in the JBS itself.
> 
> Regards
> Prasanta
> On 24-Oct-19 10:31 AM, Tejpal Rebari wrote:
>> Hi All,
>> Please review the following fix for jdk14.
>> 
>> Bug		: https://bugs.openjdk.java.net/browse/JDK-8190763 <https://bugs.openjdk.java.net/browse/JDK-8190763>
>> Webrev	: http://cr.openjdk.java.net/~trebari/swing/8190763/webrev0/ <http://cr.openjdk.java.net/~trebari/swing/8190763/webrev0/>
>> 
>> Issue : This issue is a regression of https://bugs.openjdk.java.net/browse/JDK-8030702 <https://bugs.openjdk.java.net/browse/JDK-8030702>.
>> When UndoableEditEvent.getEdit() is casted to CompoundEdit, it throws class cast exception.
>> 
>> Fix :  In JDK-8030702 <https://bugs.openjdk.java.net/browse/JDK-8030702>  a new class DefaultDocumentEventUndoableWrapper was introduced.
>> UndoableEditEvent.getEdit() returns an object of DefaultDocumentEventUndoableWrapper and when it is casted to CompoundEdit it throws class cast exception because
>> it doesn’t inherit CompoundEdit.
>> Before the fix of JDK-8030702 <https://bugs.openjdk.java.net/browse/JDK-8030702>  , UndoableEditEvent.getEdit()  used to return an object of DefaultDocumentEvent which inherits CompoundEdit so the class cast exception was not thrown.
>> The solution is to make DefaultDocumentEventUndoableWrapper a subclass of DefaultDocumentEvent.
>> 
>> Testing : I have tested it on Mac, Windows and Ubuntu.
>> 
>> Regards
>> Tejpal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/swing-dev/attachments/20191108/a404bb0f/attachment-0001.html>


More information about the swing-dev mailing list