Bug 354502

Summary: Incorrect Compiler Warning: "Method can be declared as static"
Product: [Eclipse Project] JDT Reporter: Holger Meyer <mholger>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, Olivier_Thomann, srikanth_sankaran
Version: 3.7   
Target Milestone: 3.8 M3   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Example Project for incorrect compiler warning.
none
patch under test none

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