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.
Build: NetBeans IDE Dev (Build 201109060600) VM: Java HotSpot(TM) Client VM, 21.0-b17, Java(TM) SE Runtime Environment, 1.7.0-b147 OS: Linux User Comments: vriha: Reproducible... Steps to reproduce: - create new Java Web project - invoke new File dialog, select Web Services and "RESTful web services from Patterns", next - select "Container-Item", next - type some package name The exception was thrown either after pressing Finish or after confirming the next opened dialog (REST Resources Configuration) Stacktrace: java.lang.NullPointerException at org.netbeans.api.java.source.GeneratorUtilities.addImports(GeneratorUtilities.java:615) at org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.rewriteChildren(ImmutableTreeTranslator.java:525) at org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.visitCompilationUnit(ImmutableTreeTranslator.java:332) at org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.visitCompilationUnit(ImmutableTreeTranslator.java:92) at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:490) at org.netbeans.modules.java.source.transform.ImmutableTreeTranslator.translate(ImmutableTreeTranslator.java:134)
Created attachment 110467 [details] stacktrace
Update: Exception is thrown after I confirm the "REST Resources Configuration" dialog which appears right after pressing Finish button
Fixed in jet-main. http://hg.netbeans.org/jet-main/rev/15bd6072f5fc
Seems to completely break "Use @NbBundle.Messages" hint.
http://statistics.netbeans.org/exceptions/messageslog?id=526667 is the same stack trace but when running with the purported fix.
getImportedElement returns null on the static wildcard import. By the way this code (run later, after the bug occurs) is probably wrong: for (Element e : parent.getEnclosedElements()) { if (name == e.getSimpleName() && e.getModifiers().contains(Modifier.STATIC) && trees.isAccessible(s, e, (DeclaredType)parent.asType())); return e; } You do some test and then ignore the result and return the first enclosed element unconditionally. Noticed because indentation does not match reality. Delete the stray semicolon.
imp is e.g. "import static pkg.Bundle.*;\n" with qualIdent "pkg.Bundle.*" of kind IDENTIFIER.
I tried something like this: String qualIdentS = qualIdent.toString(); if (qualIdentS.endsWith(".*")) { String fqn = qualIdentS.substring(0, qualIdentS.length() - 2); element = elements.getTypeElement(fqn); if (element == null) { element = elements.getPackageElement(fqn); } return element; } but it does not help; fqn "pkg.Bundle" is not yet available in elements, because it will be created by an AP only after the file has been saved.
BTW to reproduce, simply create a new standalone module, add a custom wizard iterator with one panel, find one of the NbBundle.getMessage calls, and accept the hint on it.
Only known workaround is to use 7.0.1 for this hint.
OOPS - second attempt http://hg.netbeans.org/jet-main/rev/0c6b5cd053df Jesse thanks for your investigation.
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/15bd6072f5fc User: Dusan Balek <dbalek@netbeans.org> Log: Issue #201730: NullPointerException at org.netbeans.api.java.source.GeneratorUtilities.addImports - fixed.
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/0c6b5cd053df User: Dusan Balek <dbalek@netbeans.org> Log: Issue #201730: NullPointerException at org.netbeans.api.java.source.GeneratorUtilities.addImports - fix cont.
verified