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 42945 - PaletteItem.loadComponentClass is probably wrong
Summary: PaletteItem.loadComponentClass is probably wrong
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@guibuilder
Depends on:
Blocks: 41448
  Show dependency tree
Reported: 2004-05-07 15:44 UTC by Jesse Glick
Modified: 2006-03-24 10:25 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2004-05-07 15:44:19 UTC
The FROM_JAR and FROM_LIBRARY cases look
suspicious; don't know what you're doing but it
sounds wrong. FROM_PROJECT is almost certainly wrong.

+            else if (origin == FROM_PROJECT) { //
+                Project project =
+                    FileUtil.toFileObject(new
+                if (project != null) {
+                    AntArtifact[] artifacts =
"jar"); // NOI18N
+                    roots = new
+                    for (int i=0; i <
artifacts.length; i++) {
+                        File jarFile = new File(
+                            originLocation +
+                        roots[i] =
+                    }
+                }
+            }

So you're storing some project and then finding
every JAR it produces? Why?? This makes little
sense. What if the project produces two JARs, one
of which is a bean JAR and one of which is
something completely different?

Probably the storage of palette items is just
designed wrong. Keep the actual classpath you need
to use for the bean. If you need to know more
about where it came from later - e.g. to add
something to a j2seproject classpath - get the
information when you need it. E.g. you can use
Comment 1 Tomas Pavek 2004-05-07 16:18:51 UTC
Thanks for noticing me. This code is still experimental (is not
executed from anywhere yet). Asking a project for all JARs does not
make much sense, I agree. The palette item will know which concrete
JAR it need.

But the other cases seem ok to me - a reference to JAR or library
needs to be kept by palette items, so they know where to load from.
Why is this suspicious?
Comment 2 Jesse Glick 2004-05-07 19:49:13 UTC
FROM_JAR is probably fine. FROM_LIBRARY may be; depends on what you
want to happen if that library is removed (when the JAR(s) still
exists), or its CP is changed, etc. I think FROM_PROJECT is the
problematic one. Either keep the actual JAR path you are using, or
keep both the project dir and the artifact's associated target, which
together form a primary key.
Comment 3 Tomas Pavek 2004-05-14 13:21:39 UTC
In case of a project, the palette item now holds the name of the
output  JAR file. When adding to a form, AntArtifact is found for the
JAR and added to the project classpath via ProjectClassPathExtender.

As for the library case, I think it's enough to refer just to the
library name - the library is found when needed. If the library is
removed, the item fails to load. But once the item class is loaded,
changes in the classpath are not reflected (at this level).

I'm closing this as fixed. Thanks for feedback.
Comment 4 Marek Grummich 2005-07-11 14:35:08 UTC