java compiler mistaking field reference with a package name?

Viewed 36

i have the following (simplified) class:

public class ConfusingClass {
   private static Object STATIC_FIELD =  org.library.Class.getSomething(); //BOOM

   public int org;
}

this gets me a compilation error - non-static field org cannot be referenced from a static context.

only thats not what im doing at all - im merely referring to org.library.Class by its FQCN.

I know that for this contrived example adding an import for org.library.Class would resolve this. but if for some reason imports cannot be used (because this code is being generated, and because there may be complicting class names requiring the use of FQCNs everywhere) - is this solvable?

is there some way for me to tell the java compiler this is not an attempt to access field "org" ? is tthere some isotetric syntax that may help here?

0 Answers
Related