| Summary: | [inline] Method inlining does not detect/resolve shadowing of field | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Brian Miller <bmiller> |
| Component: | UI | Assignee: | Markus Keller <markus.kell.r> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | Brian.Miller, strider80 |
| Version: | 3.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | stalebug | ||
Problem is that Thread.MAX_PRIORITY shadows Bug.MAX_PRIORITY. Could be resolved with
new Thread(){
void bar(){new Byte(Bug.this.MAX_PRIORITY);}
};
rather than the current
new Thread(){
void bar(){new Byte(MAX_PRIORITY);}
};
Same problem with shadowed methods. Eg, inlining method bar() declared on LINE 3 gives illegal result.
------------------------------ Bug.java ---------------------------
class Bug{
void foo(){}
void bar(){foo();} //LINE 3
class Inner{
{
bar();
}
void foo()throws Exception{throw null;}
}
}
This bug is still present. Searching for "inline" finds multiple duplicate bug reports for the issue with inner classes such as Bug 238120 I found an example that is even worse than the examples here because the resulting program still compiles but has different behavior. When running the following program it outputs Old count = 0 New count = 5 Old count = 5 New count = 7 But after inlining the first call to getCount() it outputs: Old count = 5 New count = 5 Old count = 7 New count = 7 public class Shadow { private int count; public void setCount(int count) { System.out.println("Old count = " + getCount()); this.count = count; System.out.println("New count = " + getCount()); } public int getCount() { return count; } public static void main(String[] args) { Shadow shadow = new Shadow(); shadow.setCount(5); shadow.setCount(7); } } 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. |
With 3.2M5, inlining foo() does it. ------------------ Bug.java ------------ class Bug { byte MAX_PRIORITY; void foo(){new Byte(MAX_PRIORITY);} { new Thread(){ void bar(){foo();} }; } }