8130424: if directory specified with --dest-dir does not exist, only .class files are dumped and .js files are not

Reviewed-by: attila, lagergren, hannesw
This commit is contained in:
Athijegannathan Sundararajan 2015-07-03 18:41:58 +05:30
parent 52cdae26ef
commit 833d238585
2 changed files with 10 additions and 4 deletions

View File

@ -88,7 +88,7 @@ public final class DumpBytecode {
}
// should code be dumped to disk - only valid in compile_only mode?
// should code be dumped to disk
if (env._dest_dir != null) {
final String fileName = className.replace('.', File.separatorChar) + ".class";
final int index = fileName.lastIndexOf(File.separatorChar);

View File

@ -995,7 +995,7 @@ public final class Source implements Loggable {
return initLogger(Context.getContextTrusted());
}
private File dumpFile(final String dir) {
private File dumpFile(final File dirFile) {
final URL u = getURL();
final StringBuilder buf = new StringBuilder();
// make it unique by prefixing current date & time
@ -1010,11 +1010,17 @@ public final class Source implements Loggable {
buf.append(getName());
}
return new File(dir, buf.toString());
return new File(dirFile, buf.toString());
}
void dump(final String dir) {
final File file = dumpFile(dir);
final File dirFile = new File(dir);
final File file = dumpFile(dirFile);
if (!dirFile.exists() && !dirFile.mkdirs()) {
debug("Skipping source dump for " + name);
return;
}
try (final FileOutputStream fos = new FileOutputStream(file)) {
final PrintWriter pw = new PrintWriter(fos);
pw.print(data.toString());