mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
6930076: "null" can incorrectly appear in error message compiler.err.error.reading.file
Reviewed-by: darcy
This commit is contained in:
parent
97162a48b1
commit
9ce36383eb
3 changed files with 24 additions and 5 deletions
|
@ -260,7 +260,7 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||||
archive = openArchive(directory);
|
archive = openArchive(directory);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
log.error("error.reading.file",
|
log.error("error.reading.file",
|
||||||
directory, ex.getLocalizedMessage());
|
directory, getMessage(ex));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,7 +489,7 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||||
archive = new MissingArchive(zipFileName);
|
archive = new MissingArchive(zipFileName);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
if (zipFileName.exists())
|
if (zipFileName.exists())
|
||||||
log.error("error.reading.file", zipFileName, ex.getLocalizedMessage());
|
log.error("error.reading.file", zipFileName, getMessage(ex));
|
||||||
archive = new MissingArchive(zipFileName);
|
archive = new MissingArchive(zipFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,4 +838,23 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Invalid relative path: " + file);
|
throw new IllegalArgumentException("Invalid relative path: " + file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a detail message from an IOException.
|
||||||
|
* Most, but not all, instances of IOException provide a non-null result
|
||||||
|
* for getLocalizedMessage(). But some instances return null: in these
|
||||||
|
* cases, fallover to getMessage(), and if even that is null, return the
|
||||||
|
* name of the exception itself.
|
||||||
|
* @param e an IOException
|
||||||
|
* @return a string to include in a compiler diagnostic
|
||||||
|
*/
|
||||||
|
public static String getMessage(IOException e) {
|
||||||
|
String s = e.getLocalizedMessage();
|
||||||
|
if (s != null)
|
||||||
|
return s;
|
||||||
|
s = e.getMessage();
|
||||||
|
if (s != null)
|
||||||
|
return s;
|
||||||
|
return e.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,7 +320,7 @@ public class Paths {
|
||||||
addFile(f, warn);
|
addFile(f, warn);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("error.reading.file", jarFile, e.getLocalizedMessage());
|
log.error("error.reading.file", jarFile, JavacFileManager.getMessage(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,7 +558,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
||||||
inputFiles.add(filename);
|
inputFiles.add(filename);
|
||||||
return filename.getCharContent(false);
|
return filename.getCharContent(false);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("error.reading.file", filename, e.getLocalizedMessage());
|
log.error("error.reading.file", filename, JavacFileManager.getMessage(e));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -717,7 +717,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
||||||
try {
|
try {
|
||||||
tree = parse(filename, filename.getCharContent(false));
|
tree = parse(filename, filename.getCharContent(false));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("error.reading.file", filename, e);
|
log.error("error.reading.file", filename, JavacFileManager.getMessage(e));
|
||||||
tree = make.TopLevel(List.<JCTree.JCAnnotation>nil(), null, List.<JCTree>nil());
|
tree = make.TopLevel(List.<JCTree.JCAnnotation>nil(), null, List.<JCTree>nil());
|
||||||
} finally {
|
} finally {
|
||||||
log.useSource(prev);
|
log.useSource(prev);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue