United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7080289 AWTKeystroke class registers a subclass factory during deserialization
JDK-7080289 : AWTKeystroke class registers a subclass factory during deserialization

Details
Type:
Bug
Submit Date:
2011-08-17
Status:
Resolved
Updated Date:
2011-12-29
Project Name:
JDK
Resolved Date:
2011-10-19
Component:
client-libs
OS:
generic
Sub-Component:
java.awt
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
1.4.2_34,5.0u32
Fixed Versions:
5.0u33 (b09)

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:
Relates:

Sub Tasks

Description
see comments

                                    

Comments
EVALUATION

This regression is introduced by CR 7068047 ("DnDMerlinQLTestsuite_DnDJTextArea test fails with an java.awt.dnd.InvalidDnDOperationException"). The faulty method is AWTKeyStroke.readResolve():

protected Object readResolve() throws java.io.ObjectStreamException {
   synchronized (AWTKeyStroke.class) {
       Class newClass = getClass();
       Class awtKeyStrokeClass = getAWTKeyStrokeClass();
       if (!newClass.equals(awtKeyStrokeClass)) {
           registerSubclass(newClass);
       }
       return getCachedStroke(keyChar, keyCode, modifiers, onKeyRelease);
   }
}

Judging from the exception stack trace, newClass is invalid and registerSubclass(newClass) fails, triggering an exception.
                                     
2011-08-24
EVALUATION

Exact point where exception occurs is a call to a sub-class constructor in AWTKeyStroke.registerSubclass() method:

Constructor ctor = getCtor(subclass);

String couldNotInstantiate = "subclass could not be instantiated";

if (ctor == null) 
    throw new IllegalArgumentException(couldNotInstantiate);
}
try {
    AWTKeyStroke stroke = (AWTKeyStroke)ctor.newInstance(null);
    if (stroke == null) {
        throw new IllegalArgumentException(couldNotInstantiate);
    }
} catch ...

So the line
    AWTKeyStroke stroke = (AWTKeyStroke)ctor.newInstance(null);
is the point where exception triggers. The exact cause of the exception - there're 5 possible exceptions that are catched - is still not fully clear to me. I'm going to analyse the test routine.
                                     
2011-08-29



Hardware and Software, Engineered to Work Together