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 268848 - NullPointerException at org.netbeans.modules.java.source.pretty.WidthEstimator.widthQ
Summary: NullPointerException at org.netbeans.modules.java.source.pretty.WidthEstimato...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: Dev
Hardware: All All
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-04 23:34 UTC by misterm
Modified: 2018-02-06 17:31 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 227092


Attachments
stacktrace (8.40 KB, text/plain)
2016-11-04 23:34 UTC, misterm
Details
stacktrace (7.80 KB, text/plain)
2017-06-24 05:01 UTC, _ tboudreau
Details
stacktrace (7.80 KB, text/plain)
2017-06-24 05:04 UTC, _ tboudreau
Details
stacktrace (8.40 KB, text/plain)
2017-10-14 08:44 UTC, _ tboudreau
Details
stacktrace (8.40 KB, text/plain)
2017-10-18 15:50 UTC, Michel Graciano
Details
Patch to fix - been running it for months (1.17 KB, patch)
2018-02-06 17:31 UTC, _ tboudreau
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description misterm 2016-11-04 23:34:44 UTC
Build: NetBeans IDE Dev (Build 20161010-16f9bbc04752)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.66-b17, Java(TM) SE Runtime Environment, 1.8.0_66-b17
OS: Windows 8.1

User Comments:
misterm: Generating equals and hashCode

misterm: .

misterm: .




Stacktrace: 
java.lang.NullPointerException
   at org.netbeans.modules.java.source.pretty.WidthEstimator.widthQ(WidthEstimator.java:114)
   at org.netbeans.modules.java.source.pretty.WidthEstimator.width(WidthEstimator.java:101)
   at org.netbeans.modules.java.source.pretty.WidthEstimator.visitSelect(WidthEstimator.java:284)
   at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2096)
   at org.netbeans.modules.java.source.pretty.WidthEstimator.estimateWidth(WidthEstimator.java:73)
   at org.netbeans.modules.java.source.pretty.VeryPretty.wrapTrees(VeryPretty.java:3276)
Comment 1 misterm 2016-11-04 23:34:47 UTC
Created attachment 162789 [details]
stacktrace
Comment 2 Exceptions Reporter 2017-05-07 19:10:18 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=227092
Comment 3 Exceptions Reporter 2017-05-07 19:13:16 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=227092
Comment 4 _ tboudreau 2017-06-24 05:01:28 UTC
Created attachment 164617 [details]
stacktrace

Attempting to generate equals() and hashCode() in a newly create source file for this class:

public final class UriInfo {

    public final int weight;
    public final int priority;
    public final CharSequence uri;

    public UriInfo(int weight, int priority, CharSequence uri) {
        this.weight = checkPositiveOrZero(weight, "weight");
        this.priority = checkPositiveOrZero(priority, "priority");
        this.uri = checkNotNull(uri, "uri");
        if (uri.length() == 0) {
            throw new IllegalArgumentException("URI may not be empty");
        }
        if (weight > 65535) {
            throw new IllegalArgumentException("Weight must be a positive integer 0-65535 but got " + priority);
        }
        if (weight > 65535) {
            throw new IllegalArgumentException("Weight must be a positive integer 0-65535 but got " + priority);
        }
    }

    
}
Comment 5 _ tboudreau 2017-06-24 05:04:28 UTC
Created attachment 164618 [details]
stacktrace

Attempting to generate equals() and hashCode() for this class:

public final class UriInfo {

    public final int weight;
    public final int priority;
    public final CharSequence uri;

    public UriInfo(int weight, int priority, CharSequence uri) {
        this.weight = checkPositiveOrZero(weight, "weight");
        this.priority = checkPositiveOrZero(priority, "priority");
        this.uri = checkNotNull(uri, "uri");
        if (uri.length() == 0) {
            throw new IllegalArgumentException("URI may not be empty");
        }
        if (weight > 65535) {
            throw new IllegalArgumentException("Weight must be a positive integer 0-65535 but got " + priority);
        }
        if (weight > 65535) {
            throw new IllegalArgumentException("Weight must be a positive integer 0-65535 but got " + priority);
        }
    }

    
}
Comment 6 _ tboudreau 2017-10-14 08:44:46 UTC
Created attachment 165284 [details]
stacktrace

Happens frequently when invoking insert code, which then fails.
Comment 7 _ tboudreau 2017-10-14 08:56:00 UTC
Hmm, appears to have been fixed by a commit from dbalek on August 11, 2017.  I don't think my build is older than that, but it's possible.
Comment 8 _ tboudreau 2017-10-14 09:09:00 UTC
But it was not actually fixed.  Here is the needed patch:

diff --git a/java.source.base/src/org/netbeans/modules/java/source/pretty/WidthEstimator.java b/java.source.base/src/org/netbeans/modules/java/source/pretty/WidthEstimator.java
--- a/java.source.base/src/org/netbeans/modules/java/source/pretty/WidthEstimator.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/pretty/WidthEstimator.java
@@ -114,7 +114,11 @@
         if (t == null) {
             return;
         }
-	if (t.owner != null && t.owner != symbols.rootPackage && t.owner != t.packge().modle.unnamedPackage
+        boolean notOwnedByUnnamedPackage = true;
+        if (t.packge() != null && t.packge().modle != null) {
+            notOwnedByUnnamedPackage = t.owner != t.packge().modle.unnamedPackage;
+        }
+	if (t.owner != null && t.owner != symbols.rootPackage && notOwnedByUnnamedPackage
 	        && !(t.type instanceof Type.TypeVar)
 		&& !(t.owner instanceof MethodSymbol)) {
 	    width++;
Comment 9 Michel Graciano 2017-10-18 15:50:51 UTC
Created attachment 165311 [details]
stacktrace

Generating equals and hashCode
Comment 10 Exceptions Reporter 2017-10-18 15:50:59 UTC
This bug already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=227092
Comment 11 _ tboudreau 2018-02-06 17:31:29 UTC
Created attachment 165626 [details]
Patch to fix - been running it for months

This patch has been in the comments for months - what will it take to get it applied?