Bug 354502 - Incorrect Compiler Warning: "Method can be declared as static"
Summary: Incorrect Compiler Warning: "Method can be declared as static"
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-11 10:10 EDT by Holger Meyer CLA
Modified: 2011-10-24 02:30 EDT (History)
3 users (show)

See Also:


Attachments
Example Project for incorrect compiler warning. (2.58 KB, application/zip)
2011-08-11 10:11 EDT, Holger Meyer CLA
no flags Details
patch under test (3.25 KB, patch)
2011-09-22 14:41 EDT, Ayushman Jain CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Meyer CLA 2011-08-11 10:10:46 EDT
Build Identifier: I20110613-1736

Compiler shows warning that a method can be declared as static, but when declaring as static one will see a compiler error. See steps to reproduce for details...






Reproducible: Always

Steps to Reproduce:
See attached project or follow instructions below:
1. Turn on compiler warning for Code style "Method can be static".
2. Create a java project with 2 packages (packageA and packageB)
3. In package A create an abstract class (e.g. AbstractExample) with an inner protected abstract class (e.g. SubClass).
4. In packageB create another class extending the abstract class (AbstractExample) from packageA. (here called Example)
5. Create a method in the class of packageB (Example) that creates a new instance of the inner class (SubClass).
6. Call this method in the constructor of "Example".

As Is: One can see a compiler warning "method can be declared as static".
To Be: No compiler warning, as making this method static will lead to a compile error.
Comment 1 Holger Meyer CLA 2011-08-11 10:11:47 EDT
Created attachment 201315 [details]
Example Project for incorrect compiler warning.
Comment 2 Ayushman Jain CLA 2011-09-22 14:41:27 EDT
Created attachment 203856 [details]
patch under test

The original fix bug 335845 missed on adding the relevant code to QualifiedAllocationExpression.

Added that with the patch
Comment 3 Ayushman Jain CLA 2011-09-28 12:33:52 EDT
Released commit 9c0f466d3a1091abcce132530971b41684c74f20 in HEAD for 3.8M3.
Comment 4 Srikanth Sankaran CLA 2011-10-24 02:30:56 EDT
Verified for 3.8 M3 using build id: N20111022-2000