-
Bug
-
Resolution: Fixed
-
P3
-
None
-
b23
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8281396 | 11.0.16-oracle | Vicente Arturo Romero Zaldivar | P3 | Resolved | Fixed | b01 |
JDK-8280097 | 11.0.15 | Liam Miller-Cushon | P3 | Resolved | Fixed | b01 |
Here's an example of a 'bad class file' diagnostic that references the path of a class file in a jar archive, and where the compilation refers to the jar via a symlink:
```
mkdir p
echo 'garbage' > p/B.class
jar cvf lib.jar p/B.class
mv lib.jar CLASSPATH
ln -s CLASSPATH lib.jar
echo 'class T extends p.B {}' > T.java
javac -cp lib.jar T.java
```
With JDK 8, the diagnostic path is `lib.jar(p/B.class)`:
```
T.java:1: error: cannot access B
class T extends p.B {}
^
bad class file: lib.jar(p/B.class)
illegal start of class file
Please remove or make sure it appears in the correct subdirectory of the classpath.
```
With JDK >= 9, the diagnostic path is absolute and uses the symlink instead of the user-provided path, e.g. it is now: `/tmp/some/absolute/path/CLASSPATH(/p/B.class)`
```
T.java:1: error: cannot access B
class T extends p.B {}
^
bad class file: /tmp/some/absolute/path/CLASSPATH(/p/B.class)
illegal start of class file
Please remove or make sure it appears in the correct subdirectory of the classpath.
1 error
```
The fix might be something like:
```
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java
@@ -313,10 +313,10 @@ synchronized Container getContainer(Path path) throws IOException {
if (attr != null) {
if (attr.isDirectory()) {
- fs = new DirectoryContainer(realPath);
+ fs = new DirectoryContainer(path);
} else {
try {
- fs = new ArchiveContainer(realPath);
+ fs = new ArchiveContainer(path);
} catch (ProviderNotFoundException | SecurityException ex) {
throw new IOException(ex);
}
```
- backported by
-
JDK-8280097 Canonicalized archive paths appearing in diagnostics
-
- Resolved
-
-
JDK-8281396 Canonicalized archive paths appearing in diagnostics
-
- Resolved
-
- relates to
-
JDK-8181897 JDK 9 change to symlink handling affects SourceFile attributes
-
- Resolved
-
-
JDK-8220634 SymLinkArchiveTest should handle not being able to create symlinks
-
- Resolved
-
-
JDK-8178017 JDK 9 change to symlink handling causes misleading class.public.should.be.in.file diagnostic
-
- Closed
-
- links to
-
Commit openjdk/jdk11u-dev/a29949b1
-
Review openjdk/jdk11u-dev/758
-
Review openjdk/jdk11u-dev/760