Bug 506645 - Internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.FieldBinding.constant(FieldBinding.java:218)
Summary: Internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.in...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2016-10-27 13:28 EDT by Felipe Pontes CLA
Modified: 2022-11-03 06:33 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Felipe Pontes CLA 2016-10-27 13:28:46 EDT
NullPointerException when trying to compile the following program using the eclipse bath compiler.


Program

   public class A {
        @NotNull
        final B.C<D> field;
        void x(@NotNull B.C<D> parameter) {
		field = parameter;
        }
   }

Steps to reproduce

   Execute the following command:
java -jar org.eclipse.jdt.core-3.13.0-SNAPSHOT-batch-compiler.jar -1.8 A.java

Current result

   ERROR in A.java (at line 0)
           public class A {
           ^
   Internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.FieldBinding.constant(FieldBinding.java:218)

Expected result

   No internal compiler errors.

Configuration

   Software

      O.S.: Linux Ubuntu 14.04 64bits
      ECJ: org.eclipse.jdt.core-3.13.0-SNAPSHOT-batch-compiler.jar (Eclipse Neon 4.6)

   Hardware: Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
Comment 1 Stephan Herrmann CLA 2016-10-27 17:47:49 EDT
Seems to be a result of unresolved B.C, in combination with the annotation (not necessarily a nonnull annotation).

The fact that also NotNull and D are unresolved is irrelevant.

Same exception is thrown from compiling

//---
   @interface Ann {}
   class D {}
   public class A {
        @Ann
        final B.C<D> field;
        void x(B.C<D> parameter) {
            field = parameter;
        }
   }
//---

Removing the B. from B.C avoids the bug, as does ensuring that B.C can be resolved. Also removing "final" from the field avoids the bug.

BTW: assigning a final field in a regular method is bogus to begin with - but then changing x() to a constructor does not avoid the NPE.
Comment 2 Manoj N Palat CLA 2018-05-17 03:24:51 EDT
bulk move out of 4.8
Comment 3 Manoj N Palat CLA 2018-08-16 00:09:36 EDT
Bulk move out of 4.9
Comment 4 Eclipse Genie CLA 2022-11-03 05:32:33 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Stephan Herrmann CLA 2022-11-03 06:33:05 EDT
still happens