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 257020

Summary: NullPointerException at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef
Product: java Reporter: terje7601
Component: CompilerAssignee: Dusan Balek <dbalek>
Status: VERIFIED FIXED    
Severity: normal CC: abien, danilopiazza, fleka, gtzabari, jasonkb
Priority: P2    
Version: 8.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 221545
Attachments: stacktrace
dump file mentioned in the exception dialog
IDE log
stacktrace
stacktrace
stacktrace
stacktrace
stacktrace

Description terje7601 2015-12-07 14:04:29 UTC
This bug was originally marked as duplicate of bug 230937, that is already resolved. This bug is still valid, so this seems to be another bug, but it might be related.

Build: NetBeans IDE Dev (Build 201512070002)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.60-b23, Java(TM) SE Runtime Environment, 1.8.0_60-b27
OS: Windows 7

User Comments:
terje7601: An NPE during coding




Stacktrace: 
java.lang.NullPointerException
   at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1141)
   at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:842)
   at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
   at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:286)
   at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
   at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:1120)
Comment 1 terje7601 2015-12-07 14:04:31 UTC
Created attachment 157695 [details]
stacktrace
Comment 2 terje7601 2015-12-07 14:12:24 UTC
Created attachment 157696 [details]
dump file mentioned in the exception dialog
Comment 3 terje7601 2015-12-07 14:13:32 UTC
Created attachment 157698 [details]
IDE log
Comment 4 abien 2015-12-18 11:20:03 UTC
Created attachment 157834 [details]
stacktrace

Happened during code completion
Comment 5 abien 2015-12-18 14:35:03 UTC
Created attachment 157845 [details]
stacktrace

Happened during code completion of JsonObject
Comment 6 abien 2016-01-22 06:03:40 UTC
Created attachment 158215 [details]
stacktrace

Happened during annotating an annotation (typing @)
Comment 7 Exceptions Reporter 2016-01-22 06:03:44 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=221545
Comment 8 Exceptions Reporter 2016-01-29 17:30:48 UTC
Created attachment 158296 [details]
stacktrace

I was typing inside of a newly-added JPA @Query annotation when the error message came up.
Comment 9 _ gtzabari 2016-02-08 12:52:48 UTC
Created attachment 158411 [details]
stacktrace

Opened file in Java editor. Exception thrown.
Comment 10 Exceptions Reporter 2016-05-02 19:03:11 UTC
This bug already has 20 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=221545
Comment 11 _ gtzabari 2016-05-18 03:40:15 UTC
Dusan,

This exception is taking down the entire IDE. If I code-format after saving code that generates this exception, the Swing thread hangs (indefinitely) running some endless task and I am forced to kill the process. This is 100% reproducible.
Comment 12 _ gtzabari 2016-05-18 03:47:38 UTC
Product Version: NetBeans IDE Dev (Build 201605170002)
Java: 1.8.0_92; Java HotSpot(TM) 64-Bit Server VM 25.92-b14
Runtime: Java(TM) SE Runtime Environment 1.8.0_92-b14
System: Windows 10 version 10.0 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

Repro steps:

1. Create new Maven Java project
2. Create a new class and save it:

package websitemonitor.backend.entity;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.collect.ImmutableList;
import com.vtlr.backend.ToJsonString;
import java.net.URI;
import java.util.List;
import org.bitbucket.cowwoc.preconditions.Preconditions;

/**
 * A collection of pages.
 * <p>
 * @author Gili Tzabari
 */
public final class PagesEntities
{
	/**
	 * The content-type of the JSON representation of this resource.
	 */
	public static final String JSON_TYPE = "application/x-websitemonitor.Pages+json; version=1; charset=utf-8";

	/**
	 * The entity returned by HTTP GET uri:pages.
	 */
	public static final class GetPages
	{
	/**
	 * The address of the page.
	 */
	private final URI uri;
	/**
	 * The canonical address of the page.
	 */
	private final URI canonicalUri;
	/**
	 * Indicates how long it took for the page to load.
	 */
	private final Duration loadTime;
	/**
	 * The HTTP status code returned when loading the page.
	 */
	private final int statusCode;
	/**
	 * Links that refer to malformed URLs.
	 */
	private final List<String> invalidLinks = new ArrayList<>();
	/**
	 * Links that refer to well-formed URLs.
	 */
	private final List<URI> validLinks = new ArrayList<>();

		/**
		 * Creates a new GetCompanies.
		 * <p>
		 * @param companies the list of companies
		 * @throws NullPointerException if companies is null
		 */
		@JsonCreator
		public GetCompanies(List<URI> companies)
			throws NullPointerException
		{
			Preconditions.requireThat(companies, "companies").isNotNull();

			this.companies = ImmutableList.copyOf(companies);
		}

		/**
		 * @return the list of companies
		 */
		@JsonValue
		@SuppressWarnings("ReturnOfCollectionOrArrayField")
		public List<URI> getCompanies()
		{
			return companies;
		}

		@Override
		public String toString()
		{
			return new ToJsonString(getClass(), this).toString();
		}
	}

	/**
	 * Prevent construction.
	 */
	private CompaniesEntities()
	{
	}
}

3. Netbeans will throw the following exception:

java.lang.NullPointerException
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1141)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:842)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:286)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:1120)
	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:748)
	at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:286)
	at com.sun.tools.javac.code.TypeAnnotations$1.run(TypeAnnotations.java:124)
	at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:179)
	at com.sun.tools.javac.comp.Annotate.unblockAnnotations(Annotate.java:130)
	at com.sun.tools.javac.comp.Enter.complete(Enter.java:738)
	at org.netbeans.lib.nbjavac.services.NBJavadocEnter.main(NBJavadocEnter.java:84)
	at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:995)
	at com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:369)
	at com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:311)
	at org.netbeans.modules.java.source.parsing.JavacParser.moveToPhase(JavacParser.java:630)
	at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:496)
	at org.netbeans.modules.java.source.parsing.JavacParser.getResult(JavacParser.java:163)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callGetResult(TaskProcessor.java:631)
	at org.netbeans.modules.parsing.impl.SourceCache.getResult(SourceCache.java:262)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:798)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:304)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:725)
[catch] at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:686)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)

4. Close the Exception Reporter dialog.
5. Invoke code-format.
6. Save the file.
7. IDE will hang indefinitely. Process must be killed.

This is 100% reproducible.
Comment 14 _ gtzabari 2016-05-24 16:45:48 UTC
Dusan,

What about the bigger bug of the IDE hanging if a parsing error occuring? Did you take a look at that?
Comment 15 Quality Engineering 2016-05-26 01:57:33 UTC
Integrated into 'main-silver', will be available in build *201605260002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/5a6f2b6ec074
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #257020 - NullPointerException at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef - fixed.
Comment 16 markiewb 2016-06-01 14:21:57 UTC
Thanks. Verified as fixed 
Product Version: NetBeans IDE Dev (Build 201606010002)