| Summary: | [rewrite] Inferred callouts to private static fields make OrganizeImports to import private fields | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] Objectteams | Reporter: | Jan Marc Hoffmann <exelnet> | ||||
| Component: | OTDT | Assignee: | Stephan Herrmann <stephan.herrmann> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | stephan.herrmann | ||||
| Version: | 1.4 | Flags: | stephan.herrmann:
iplog+
|
||||
| Target Milestone: | 0.7 M2 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Jan Marc Hoffmann
Would you have a simple example? TIA Sure. :=)
Reproduce:
public team class SomeTeam {
protected class SomeRole playedBy Base {
m <-replace m;
@SuppressWarnings({ "inferredcallout", "decapsulation" })
callin void m(){
boolean v = field;
System.out.println(v);
}
}
}
Start Organize Imports.
Btw.: This does yield a more serious internal compiler error if used with "this" before the field. I ll file a new bug for this one.
forgot the base:
public class Base {
private static boolean field = true;
public void m(){
}
}
(In reply to comment #2)
> Sure. :=)
>
> Reproduce:
>
> public team class SomeTeam {
>
> protected class SomeRole playedBy Base {
>
> m <-replace m;
>
> @SuppressWarnings({ "inferredcallout", "decapsulation" })
> callin void m(){
> boolean v = field;
> System.out.println(v);
> }
> }
>
> }
>
> Start Organize Imports.
>
> Btw.: This does yield a more serious internal compiler error if used with
> "this" before the field. I ll file a new bug for this one.
(In reply to comment #2) Starting with your example I had to do the following: - add a class b.Base (must not reside in the same package as SomeTeam) with this content: package b; public class Base { private static boolean field; void m() {} } - organize imports once to correctly insert "import base b.Base;" - organize imports once more to see the error. The internal error I could not reproduce, so if you have instructions how to do that it would be helpful. The internal Compiler Bug goes with the id: 311509 https://bugs.eclipse.org/bugs/show_bug.cgi?id=311509 Created attachment 166937 [details]
test & fix
Don't add a static import if
- a static field is not public AND
- it is accessed by a callout (which may apply decapsulation)
Patch has been committed as r292. Verified for M2 using I201005052210 Setting iplog flag to acknowledge the contributed test case. |