Bug 489979 - Boolean NOT Unary NOT Operator in some circumstances causes "Compute launch button tooltip" and other issues
Summary: Boolean NOT Unary NOT Operator in some circumstances causes "Compute launch b...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5.2   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-18 18:30 EDT by Olivier Lerone CLA
Modified: 2022-08-02 09:20 EDT (History)
3 users (show)

See Also:


Attachments
Example Project for Reproduction (6.55 KB, application/zip)
2016-03-18 18:30 EDT, Olivier Lerone CLA
no flags Details
Error log exported from Eclipse with Stack Trace (734.28 KB, text/x-log)
2016-03-18 18:31 EDT, Olivier Lerone CLA
no flags Details
(Corrected) Eclipse Error Log with Stack Trace (4.74 KB, text/plain)
2016-03-18 18:35 EDT, Olivier Lerone CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Lerone CLA 2016-03-18 18:30:17 EDT
Created attachment 260417 [details]
Example Project for Reproduction

### Overview:

The boolean, unary NOT operator in some (extreme?) circumstances causes some exception in org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.optimizedBooleanConstant which causes issues further up in Eclipse.

I hope I was correct in filing this in the JDT bug tracker and not that of Eclipse. Else, please forgive me.

### Steps to Reproduce in Eclipse:

1) Import the attached project, which has been reduced and anonymised to the minimum of what I was able to use to reproduce the issue.

2) Open the file bugrepro/BugReproTest.java in the Editor by double clicking it in the Package hierarchy tree sidepane.

3) Mouse over the green run button.

4) Receive an "Compute launch button tooltip" error with vague information.
A full error log is available from the 'Error Log' view.

5) (Extra): Open the Run > Run As... Menu, and notice that it is completely blank/empty (not even the 'none applicable' is there).

### Actual Results

An error message was received with a stack trace in the Error Log view.

### Expected Results

No such error should occur, and an option for running as Java Application should be visible (if main method present) or a grayed out '(none applicable)' pseudo-option should be in the Run > Run As... menu.

### Build Date & Hardware

Using build:
Version: Mars.2 Release (4.5.2)
Build id: 20160218-0600

Running Ubuntu 15.04 (x64)

`uname -a`
Linux spruce-GA-78LMT-USB3 3.19.0-47-generic #53-Ubuntu SMP Mon Jan 18 14:02:48 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Using Java JDK:
openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)

### Additional Builds and Platforms

None available for test.

### Additional Information

The bug is very finickity to reproduce, so I have attached a project which can be used to reproduce the error, while cutting out as much code as possible and anonymising it. The error log will follow in a new comment if possible, because the attachment form only seems to accept one attachment.
Comment 1 Olivier Lerone CLA 2016-03-18 18:31:31 EDT
Created attachment 260418 [details]
Error log exported from Eclipse with Stack Trace
Comment 2 Olivier Lerone CLA 2016-03-18 18:35:42 EDT
Created attachment 260419 [details]
(Corrected) Eclipse Error Log with Stack Trace

Apologies for the prior attachment which was seemingly the entire log file, not the log for this single case.
Comment 3 Stephan Herrmann CLA 2016-03-19 21:21:14 EDT
I can reproduce, although debugging the code that creates a sub menu is prone to freezing the computer ...

Anyway, the statement in question is

    pp.rs = (! (boolean) pp.rs)

inside this method

  public void abc() {
    Pqrs pp = new Pqrs();
    pp.rs = (! (boolean) pp.rs);
  }


During normal compilation all is fine, the qualified name reference pp.rs has resolved type j.l.Object.

But on the given call path from HierarchyResolver, the STB for Pqrs has no fields, hence 'rs' is a ProblemFieldBinding with no type. Apparently, one part of the machine thinks we don't need any details, but another part disagrees.

It should be possible to create a JUnit by just requesting the type hierarchy for type BugReproTest.

Anyone? :)
Comment 4 Sasikanth Bharadwaj CLA 2016-03-22 07:03:07 EDT
HierarchyResolver.accept(ISourceType[], PackageBinding, AccessRestriction) has this

CompilationUnitDeclaration unit =
		SourceTypeConverter.buildCompilationUnit(
			new ISourceType[] {sourceType}, // ignore secondary types, to improve laziness
			SourceTypeConverter.MEMBER_TYPE | (this.lookupEnvironment.globalOptions.sourceLevel >= ClassFileConstants.JDK1_8 ? SourceTypeConverter.METHOD : 0), // need member types
			// no need for field initialization
			this.lookupEnvironment.problemReporter,
			result);
			
where it is explicitly excluding fields from the built type declaration, so the fields are not included in the parsed type declaration thereby resulting in this problem.  Including SourceTypeConverter.FIELD in the flags solves the problem. Could it be for performance reasons that fields were left out??
Comment 5 Stephan Herrmann CLA 2016-03-22 17:01:51 EDT
(In reply to Sasikanth Bharadwaj from comment #4)
> where it is explicitly excluding fields from the built type declaration, so
> the fields are not included in the parsed type declaration thereby resulting
> in this problem.  Including SourceTypeConverter.FIELD in the flags solves
> the problem. Could it be for performance reasons that fields were left out??

I believe so. It seems like in former times the different use cases calling into the compiler paid great attention to performing only the minimal necessary work, and with Java getting more and more complex, this erodes to doing almost all the work almost all the time (see, e.g., the ">= JDT1_8" part in the quoted snippet).

Regarding the issue at hand: I wouldn't expect a huge performance penalty from including fields of secondary types, but OTOH I believe compiling statements (which triggers the NPE in the first place) is beyond the point for creating a type hierarchy. Perhaps this is done in order to find local types? Perhaps we could prune the parse tree in scenarios like type hierarchy to discard all statements other than local type declarations?
Comment 6 Eclipse Genie CLA 2020-07-23 09:44:17 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 7 Eclipse Genie CLA 2022-08-02 09:20:10 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.