A DESCRIPTION OF THE PROBLEM :
Doing a static import with a locally-defined class gives an error
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
* launch jshell
* enter the following class definition: class Test { static int ME = 0; }
* attempt to do a static import of the field Test.ME
** with a wildcard: import static Test.*;
** with an exact import: import static Test.ME;
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The imports succeed, and ME is directly accessible
ACTUAL -
jshell> import static Test.*;
| Error:
| cannot find symbol
| symbol: class Test
| import static Test.*;
| ^--^
jshell> import static Test.ME;
| Error:
| cannot find symbol
| symbol: class Test
| import static Test.ME;
| ^--^
| Error:
| static import only from classes and interfaces
| import static Test.ME;
| ^--------------------^
CUSTOMER SUBMITTED WORKAROUND :
declare the field "globally", or use the fully-qualified name of the field (i.e. Test.ME)
Doing a static import with a locally-defined class gives an error
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
* launch jshell
* enter the following class definition: class Test { static int ME = 0; }
* attempt to do a static import of the field Test.ME
** with a wildcard: import static Test.*;
** with an exact import: import static Test.ME;
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The imports succeed, and ME is directly accessible
ACTUAL -
jshell> import static Test.*;
| Error:
| cannot find symbol
| symbol: class Test
| import static Test.*;
| ^--^
jshell> import static Test.ME;
| Error:
| cannot find symbol
| symbol: class Test
| import static Test.ME;
| ^--^
| Error:
| static import only from classes and interfaces
| import static Test.ME;
| ^--------------------^
CUSTOMER SUBMITTED WORKAROUND :
declare the field "globally", or use the fully-qualified name of the field (i.e. Test.ME)