Bug 278521

Summary: [ErrorHandling] 'unused import' is not displayed consistently
Product: [Eclipse Project] JDT Reporter: Jonathan Camilleri <camilleri.jon>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, Olivier_Thomann, remy.suen, srikanth_sankaran, stephan.herrmann
Version: 3.4.2   
Target Milestone: 3.6 M1   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
Screenshot
none
Source code none

Description Jonathan Camilleri CLA 2009-05-30 12:45:54 EDT
Created attachment 137754 [details]
Screenshot

Build ID: Build id: M20090211-1700

Steps To Reproduce:
In the attached code, the error message that warns about unused imports is not displayed within ResourceTest.java.

Earlier on I reported this issue, but marked it as invalid, because I thought it was a temporary issue.  This is because sometimes Eclipse displays/hides errors after a while, which is slightly confusing until the user gets used to it.


More information:
NOTE 1: 
Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\Administrator>java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
Comment 1 Jonathan Camilleri CLA 2009-05-30 12:46:24 EDT
Created attachment 137755 [details]
Source code
Comment 2 Remy Suen CLA 2009-05-30 13:02:25 EDT
I'm pretty sure Eclipse's Java compiler is set to tell the user about errors before it tells the user about warnings. Warnings could potentially be invalid (because of syntax errors in the code). Personally, I'd be more interested in errors than warnings if I have erroneous code.

Moving to JDT/Core to comment.

Jonathan, as Paul mentioned in bug 278379 comment 4, please file perceived problems with the Java editor/compiler against JDT instead of Platform/IDE.
Comment 3 Jonathan Camilleri CLA 2009-05-30 13:11:20 EDT
(In reply to comment #2)
> I'm pretty sure Eclipse's Java compiler is set to tell the user about errors
> before it tells the user about warnings. Warnings could potentially be invalid
> (because of syntax errors in the code). Personally, I'd be more interested in
> errors than warnings if I have erroneous code.
Of course, but you never know :)
> 
> Moving to JDT/Core to comment.
> 
> Jonathan, as Paul mentioned in bug 278379 comment 4, please file perceived
> problems with the Java editor/compiler against JDT instead of Platform/IDE.
> 

Excuse the inconvenience.
Comment 4 Stephan Herrmann CLA 2009-05-30 13:23:19 EDT
This behavior can be traced back to bug 95909.
In that bug you'll find a discussion showing that checking for unused
imports in the presence of compile errors would lead to bogus warnings.
Therefore, the implementation in class CompilationUnitDeclaration
says:
	if (!this.compilationResult.hasErrors()) checkUnusedImports();

It _might_ be possible to use more sophisticated analysis whether
existing compile errors could affect "unused" warnings, but
assumable such analysis would cost more than it's worth here.

So, following Remy's advice start by removing severe errors,
and then the compiler will tell you about the fine points ;-)
Comment 5 Olivier Thomann CLA 2009-07-13 16:51:35 EDT
This behaves as expected as far as I can tell.
Serious errors in the code can potentially cause missing diagnosis. This works as designed as it prevents lots of secondary false positives errors or warnings.
Closing as INVALID.
Comment 6 Jay Arthanareeswaran CLA 2009-08-04 08:59:31 EDT
Verified for 3.6M1