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 127881 - Do not use more classloaders during visualization
Summary: Do not use more classloaders during visualization
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
: 212751 216599 216860 223384 227204 227487 242074 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-02-20 14:38 UTC by Jan Stola
Modified: 2014-02-19 14:13 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Stola 2008-02-20 14:38:46 UTC
Consider the following test-case (assumes that JXDatePicker from SwingX library is installed in the Palette):

1. Create new Java Application.
2. Create new JFrame form.
3. Put JXDatePicker into the form.
4. Preview the form - it works correctly.
5. Clean and build the project.
6. Preview the form again - exception is thrown.

java.lang.NullPointerException
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:164)
        at org.jdesktop.swingx.plaf.LookAndFeelAddons.getUI(LookAndFeelAddons.java:280)
        at org.jdesktop.swingx.JXMonthView.updateUI(JXMonthView.java:792)
        at org.jdesktop.swingx.JXMonthView.<init>(JXMonthView.java:341)
        at org.jdesktop.swingx.JXMonthView.<init>(JXMonthView.java:281)
        at org.jdesktop.swingx.JXDatePicker.initMonthView(JXDatePicker.java:272)
        at org.jdesktop.swingx.JXDatePicker.init(JXDatePicker.java:263)
        at org.jdesktop.swingx.JXDatePicker.<init>(JXDatePicker.java:192)
        at org.jdesktop.swingx.JXDatePicker.<init>(JXDatePicker.java:143)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at java.lang.Class.newInstance0(Class.java:350)
        at java.lang.Class.newInstance(Class.java:303)
        at org.netbeans.modules.form.CreationFactory.createDefaultInstance(CreationFactory.java:165)
        at org.netbeans.modules.form.RADComponent.createBeanInstance(RADComponent.java:229)
[catch] at org.netbeans.modules.form.RADComponent.cloneBeanInstance(RADComponent.java:355)
        at org.netbeans.modules.form.VisualReplicator.cloneComponent(VisualReplicator.java:666)
        at org.netbeans.modules.form.VisualReplicator.cloneComponent(VisualReplicator.java:704)
        at org.netbeans.modules.form.VisualReplicator.createClone(VisualReplicator.java:182)
        at org.netbeans.modules.form.VisualReplicator.createClone(VisualReplicator.java:170)
        at org.netbeans.modules.form.FormDesigner$4.run(FormDesigner.java:560)
        at org.netbeans.modules.form.FormLAF$2.run(FormLAF.java:255)
        at org.openide.util.Mutex.doEventAccess(Mutex.java:1355)
        at org.openide.util.Mutex.readAccess(Mutex.java:317)
        at org.netbeans.modules.form.FormLAF.executeWithLookAndFeel(FormLAF.java:240)
        at org.netbeans.modules.form.FormDesigner.createFormView(FormDesigner.java:555)
        at org.netbeans.modules.form.actions.TestAction.run(TestAction.java:137)
Comment 1 Jan Stola 2008-02-20 14:49:18 UTC
There is a simple workaround - just reload (or close and reopen) the form.

The root of this problem is a modification of project's classloader during compilation. The hacks that allow previews 
in different look and feels require usage of disjoint UIDefaults for individual classloaders. The mentioned change in 
classloader causes flush of previously installed defaults. Unfortunately, the component in view is loaded by the old 
classloader and hence requires the old defaults (during cloning).

The only solution I am aware of by now is to make sure that just one classloader is used for visualization e.g. to 
force reload of the form when project's classloader is changed. It current infrastructure requires saving of the form 
before reload. This may be annoying when project's classpath is modified as a result of form modification e.g. new 
custom component is added to form or the first binding is created.
Comment 2 Michel Graciano 2008-02-20 14:57:58 UTC
But, with just one classloader, do you think preview for different L&F will work? Some SwingX components as JXTaskPane
have different look for different L&Fs. There is a issue https://swingx.dev.java.net/issues/show_bug.cgi?id=753 which I
think is related with this behavior.

Regards.
Comment 3 Jan Stola 2008-02-20 15:20:27 UTC
As it is described in SwingX issue 753 - the 3rd party components will never be correctly displayed in other look and 
feels (if they use other than standard UI resources). The design of UIManager is not good and hence some things are not 
possible, unfortunately.
Comment 4 Tomas Pavek 2012-08-17 16:52:41 UTC
*** Bug 216599 has been marked as a duplicate of this bug. ***
Comment 5 Tomas Pavek 2012-08-22 16:48:25 UTC
*** Bug 216860 has been marked as a duplicate of this bug. ***
Comment 6 Tomas Pavek 2013-01-08 16:05:15 UTC
*** Bug 223384 has been marked as a duplicate of this bug. ***
Comment 7 Tomas Pavek 2013-01-08 16:06:11 UTC
*** Bug 212751 has been marked as a duplicate of this bug. ***
Comment 8 Tomas Pavek 2013-07-09 13:59:07 UTC
*** Bug 227487 has been marked as a duplicate of this bug. ***
Comment 9 Tomas Pavek 2014-01-16 14:00:31 UTC
*** Bug 227204 has been marked as a duplicate of this bug. ***
Comment 10 Tomas Pavek 2014-01-16 14:26:59 UTC
Implemented a simple workaround - reloading the component classes whenever the components need to be cloned. It should help with the problems reported here, but not a perfect solution and somewhat increasing risk of ClassCastException, so done only for SwingX components.

http://hg.netbeans.org/jet-main/rev/57ca7332910e
Comment 11 Quality Engineering 2014-01-18 04:52:38 UTC
Integrated into 'main-silver', will be available in build *201401180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/57ca7332910e
User: Tomas Pavek <tpavek@netbeans.org>
Log: #127881: load fresh classes when cloning SwingX components so they get to UIDefaults of the newest classloader
Comment 12 Tomas Pavek 2014-02-19 14:13:25 UTC
*** Bug 242074 has been marked as a duplicate of this bug. ***