-
Bug
-
Resolution: Fixed
-
P2
-
6
javac should use the same accessiblity rules for symbols imported using
static import as for resolving symbols as "normal" symbol references,
but it doesn't, and this is very surprising to users.
In the unlikely event that they should be different, the error
should be reported in the static import statement, not the symbol reference.
Self-explanatory shell transcript follows:
$ cat StaticImportAccess.java
import static java.util.zip.ZipFile.ENDSIG;
public class StaticImportAccess {
public static long i = ENDSIG;
}
$ javac -source 1.5 StaticImportAccess.java
StaticImportAccess.java:4: ENDSIG in java.util.zip.ZipConstants is defined in an inaccessible class or interface
public static long i = ENDSIG;
^
1 error
zsh: exit 1 jver 1.6.0 javac -source 1.5 StaticImportAccess.java
$ cat NormalAccess.java
public class NormalAccess {
public static long i = java.util.zip.ZipFile.ENDSIG;
}
$ javac -source 1.5 NormalAccess.java
$
###@###.### 2005-2-05 19:45:21 GMT
static import as for resolving symbols as "normal" symbol references,
but it doesn't, and this is very surprising to users.
In the unlikely event that they should be different, the error
should be reported in the static import statement, not the symbol reference.
Self-explanatory shell transcript follows:
$ cat StaticImportAccess.java
import static java.util.zip.ZipFile.ENDSIG;
public class StaticImportAccess {
public static long i = ENDSIG;
}
$ javac -source 1.5 StaticImportAccess.java
StaticImportAccess.java:4: ENDSIG in java.util.zip.ZipConstants is defined in an inaccessible class or interface
public static long i = ENDSIG;
^
1 error
zsh: exit 1 jver 1.6.0 javac -source 1.5 StaticImportAccess.java
$ cat NormalAccess.java
public class NormalAccess {
public static long i = java.util.zip.ZipFile.ENDSIG;
}
$ javac -source 1.5 NormalAccess.java
$
###@###.### 2005-2-05 19:45:21 GMT
- relates to
-
JDK-6214959 Compiler fails to produce error message with ODD number of import static
- Closed
-
JDK-6392998 REGRESSION/CONFORMANCE: Mustang compiler throws AssertionError (beta2-b71 and higher)
- Closed