Please use the Apache issue tracking system for new NetBeans issues ( !!

Bug 196497

Summary: NbBundle.getMessage format pattern should not be used in module w/o dep on org.openide.util
Product: guibuilder Reporter: Geertjan Wielenga <geertjan>
Component: CodeAssignee: issues <>
Status: NEW --- QA Contact: issues <>
Priority: P3 CC: asenk, jglick, mienamoo, tingJava2013, tzezula
Version: 7.0.1   
Target Milestone: 7.3   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Report:
Bug Depends on: 213683    
Bug Blocks:    

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\ 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 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. ***
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo