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.
NB 5.0 200512111900 JDK 1.6.0 b62 Datamodel of some swing components cannot be cloned, when they are placed in the form. In editor it looks like their contents is lost and in the console, there is annotation error followed by NPE. It is reproducible with JList, JTable, JCombobox on JDK 1.6.0 Annotation: Cannot clone javax.swing.DefaultListModel java.lang.NullPointerException at java.awt.Container.readObject(Container.java:3501) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) Annotation: Cannot clone org.netbeans.modules.form.editors2.TableModelEditor$NbTableModel java.lang.ClassNotFoundException at org.netbeans.modules.form.project.ProjectClassLoader.findClass(ProjectClassLoader.java:119) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) Annotation: Cannot clone javax.swing.DefaultComboBoxModel java.lang.NullPointerException at java.awt.Container.readObject(Container.java:3501) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Created attachment 27735 [details] Exceptions
The root of the problem is in the class loading of arrays. The code in FormClassLoader and ProjectClassLoader that attempts to load the bytecode as a resource fails for class names like [Ljavax.swing.JComponent; The problem can be reproduced as described or by cloning of a property of array type (where the component of the array is user class). The problem doesn't occur of jdk 5.0 and jdk 6.0 b60 because it happens only when allowArraySyntax flag is set to false - this was changed between jdk 6.0 b60 and jdk 6.0 b62 (see defaultAllowArraySyntax field in class sun.misc.VM). The comment above this field says that the false value will be used for final release of jdk 6.0. There is a simple workaround - it is possible to set this flag to true using sun.lang.ClassLoader.allowArraySyntax property (e.g. add -J-Dsun.lang.ClassLoader.allowArraySyntax=true to command line when starting NetBeans). Note that the opposite value -J-Dsun.lang.ClassLoader.allowArraySyntax=false allows you to reproduce the problem on jdk 5.0 as well.
Fixed. I have found an inspiration in jdk's bug 4987945. classLoader.loadClass(name) has been replaced by Class.forName(name, true, classLoader). The later one is able to create Class objects for array classes even when the mentioned allowArraySyntax flag is set to false. /cvs/form/src/org/netbeans/modules/form/FormUtils.java,v new revision: 1.110; previous revision: 1.109 /cvs/form/src/org/netbeans/modules/form/project/ClassPathUtils.java,v new revision: 1.19; previous revision: 1.18 This is a serious issue that makes the form editor (when invoked without the allowArraySyntax flag set to true) unusable on Mustang => increasing priority to P2.
Created attachment 27969 [details] The fix.
Javadoc for Class.forName actually mentions that it can load array types... We should have noticed this sooner. I have reviewed the fix - it seems to be correct and safe.
verified If there is no other problem it can be commited to 5.0 branch
Fixed also in release50 branch. /cvs/form/src/org/netbeans/modules/form/project/ClassPathUtils.java,v new revision: 1.18.4.1; previous revision: 1.18 /cvs/form/src/org/netbeans/modules/form/FormUtils.java,v new revision: 1.109.2.1; previous revision: 1.109
Hi, I am getting similar error running NB5 on Mac, JDK1.5 . Here is the stack-trace. Is this the same problem, or different one? Thanks. INFORMATIONAL *********** Exception occurred ************ at 12:17 PM on Apr 4, 2006 Annotation: Cannot clone javax.swing.DefaultComboBoxModel java.io.NotSerializableException: biz.icetec.beans.gui.CardSelectors.Selector at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291) at javax.swing.event.EventListenerList.writeObject(EventListenerList.java:240) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:890) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1333) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291) [catch] at org.netbeans.modules.form.FormUtils.cloneBeanInstance(FormUtils.java:454) at org.netbeans.modules.form.FormUtils.cloneObject(FormUtils.java:434) at org.netbeans.modules.form.FormUtils.copyPropertiesToBean(FormUtils.java:634) at org.netbeans.modules.form.RADComponent.cloneBeanInstance(RADComponent.java:335) at org.netbeans.modules.form.VisualReplicator.cloneComponent(VisualReplicator.java:613) at org.netbeans.modules.form.VisualReplicator.cloneComponent(VisualReplicator.java:646) at org.netbeans.modules.form.VisualReplicator.cloneComponent(VisualReplicator.java:646) at org.netbeans.modules.form.VisualReplicator.createClone(VisualReplicator.java:171) at org.netbeans.modules.form.VisualReplicator.createClone(VisualReplicator.java:159) at org.netbeans.modules.form.FormDesigner$FormListener.run(FormDesigner.java:1873) at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:94) at org.openide.util.Mutex.doEventAccess(Mutex.java:1172) at org.openide.util.Mutex.readAccess(Mutex.java:209) at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:76) at org.netbeans.modules.form.FormDesigner$FormListener.processEvents(FormDesigner.java: 1861) at org.netbeans.modules.form.FormDesigner$FormListener.formChanged(FormDesigner.java: 1831) at org.netbeans.modules.form.FormDesigner.updateWholeDesigner(FormDesigner.java:422) at org.netbeans.modules.form.FormDesigner.initialize(FormDesigner.java:249) at org.netbeans.modules.form.FormDesigner.componentShowing(FormDesigner.java:1491) at org.netbeans.core.multiview.MultiViewPeer.peerComponentShowing(MultiViewPeer.java:171) at org.netbeans.core.multiview.MultiViewCloneableTopComponent.componentShowing (MultiViewCloneableTopComponent.java:107) at org.openide.windows.WindowManager.componentShowing(WindowManager.java:307) at org.netbeans.core.windows.WindowManagerImpl.componentShowing(WindowManagerImpl.java: 944) at org.netbeans.core.windows.view.DefaultView.changeGUI(DefaultView.java:144) at org.netbeans.core.windows.ViewRequestor.dispatchRequest(ViewRequestor.java:238) at org.netbeans.core.windows.ViewRequestor.processRequest(ViewRequestor.java:214) at org.netbeans.core.windows.ViewRequestor.postRequest(ViewRequestor.java:152) at org.netbeans.core.windows.ViewRequestor.scheduleRequest(ViewRequestor.java:91) at org.netbeans.core.windows.Central.addModeOpenedTopComponent(Central.java:578) at org.netbeans.core.windows.ModeImpl.addOpenedTopComponent(ModeImpl.java:249) at org.netbeans.core.windows.WindowManagerImpl.topComponentOpen (WindowManagerImpl.java:992) at org.openide.windows.TopComponent.open(TopComponent.java:312) at org.openide.windows.TopComponent.open(TopComponent.java:304) at org.openide.windows.CloneableOpenSupport.openCloneableTopComponent (CloneableOpenSupport.java:171) at org.netbeans.modules.form.FormEditorSupport.openFormEditor(FormEditorSupport.java:107) at org.netbeans.modules.form.FormDataNode$1.actionPerformed(FormDataNode.java:47) at org.openide.explorer.view.TreeView$PopupSupport.mouseClicked(TreeView.java:1358) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:212) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:211) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:211) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:211) at java.awt.Component.processMouseEvent(Component.java:5557) at javax.swing.JComponent.processMouseEvent(JComponent.java:3126) at java.awt.Component.processEvent(Component.java:5319) at java.awt.Container.processEvent(Container.java:2010) at java.awt.Component.dispatchEventImpl(Component.java:4021) at java.awt.Container.dispatchEventImpl(Container.java:2068) at java.awt.Component.dispatchEvent(Component.java:3869) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3945) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866) at java.awt.Container.dispatchEventImpl(Container.java:2054) at java.awt.Window.dispatchEventImpl(Window.java:1774) at java.awt.Component.dispatchEvent(Component.java:3869) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)