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 196497 - NbBundle.getMessage format pattern should not be used in module w/o dep on org.openide.util
Summary: NbBundle.getMessage format pattern should not be used in module w/o dep on or...
Status: NEW
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.0.1
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: issues@guibuilder
URL:
Keywords:
: 201628 201872 213672 238857 (view as bug list)
Depends on: 213683
Blocks:
  Show dependency tree
 
Reported: 2011-03-09 14:05 UTC by Geertjan Wielenga
Modified: 2013-11-27 13:48 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 Geertjan Wielenga 2011-03-09 14:05:39 UTC
Create a new module. Add a JPanel. Drag and drop a JLabel. Compile. Output shows that org.openide.util is needed but that it hasn't been added automatically, should be added automatically, maybe when the module is created, since you're always going to need that module sometime.

Created dir: C:\Documents and Settings\gwielenga\Desktop\packtpub-repo\new\code\ch2\TaskManager\TaskEditor\build\classes
Compiling 1 source file to C:\Documents and Settings\gwielenga\Desktop\packtpub-repo\new\code\ch2\TaskManager\TaskEditor\build\classes
C:\Documents and Settings\gwielenga\Desktop\packtpub-repo\new\code\ch2\TaskManager\TaskEditor\src\com\netbeansrcp\taskeditor\TaskEditorPanel.java:36: package org.openide.util does not exist
        jLabel1.setText(org.openide.util.NbBundle.getMessage(TaskEditorPanel.class, "TaskEditorPanel.jLabel1.text")); // NOI18N
1 error
C:\Program Files\NetBeans 7.0 Beta 2\harness\common.xml:206: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
Comment 1 Jesse Glick 2011-03-09 17:04:50 UTC
You do not always need a dep on org.openide.util and none should be added until one is needed.

It is the responsibility of the form editor to not create code referencing org.openide.util.NbBundle when it is not accessible. In the short term, this probably means just disabling this I18N message pattern when ClassPath.getClassPath(form, COMPILE).findResource("org/openide/util/NbBundle.class") == null.

Better would be to add the dep as needed. In an Ant-based module project, ProjectClassPathModifier may be used for this purpose, if you add a Library with a classpath volume jar:nbinst://org.openide.util/lib/org-openide-util.jar!/ for example. For a Maven-based module project, I think you would need a Library with a maven-pom volume http://bits.netbeans.org/maven2/org/netbeans/api/org-openide-util/RELEASE691/org-openide-util-RELEASE691.pom or similar, though it could likely be made to understand the URL form used for Ant-based projects too. (There is also org.netbeans.modules.apisupport.project.spi.NbModuleProvider.getDependencyVersion/addDependency but that is only available as a friend API.)

There probably needs to be some more general method in ProjectClassPathModifier such as

public static boolean add/removeAPI(String apiClass, FileObject projectArtifact, String classPathType) throws IOException, UnsupportedOperationException;

which would allow the caller to specify just "org.openide.util.NbBundle" and leave it up to the implementation to decide exactly where to find this dependency and which version to use.
Comment 2 Jan Stola 2011-09-08 15:20:01 UTC
*** Bug 201628 has been marked as a duplicate of this bug. ***
Comment 3 Jan Stola 2011-09-12 09:30:02 UTC
*** Bug 201872 has been marked as a duplicate of this bug. ***
Comment 4 Tomas Pavek 2012-06-06 14:19:50 UTC
From user's point of view, the dependency on org.openide.util should be added as needed. Similarly also org.openide.awt to support Mnemonics (bug 70944).
Comment 5 Tomas Pavek 2012-06-06 14:20:39 UTC
*** Bug 213672 has been marked as a duplicate of this bug. ***
Comment 6 Tomas Pavek 2013-11-27 13:48:40 UTC
*** Bug 238857 has been marked as a duplicate of this bug. ***