You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Hans Grimmelshausen HG <Fa...@mail.de> on 2020/02/26 11:09:04 UTC

Null-pointer exception because of javac hints, with non-installed nb-javac plug-in

Hello Geertjan and other Netbeans users,

Problem description: In NB with uninstalled nb-javac plug-in, whilst editing 
in a Java source file, a few seconds later NB raises a Null-pointer 
exception; its stacktrace I attach below.

With a fresh NB profile I imported step by step the formerly exported NB 
options (which threw the exception), until I could reproduce the Null-pointer 
exception. So I encircled the problem to the export/import options section: 
All -> General -> "All other unspecified". This means a setting in the NB 
editor Hints options.

How to reproduce the bug step by step:

1) Netbeans 11.2 and 11.3_beta, here used with Ubuntu 18.04 LTS and an 
apt-get installed OpenJDK "11.0.6" 2020-01-14

2) When NB asks to install nb-javac plugin, don't install it. In case it's 
already installed, un-install it. With enabled nb-javac plugin, the 
Null-pointer exception bug doesn't happen. (Also the refactoring-rename only 
works fully with an non-installed nb-javac plug-in.)

3) I use Netbeans Ant projects with Java 11 source-format, but the bug could 
probably also happen with other project types.

4) In NB's menu Tools -> Options -> Editor -> Hints -> Java, in section 
"Standard javac warnings", enable the "Overrides" checkbox.

5) Create a new Swing GUI form class, add to it with Netbeans' GUI designer a 
visual component which can have an action event, like a JCheckBox, then 
register an action event, i.e. double click on the JCheckBox component, so 
that NB creates an actionPerformed event method in the source code.

(By the way, surely there are other classes which would show the same 
Null-pointer exception, but since I use such NB designed Swing classes a lot 
currently, this is the fastest way I can reproduce the bug.)

6) Now manually edit some of your own code in the same source file, and a few 
seconds later, when NB's parser wants to check the source code for potential 
Override hint situations, it raises the Null-pointer exception.

7) Work-around: Disable the "Overrides" checkbox in the NB editor's hints 
section.

Greetings,
Hans



-------------------------------------------------------------------------------

java.lang.NullPointerException
     at 
jdk.compiler/com.sun.tools.javac.comp.Check.checkClassOverrideEqualsAndHash(Check.java:2095)
     at 
jdk.compiler/com.sun.tools.javac.comp.Check.checkClassOverrideEqualsAndHashIfNeeded(Check.java:2085)
     at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4577)
     at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4503)
     at jdk.compiler/com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:951)
     at org.netbeans.lib.nbjavac.services.NBAttr.visitClassDef(NBAttr.java:66)
     at 
jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:774)
     at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
     at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
     at 
jdk.compiler/com.sun.tools.javac.comp.Attr.visitAnonymousClassDefinition(Attr.java:2397)
     at jdk.compiler/com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:2288)
     at 
jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1689)
     at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
     at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:695)
     at 
org.netbeans.modules.java.hints.spiimpl.Utilities.attributeTree(Utilities.java:655)
     at 
org.netbeans.modules.java.hints.spiimpl.Utilities.parseAndAttribute(Utilities.java:435)
     at 
org.netbeans.modules.java.hints.spiimpl.Utilities.parseAndAttribute(Utilities.java:349)
     at 
org.netbeans.modules.java.hints.spiimpl.Utilities.parseAndAttribute(Utilities.java:329)
     at 
org.netbeans.modules.java.hints.spiimpl.Utilities.parseAndAttribute(Utilities.java:325)
     at 
org.netbeans.modules.java.hints.spiimpl.pm.PatternCompiler.compile(PatternCompiler.java:44)
     at 
org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.doComputeHints(HintsInvoker.java:535)
     at 
org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHintsImpl(HintsInvoker.java:283)
     at 
org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:228)
     at 
org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:193)
     at 
org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:166)
     at 
org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker.computeHints(HintsInvoker.java:128)
     at 
org.netbeans.modules.java.hints.spiimpl.hints.HintsTask.run(HintsTask.java:114)
     at 
org.netbeans.modules.java.hints.spiimpl.hints.HintsTask.run(HintsTask.java:65)
[catch] at 
org.netbeans.modules.java.source.JavaSourceAccessor$CancelableTaskWrapper.run(JavaSourceAccessor.java:273)
     at 
org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:561)
     at 
org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:786)
     at org.openide.util.lookup.Lookups.executeWith(Lookups.java:279)
     at 
org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
     at 
org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
     at 
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
     at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
     at 
org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
     at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
     at 
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)



Am 25.02.20 um 17:40 schrieb Geertjan Wielenga:
> Without very clear steps and a full description of your environment, no one 
> can help.
>
> Gj
>
> On Tue, Feb 25, 2020 at 5:31 PM Hans Grimmelshausen HG <Farold@mail.de 
> <ma...@mail.de>> wrote:
>
>     Hello Geertjan and others,
>
>     Unfortunately also with NB 11.3 alpha, the same Null pointer exception
>     occurs frequently at compile time, with non-installed nb-java plugin.
>
>     But I observed the following:
>     While the null pointer exception in its stack-trace lists this (which
>     you quoted earlier) :
>     ->  at
>     org.netbeans.lib.nbjavac.services.NBAttr.visitClassDef(NBAttr.java:66)
>
>     … and the nb-javac plugin isn't installed (which for many, including
>     me, would be located in the user's home, here under Linux it's:
>     .netbeans/11.2/ ), there's still a hard-wired module inside the
>     netbeans application folder, this:
>     ->  netbeans/java/modules/org-netbeans-lib-nbjavac.jar
>
>     This jar file stays there, even if nb-javac plugin isn't installed (or
>     un-installed) in the user's home.
>     Could this be the problem?
>
>     For now, the situation for my mid-sized OpenJDK 11 project is as follows:
>     a) With installed nb-javac plugin:
>     No null-pointer exceptions at compile time, but refactoring-rename
>     doesn't work.
>
>     b) Without the nb-javac plugin:
>     Frequent null-pointer exceptions at compile time, however
>     refactoring-rename works fine.
>
>     Strange. The null pointer exception doesn't block anything, it seems,
>     i.e. I can continue to work with the project in NB. But since the
>     exception is shown in red an occurs frequently when compiling, it's
>     irritating. Also I am at my wits' end. :-)
>
>     Greetings,
>     Hans
>


Re: Null-pointer exception because of javac hints, with non-installed nb-javac plug-in

Posted by Hans Grimmelshausen HG <Fa...@mail.de>.
Hello Geertjan,

Thanks for your hints and help. I just opened my first bug-issue on Apache. 
In case anybody is affected by this bug, too, or would like to vote for it, 
please see here:

https://issues.apache.org/jira/browse/NETBEANS-3919

Since it's related to the non-installed nb-javac plug-in and javac in 
general, it could well affect other situations, too, which we just don't 
experience at the moment, yet.

Now happy coding to you all.

Greetings,
Hans


Am 26.02.20 um 13:48 schrieb Geertjan Wielenga:
> Best to put all this into a new issue so that it can be tracked, the info 
> you have here is perfect for an issue.
>
> Gj


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: Null-pointer exception because of javac hints, with non-installed nb-javac plug-in

Posted by Geertjan Wielenga <ge...@apache.org>.
Best to put all this into a new issue so that it can be tracked, the info
you have here is perfect for an issue.

Gj

On Wed, 26 Feb 2020 at 13:36, Hans Grimmelshausen HG <Fa...@mail.de> wrote:

> Am 26.02.20 um 12:09 schrieb Hans Grimmelshausen HG:
> > 5) Create a new Swing GUI form class, add to it with Netbeans' GUI
> designer
> > a visual component which can have an action event, like a JCheckBox,
> then
> > register an action event, i.e. double click on the JCheckBox component,
> so
> > that NB creates an actionPerformed event method in the source code.
>
> Or simply use offending source code lines manually, like in the following
> mini Java class. With NB's enabled "Overrides" hint and un-installed
> nb-javac
> plug-in, in order to make NB bring a null-pointer exception during editing:
>
> import java.awt.event.ActionEvent;
> import java.awt.event.ActionListener;
> import javax.swing.JCheckBox;
> public class Test {
>     public static void main(String[] parameter)  {
>        JCheckBox jCheckbox = new JCheckBox();
>        jCheckbox.addActionListener(new ActionListener()  {
>           public void actionPerformed(ActionEvent evt) {
>           }
>        });
>     }
> }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: users-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>

Re: Null-pointer exception because of javac hints, with non-installed nb-javac plug-in

Posted by Hans Grimmelshausen HG <Fa...@mail.de>.
Am 26.02.20 um 12:09 schrieb Hans Grimmelshausen HG:
> 5) Create a new Swing GUI form class, add to it with Netbeans' GUI designer 
> a visual component which can have an action event, like a JCheckBox, then 
> register an action event, i.e. double click on the JCheckBox component, so 
> that NB creates an actionPerformed event method in the source code.

Or simply use offending source code lines manually, like in the following 
mini Java class. With NB's enabled "Overrides" hint and un-installed nb-javac 
plug-in, in order to make NB bring a null-pointer exception during editing:

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
public class Test {
    public static void main(String[] parameter)  {
       JCheckBox jCheckbox = new JCheckBox();
       jCheckbox.addActionListener(new ActionListener()  {
          public void actionPerformed(ActionEvent evt) {
          }
       });
    }
}




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists