Bug 203721 - [compiler] "Parameter is never read" not reported if unnecessary declared checked exception
Summary: [compiler] "Parameter is never read" not reported if unnecessary declared che...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-18 06:16 EDT by Dani Megert CLA
Modified: 2007-10-29 12:53 EDT (History)
2 users (show)

See Also:
kent_johnson: review+


Attachments
Tentative fix + test cases (6.88 KB, patch)
2007-09-18 08:55 EDT, Maxime Daniel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2007-09-18 06:16:26 EDT
I20070918-0010.

1. set compiler setting to report unused param to WARNING
2. set compiler setting to eport unnecessary thrown checked exception to ERROR
3. paste this into Package Explorer:
import java.io.IOException;
public class Foo {
        void foo(int unused) throws IOException {}
}
==> only error is reported. warning for unused parameter is missing.

If I set both to warning it works.
Comment 1 Maxime Daniel CLA 2007-09-18 07:56:18 EDT
Reproduced, will investigate.
Comment 2 Maxime Daniel CLA 2007-09-18 08:24:17 EDT
The reason is that, in the current state of the code, the error/warning for the exception is detected at code analysis time, whereas the warning for the parameter is detected at code generation time. When the former is an error, the code generation is different and does not check the use of parameters.
I'll investigate if we can fix this easily or not.

Released test cases ProgrammingProblemTest#14 (inactive) and 15 in HEAD.
Comment 3 Maxime Daniel CLA 2007-09-18 08:29:31 EDT
Eclipse 3.3 behaves like I20070918-0010 (hence this is not a regression).
Comment 4 Maxime Daniel CLA 2007-09-18 08:55:35 EDT
Created attachment 78640 [details]
Tentative fix + test cases

Seems ez enough. Tests are running.
Comment 5 Maxime Daniel CLA 2007-09-19 03:07:06 EDT
JDT Core tests pass.
The fix consists into moving the check into the analysis phase.

Kent, would you please tell me what you think?
Comment 6 Maxime Daniel CLA 2007-09-20 04:35:02 EDT
Released for 3.4 M3.
Comment 7 Frederic Fusier CLA 2007-10-29 12:53:11 EDT
Verified for 3.4M3 using I20071029-0010 build.