Community
Participate
Working Groups
If inferred callouts are turned on, Organize Import will also try to import private static fields, which results in errors.
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.