--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,19 +25,20 @@
package com.sun.tools.javac.file;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.CharsetDecoder;
-import java.nio.file.Path;
-
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.FileObject;
import javax.tools.JavaFileObject;
+import static javax.tools.JavaFileObject.Kind.*;
+
import com.sun.tools.javac.util.BaseFileManager;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
@@ -77,7 +78,7 @@
throw new UnsupportedOperationException();
}
- protected abstract String inferBinaryName(Iterable<? extends Path> path);
+ protected abstract String inferBinaryName(Iterable<? extends File> path);
protected static JavaFileObject.Kind getKind(String filename) {
return BaseFileManager.getKind(filename);
@@ -88,8 +89,8 @@
return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
}
- protected static URI createJarUri(Path jarFile, String entryName) {
- URI jarURI = jarFile.toUri().normalize();
+ protected static URI createJarUri(File jarFile, String entryName) {
+ URI jarURI = jarFile.toURI().normalize();
String separator = entryName.startsWith("/") ? "!" : "!/";
try {
// The jar URI convention appears to be not to re-encode the jarURI
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/CacheFSInfo.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/CacheFSInfo.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,8 @@
package com.sun.tools.javac.file;
+import java.io.File;
import java.io.IOException;
-import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -61,31 +61,31 @@
}
@Override
- public Path getCanonicalFile(Path file) {
+ public File getCanonicalFile(File file) {
Entry e = getEntry(file);
return e.canonicalFile;
}
@Override
- public boolean exists(Path file) {
+ public boolean exists(File file) {
Entry e = getEntry(file);
return e.exists;
}
@Override
- public boolean isDirectory(Path file) {
+ public boolean isDirectory(File file) {
Entry e = getEntry(file);
return e.isDirectory;
}
@Override
- public boolean isFile(Path file) {
+ public boolean isFile(File file) {
Entry e = getEntry(file);
return e.isFile;
}
@Override
- public List<Path> getJarClassPath(Path file) throws IOException {
+ public List<File> getJarClassPath(File file) throws IOException {
// don't bother to lock the cache, because it is thread-safe, and
// because the worst that can happen would be to create two identical
// jar class paths together and have one overwrite the other.
@@ -95,7 +95,7 @@
return e.jarClassPath;
}
- private Entry getEntry(Path file) {
+ private Entry getEntry(File file) {
// don't bother to lock the cache, because it is thread-safe, and
// because the worst that can happen would be to create two identical
// entries together and have one overwrite the other.
@@ -112,13 +112,13 @@
}
// could also be a Map<File,SoftReference<Entry>> ?
- private final Map<Path,Entry> cache = new ConcurrentHashMap<>();
+ private Map<File,Entry> cache = new ConcurrentHashMap<>();
private static class Entry {
- Path canonicalFile;
+ File canonicalFile;
boolean exists;
boolean isFile;
boolean isDirectory;
- List<Path> jarClassPath;
+ List<File> jarClassPath;
}
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/FSInfo.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/FSInfo.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,10 +1,8 @@
package com.sun.tools.javac.file;
+import java.io.File;
import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -44,29 +42,29 @@
context.put(FSInfo.class, this);
}
- public Path getCanonicalFile(Path file) {
+ public File getCanonicalFile(File file) {
try {
- return file.toRealPath();
+ return file.getCanonicalFile();
} catch (IOException e) {
- return file.toAbsolutePath();
+ return file.getAbsoluteFile();
}
}
- public boolean exists(Path file) {
- return Files.exists(file);
+ public boolean exists(File file) {
+ return file.exists();
}
- public boolean isDirectory(Path file) {
- return Files.isDirectory(file);
+ public boolean isDirectory(File file) {
+ return file.isDirectory();
}
- public boolean isFile(Path file) {
- return Files.isRegularFile(file);
+ public boolean isFile(File file) {
+ return file.isFile();
}
- public List<Path> getJarClassPath(Path file) throws IOException {
- Path parent = file.getParent();
- try (JarFile jarFile = new JarFile(file.toFile())) {
+ public List<File> getJarClassPath(File file) throws IOException {
+ String parent = file.getParent();
+ try (JarFile jarFile = new JarFile(file)) {
Manifest man = jarFile.getManifest();
if (man == null)
return Collections.emptyList();
@@ -79,14 +77,14 @@
if (path == null)
return Collections.emptyList();
- List<Path> list = new ArrayList<>();
+ List<File> list = new ArrayList<>();
for (StringTokenizer st = new StringTokenizer(path);
st.hasMoreTokens(); ) {
String elt = st.nextToken();
- Path f = Paths.get(elt);
+ File f = new File(elt);
if (!f.isAbsolute() && parent != null)
- f = parent.resolve(f).toAbsolutePath();
+ f = new File(parent,elt).getAbsoluteFile();
list.add(f);
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Tue Oct 21 17:50:13 2014 -0700
@@ -25,19 +25,17 @@
package com.sun.tools.javac.file;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.NoSuchFileException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -48,8 +46,6 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
import java.util.zip.ZipFile;
import javax.lang.model.SourceVersion;
@@ -58,8 +54,8 @@
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
+import com.sun.tools.javac.file.RelativePath.RelativeFile;
import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
-import com.sun.tools.javac.file.RelativePath.RelativeFile;
import com.sun.tools.javac.util.BaseFileManager;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.DefinedBy;
@@ -98,15 +94,15 @@
protected boolean mmappedIO;
protected boolean symbolFileEnabled;
- protected enum SortFiles implements Comparator<Path> {
+ protected enum SortFiles implements Comparator<File> {
FORWARD {
- public int compare(Path f1, Path f2) {
- return f1.getFileName().compareTo(f2.getFileName());
+ public int compare(File f1, File f2) {
+ return f1.getName().compareTo(f2.getName());
}
},
REVERSE {
- public int compare(Path f1, Path f2) {
- return -f1.getFileName().compareTo(f2.getFileName());
+ public int compare(File f1, File f2) {
+ return -f1.getName().compareTo(f2.getName());
}
}
}
@@ -165,10 +161,10 @@
}
public JavaFileObject getFileForInput(String name) {
- return getRegularFile(Paths.get(name));
+ return getRegularFile(new File(name));
}
- public JavaFileObject getRegularFile(Path file) {
+ public JavaFileObject getRegularFile(File file) {
return new RegularFileObject(this, file);
}
@@ -258,26 +254,25 @@
* Insert all files in subdirectory subdirectory of directory directory
* which match fileKinds into resultList
*/
- private void listDirectory(Path directory,
+ private void listDirectory(File directory,
RelativeDirectory subdirectory,
Set<JavaFileObject.Kind> fileKinds,
boolean recurse,
ListBuffer<JavaFileObject> resultList) {
- Path d = subdirectory.getFile(directory);
+ File d = subdirectory.getFile(directory);
if (!caseMapCheck(d, subdirectory))
return;
-
- java.util.List<Path> files;
- try (Stream<Path> s = Files.list(d)) {
- files = (sortFiles == null ? s : s.sorted(sortFiles)).collect(Collectors.toList());
- } catch (IOException ignore) {
+ File[] files = d.listFiles();
+ if (files == null)
return;
- }
+
+ if (sortFiles != null)
+ Arrays.sort(files, sortFiles);
- for (Path f: files) {
- String fname = f.getFileName().toString();
- if (Files.isDirectory(f)) {
+ for (File f: files) {
+ String fname = f.getName();
+ if (f.isDirectory()) {
if (recurse && SourceVersion.isIdentifier(fname)) {
listDirectory(directory,
new RelativeDirectory(subdirectory, fname),
@@ -288,7 +283,7 @@
} else {
if (isValidFile(fname, fileKinds)) {
JavaFileObject fe =
- new RegularFileObject(this, fname, d.resolve(fname));
+ new RegularFileObject(this, fname, new File(d, fname));
resultList.append(fe);
}
}
@@ -331,7 +326,7 @@
* Insert all files in subdirectory subdirectory of container which
* match fileKinds into resultList
*/
- private void listContainer(Path container,
+ private void listContainer(File container,
RelativeDirectory subdirectory,
Set<JavaFileObject.Kind> fileKinds,
boolean recurse,
@@ -376,13 +371,13 @@
* ends in a string of characters with the same case as given name.
* Ignore file separators in both path and name.
*/
- private boolean caseMapCheck(Path f, RelativePath name) {
+ private boolean caseMapCheck(File f, RelativePath name) {
if (fileSystemIsCaseSensitive) return true;
// Note that getCanonicalPath() returns the case-sensitive
// spelled file name.
String path;
try {
- path = f.toRealPath().toString();
+ path = f.getCanonicalPath();
} catch (IOException ex) {
return false;
}
@@ -419,8 +414,8 @@
}
public class MissingArchive implements Archive {
- final Path zipFileName;
- public MissingArchive(Path name) {
+ final File zipFileName;
+ public MissingArchive(File name) {
zipFileName = name;
}
public boolean contains(RelativePath name) {
@@ -450,7 +445,7 @@
/** A directory of zip files already opened.
*/
- Map<Path, Archive> archives = new HashMap<>();
+ Map<File, Archive> archives = new HashMap<>();
private static final String[] symbolFileLocation = { "lib", "ct.sym" };
private static final RelativeDirectory symbolFilePrefix
@@ -462,7 +457,7 @@
* fail over to the platform zip, and allow it to deal with a potentially
* non compliant zip file.
*/
- protected Archive openArchive(Path zipFilename) throws IOException {
+ protected Archive openArchive(File zipFilename) throws IOException {
try {
return openArchive(zipFilename, contextUseOptimizedZip);
} catch (IOException ioe) {
@@ -476,17 +471,17 @@
/** Open a new zip file directory, and cache it.
*/
- private Archive openArchive(Path zipFileName, boolean useOptimizedZip) throws IOException {
- Path origZipFileName = zipFileName;
+ private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException {
+ File origZipFileName = zipFileName;
if (symbolFileEnabled && locations.isDefaultBootClassPathRtJar(zipFileName)) {
- Path file = zipFileName.getParent().getParent(); // ${java.home}
- if (file.getFileName().equals(Paths.get("jre")))
- file = file.getParent();
+ File file = zipFileName.getParentFile().getParentFile(); // ${java.home}
+ if (new File(file.getName()).equals(new File("jre")))
+ file = file.getParentFile();
// file == ${jdk.home}
for (String name : symbolFileLocation)
- file = file.resolve(name);
+ file = new File(file, name);
// file == ${jdk.home}/lib/ct.sym
- if (Files.exists(file))
+ if (file.exists())
zipFileName = file;
}
@@ -499,7 +494,7 @@
String preindexCacheLocation = null;
if (!useOptimizedZip) {
- zdir = new ZipFile(zipFileName.toFile());
+ zdir = new ZipFile(zipFileName);
} else {
usePreindexedCache = options.isSet("usezipindex");
preindexCacheLocation = options.get("java.io.tmpdir");
@@ -549,12 +544,12 @@
options.isSet("writezipindexfiles")));
}
}
- } catch (FileNotFoundException | NoSuchFileException ex) {
+ } catch (FileNotFoundException ex) {
archive = new MissingArchive(zipFileName);
} catch (ZipFileIndex.ZipFormatException zfe) {
throw zfe;
} catch (IOException ex) {
- if (Files.exists(zipFileName))
+ if (zipFileName.exists())
log.error("error.reading.file", zipFileName, getMessage(ex));
archive = new MissingArchive(zipFileName);
}
@@ -614,13 +609,13 @@
nullCheck(packageName);
nullCheck(kinds);
- Iterable<? extends Path> path = asPaths(getLocation(location));
+ Iterable<? extends File> path = getLocation(location);
if (path == null)
return List.nil();
RelativeDirectory subdirectory = RelativeDirectory.forPackage(packageName);
ListBuffer<JavaFileObject> results = new ListBuffer<>();
- for (Path directory : path)
+ for (File directory : path)
listContainer(directory, subdirectory, kinds, recurse, results);
return results.toList();
}
@@ -630,7 +625,7 @@
file.getClass(); // null check
location.getClass(); // null check
// Need to match the path semantics of list(location, ...)
- Iterable<? extends Path> path = getLocationAsPaths(location);
+ Iterable<? extends File> path = getLocation(location);
if (path == null) {
return null;
}
@@ -690,16 +685,16 @@
}
private JavaFileObject getFileForInput(Location location, RelativeFile name) throws IOException {
- Iterable<? extends Path> path = asPaths(getLocation(location));
+ Iterable<? extends File> path = getLocation(location);
if (path == null)
return null;
- for (Path dir: path) {
+ for (File dir: path) {
Archive a = archives.get(dir);
if (a == null) {
if (fsInfo.isDirectory(dir)) {
- Path f = name.getFile(dir);
- if (Files.exists(f))
+ File f = name.getFile(dir);
+ if (f.exists())
return new RegularFileObject(this, f);
continue;
}
@@ -753,32 +748,29 @@
FileObject sibling)
throws IOException
{
- Path dir;
+ File dir;
if (location == CLASS_OUTPUT) {
if (getClassOutDir() != null) {
dir = getClassOutDir();
} else {
- Path siblingDir = null;
+ File siblingDir = null;
if (sibling != null && sibling instanceof RegularFileObject) {
- siblingDir = ((RegularFileObject)sibling).file.getParent();
+ siblingDir = ((RegularFileObject)sibling).file.getParentFile();
}
- if (siblingDir == null)
- return new RegularFileObject(this, Paths.get(fileName.basename()));
- else
- return new RegularFileObject(this, siblingDir.resolve(fileName.basename()));
+ return new RegularFileObject(this, new File(siblingDir, fileName.basename()));
}
} else if (location == SOURCE_OUTPUT) {
dir = (getSourceOutDir() != null ? getSourceOutDir() : getClassOutDir());
} else {
- Iterable<? extends Path> path = locations.getLocation(location);
+ Iterable<? extends File> path = locations.getLocation(location);
dir = null;
- for (Path f: path) {
+ for (File f: path) {
dir = f;
break;
}
}
- Path file = fileName.getFile(dir); // null-safe
+ File file = fileName.getFile(dir); // null-safe
return new RegularFileObject(this, file);
}
@@ -793,7 +785,7 @@
else
result = new ArrayList<>();
for (File f: files)
- result.add(new RegularFileObject(this, nullCheck(f).toPath()));
+ result.add(new RegularFileObject(this, nullCheck(f)));
return result;
}
@@ -804,29 +796,24 @@
@DefinedBy(Api.COMPILER)
public void setLocation(Location location,
- Iterable<? extends File> searchpath)
+ Iterable<? extends File> path)
throws IOException
{
nullCheck(location);
- locations.setLocation(location, asPaths(searchpath));
+ locations.setLocation(location, path);
}
@DefinedBy(Api.COMPILER)
public Iterable<? extends File> getLocation(Location location) {
nullCheck(location);
- return asFiles(locations.getLocation(location));
- }
-
- private Iterable<? extends Path> getLocationAsPaths(Location location) {
- nullCheck(location);
return locations.getLocation(location);
}
- private Path getClassOutDir() {
+ private File getClassOutDir() {
return locations.getOutputLocation(CLASS_OUTPUT);
}
- private Path getSourceOutDir() {
+ private File getSourceOutDir() {
return locations.getOutputLocation(SOURCE_OUTPUT);
}
@@ -897,50 +884,4 @@
return s;
return e.toString();
}
-
- /* Converters between files and paths.
- * These are temporary until we can update the StandardJavaFileManager API.
- */
-
- static Iterable<Path> asPaths(final Iterable<? extends File> files) {
- if (files == null)
- return null;
-
- return () -> new Iterator<Path>() {
- Iterator<? extends File> iter = files.iterator();
-
- @Override
- public boolean hasNext() {
- return iter.hasNext();
- }
-
- @Override
- public Path next() {
- return iter.next().toPath();
- }
- };
- }
-
- static Iterable<File> asFiles(final Iterable<? extends Path> paths) {
- if (paths == null)
- return null;
-
- return () -> new Iterator<File>() {
- Iterator<? extends Path> iter = paths.iterator();
-
- @Override
- public boolean hasNext() {
- return iter.hasNext();
- }
-
- @Override
- public File next() {
- return iter.next().toFile();
- }
- };
- }
-
- static File asFile(Path path) {
- return path == null ? null : path.toFile();
- }
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Tue Oct 21 17:50:13 2014 -0700
@@ -29,10 +29,6 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -44,8 +40,7 @@
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
-import java.util.regex.Pattern;
-import java.util.stream.Stream;
+import java.util.StringTokenizer;
import java.util.zip.ZipFile;
import javax.tools.JavaFileManager;
@@ -110,7 +105,7 @@
this.fsInfo = fsInfo;
}
- public Collection<Path> bootClassPath() {
+ public Collection<File> bootClassPath() {
return getLocation(PLATFORM_CLASS_PATH);
}
@@ -120,52 +115,56 @@
return h.isDefault();
}
- boolean isDefaultBootClassPathRtJar(Path file) {
+ boolean isDefaultBootClassPathRtJar(File file) {
BootClassPathLocationHandler h
= (BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH);
return h.isDefaultRtJar(file);
}
- public Collection<Path> userClassPath() {
+ public Collection<File> userClassPath() {
return getLocation(CLASS_PATH);
}
- public Collection<Path> sourcePath() {
- Collection<Path> p = getLocation(SOURCE_PATH);
+ public Collection<File> sourcePath() {
+ Collection<File> p = getLocation(SOURCE_PATH);
// TODO: this should be handled by the LocationHandler
return p == null || p.isEmpty() ? null : p;
}
/**
- * Split a search path into its elements. Empty path elements will be ignored.
+ * Split a path into its elements. Empty path elements will be ignored.
*
- * @param searchPath The search path to be split
+ * @param path The path to be split
* @return The elements of the path
*/
- private static Iterable<Path> getPathEntries(String searchPath) {
- return getPathEntries(searchPath, null);
+ private static Iterable<File> getPathEntries(String path) {
+ return getPathEntries(path, null);
}
/**
- * Split a search path into its elements. If emptyPathDefault is not null, all empty elements in the
+ * Split a path into its elements. If emptyPathDefault is not null, all empty elements in the
* path, including empty elements at either end of the path, will be replaced with the value of
* emptyPathDefault.
*
- * @param searchPath The search path to be split
+ * @param path The path to be split
* @param emptyPathDefault The value to substitute for empty path elements, or null, to ignore
* empty path elements
* @return The elements of the path
*/
- private static Iterable<Path> getPathEntries(String searchPath, Path emptyPathDefault) {
- ListBuffer<Path> entries = new ListBuffer<>();
- for (String s: searchPath.split(Pattern.quote(File.pathSeparator), -1)) {
- if (s.isEmpty()) {
- if (emptyPathDefault != null) {
- entries.add(emptyPathDefault);
- }
- } else {
- entries.add(Paths.get(s));
+ private static Iterable<File> getPathEntries(String path, File emptyPathDefault) {
+ ListBuffer<File> entries = new ListBuffer<>();
+ int start = 0;
+ while (start <= path.length()) {
+ int sep = path.indexOf(File.pathSeparatorChar, start);
+ if (sep == -1) {
+ sep = path.length();
}
+ if (start < sep) {
+ entries.add(new File(path.substring(start, sep)));
+ } else if (emptyPathDefault != null) {
+ entries.add(emptyPathDefault);
+ }
+ start = sep + 1;
}
return entries;
}
@@ -174,12 +173,12 @@
* Utility class to help evaluate a path option. Duplicate entries are ignored, jar class paths
* can be expanded.
*/
- private class SearchPath extends LinkedHashSet<Path> {
+ private class SearchPath extends LinkedHashSet<File> {
private static final long serialVersionUID = 0;
private boolean expandJarClassPaths = false;
- private final Set<Path> canonicalValues = new HashSet<>();
+ private final Set<File> canonicalValues = new HashSet<>();
public SearchPath expandJarClassPaths(boolean x) {
expandJarClassPaths = x;
@@ -189,9 +188,9 @@
/**
* What to use when path element is the empty string
*/
- private Path emptyPathDefault = null;
+ private File emptyPathDefault = null;
- public SearchPath emptyPathDefault(Path x) {
+ public SearchPath emptyPathDefault(File x) {
emptyPathDefault = x;
return this;
}
@@ -201,7 +200,7 @@
expandJarClassPaths = true;
try {
if (dirs != null) {
- for (Path dir : getPathEntries(dirs)) {
+ for (File dir : getPathEntries(dirs)) {
addDirectory(dir, warn);
}
}
@@ -215,8 +214,8 @@
return addDirectories(dirs, warn);
}
- private void addDirectory(Path dir, boolean warn) {
- if (!Files.isDirectory(dir)) {
+ private void addDirectory(File dir, boolean warn) {
+ if (!dir.isDirectory()) {
if (warn) {
log.warning(Lint.LintCategory.PATH,
"dir.path.element.not.found", dir);
@@ -224,10 +223,15 @@
return;
}
- try (Stream<Path> s = Files.list(dir)) {
- s.filter(dirEntry -> isArchive(dirEntry))
- .forEach(dirEntry -> addFile(dirEntry, warn));
- } catch (IOException ignore) {
+ File[] files = dir.listFiles();
+ if (files == null) {
+ return;
+ }
+
+ for (File direntry : files) {
+ if (isArchive(direntry)) {
+ addFile(direntry, warn);
+ }
}
}
@@ -242,20 +246,20 @@
return addFiles(files, warn);
}
- public SearchPath addFiles(Iterable<? extends Path> files, boolean warn) {
+ public SearchPath addFiles(Iterable<? extends File> files, boolean warn) {
if (files != null) {
- for (Path file : files) {
+ for (File file : files) {
addFile(file, warn);
}
}
return this;
}
- public SearchPath addFiles(Iterable<? extends Path> files) {
+ public SearchPath addFiles(Iterable<? extends File> files) {
return addFiles(files, warn);
}
- public void addFile(Path file, boolean warn) {
+ public void addFile(File file, boolean warn) {
if (contains(file)) {
// discard duplicates
return;
@@ -271,7 +275,7 @@
return;
}
- Path canonFile = fsInfo.getCanonicalFile(file);
+ File canonFile = fsInfo.getCanonicalFile(file);
if (canonicalValues.contains(canonFile)) {
/* Discard duplicates and avoid infinite recursion */
return;
@@ -283,7 +287,7 @@
/* Not a recognized extension; open it to see if
it looks like a valid zip file. */
try {
- ZipFile z = new ZipFile(file.toFile());
+ ZipFile z = new ZipFile(file);
z.close();
if (warn) {
log.warning(Lint.LintCategory.PATH,
@@ -314,9 +318,9 @@
// Manifest entry. In some future release, we may want to
// update this code to recognize URLs rather than simple
// filenames, but if we do, we should redo all path-related code.
- private void addJarClassPath(Path jarFile, boolean warn) {
+ private void addJarClassPath(File jarFile, boolean warn) {
try {
- for (Path f : fsInfo.getJarClassPath(jarFile)) {
+ for (File f : fsInfo.getJarClassPath(jarFile)) {
addFile(f, warn);
}
} catch (IOException e) {
@@ -361,12 +365,12 @@
/**
* @see StandardJavaFileManager#getLocation
*/
- abstract Collection<Path> getLocation();
+ abstract Collection<File> getLocation();
/**
* @see StandardJavaFileManager#setLocation
*/
- abstract void setLocation(Iterable<? extends Path> files) throws IOException;
+ abstract void setLocation(Iterable<? extends File> files) throws IOException;
}
/**
@@ -376,7 +380,7 @@
*/
private class OutputLocationHandler extends LocationHandler {
- private Path outputDir;
+ private File outputDir;
OutputLocationHandler(Location location, Option... options) {
super(location, options);
@@ -392,31 +396,31 @@
// need to decide how best to report issue for benefit of
// direct API call on JavaFileManager.handleOption(specifies IAE)
// vs. command line decoding.
- outputDir = (value == null) ? null : Paths.get(value);
+ outputDir = (value == null) ? null : new File(value);
return true;
}
@Override
- Collection<Path> getLocation() {
+ Collection<File> getLocation() {
return (outputDir == null) ? null : Collections.singleton(outputDir);
}
@Override
- void setLocation(Iterable<? extends Path> files) throws IOException {
+ void setLocation(Iterable<? extends File> files) throws IOException {
if (files == null) {
outputDir = null;
} else {
- Iterator<? extends Path> pathIter = files.iterator();
+ Iterator<? extends File> pathIter = files.iterator();
if (!pathIter.hasNext()) {
throw new IllegalArgumentException("empty path for directory");
}
- Path dir = pathIter.next();
+ File dir = pathIter.next();
if (pathIter.hasNext()) {
throw new IllegalArgumentException("path too long for directory");
}
- if (!Files.exists(dir)) {
+ if (!dir.exists()) {
throw new FileNotFoundException(dir + ": does not exist");
- } else if (!Files.isDirectory(dir)) {
+ } else if (!dir.isDirectory()) {
throw new IOException(dir + ": not a directory");
}
outputDir = dir;
@@ -431,7 +435,7 @@
*/
private class SimpleLocationHandler extends LocationHandler {
- protected Collection<Path> searchPath;
+ protected Collection<File> searchPath;
SimpleLocationHandler(Location location, Option... options) {
super(location, options);
@@ -448,12 +452,12 @@
}
@Override
- Collection<Path> getLocation() {
+ Collection<File> getLocation() {
return searchPath;
}
@Override
- void setLocation(Iterable<? extends Path> files) {
+ void setLocation(Iterable<? extends File> files) {
SearchPath p;
if (files == null) {
p = computePath(null);
@@ -484,7 +488,7 @@
}
@Override
- Collection<Path> getLocation() {
+ Collection<File> getLocation() {
lazy();
return searchPath;
}
@@ -516,7 +520,7 @@
protected SearchPath createPath() {
return new SearchPath()
.expandJarClassPaths(true) // Only search user jars for Class-Paths
- .emptyPathDefault(Paths.get(".")); // Empty path elt ==> current directory
+ .emptyPathDefault(new File(".")); // Empty path elt ==> current directory
}
private void lazy() {
@@ -535,14 +539,14 @@
*/
private class BootClassPathLocationHandler extends LocationHandler {
- private Collection<Path> searchPath;
+ private Collection<File> searchPath;
final Map<Option, String> optionValues = new EnumMap<>(Option.class);
/**
* rt.jar as found on the default bootclasspath. If the user specified a bootclasspath, null
* is used.
*/
- private Path defaultBootClassPathRtJar = null;
+ private File defaultBootClassPathRtJar = null;
/**
* Is bootclasspath the default?
@@ -563,7 +567,7 @@
return isDefaultBootClassPath;
}
- boolean isDefaultRtJar(Path file) {
+ boolean isDefaultRtJar(File file) {
lazy();
return file.equals(defaultBootClassPathRtJar);
}
@@ -600,13 +604,13 @@
}
@Override
- Collection<Path> getLocation() {
+ Collection<File> getLocation() {
lazy();
return searchPath;
}
@Override
- void setLocation(Iterable<? extends Path> files) {
+ void setLocation(Iterable<? extends File> files) {
if (files == null) {
searchPath = null; // reset to "uninitialized"
} else {
@@ -641,9 +645,9 @@
// Standard system classes for this compiler's release.
String files = System.getProperty("sun.boot.class.path");
path.addFiles(files, false);
- Path rt_jar = Paths.get("rt.jar");
- for (Path file : getPathEntries(files)) {
- if (file.getFileName().equals(rt_jar)) {
+ File rt_jar = new File("rt.jar");
+ for (File file : getPathEntries(files)) {
+ if (new File(file.getName()).equals(rt_jar)) {
defaultBootClassPathRtJar = file;
}
}
@@ -705,12 +709,12 @@
return (h == null ? false : h.handleOption(option, value));
}
- Collection<Path> getLocation(Location location) {
+ Collection<File> getLocation(Location location) {
LocationHandler h = getHandler(location);
return (h == null ? null : h.getLocation());
}
- Path getOutputLocation(Location location) {
+ File getOutputLocation(Location location) {
if (!location.isOutputLocation()) {
throw new IllegalArgumentException();
}
@@ -718,7 +722,7 @@
return ((OutputLocationHandler) h).outputDir;
}
- void setLocation(Location location, Iterable<? extends Path> files) throws IOException {
+ void setLocation(Location location, Iterable<? extends File> files) throws IOException {
LocationHandler h = getHandler(location);
if (h == null) {
if (location.isOutputLocation()) {
@@ -739,8 +743,8 @@
/**
* Is this the name of an archive file?
*/
- private boolean isArchive(Path file) {
- String n = StringUtils.toLowerCase(file.getFileName().toString());
+ private boolean isArchive(File file) {
+ String n = StringUtils.toLowerCase(file.getName());
return fsInfo.isFile(file)
&& (n.endsWith(".jar") || n.endsWith(".zip"));
}
@@ -749,41 +753,50 @@
* Utility method for converting a search path string to an array of directory and JAR file
* URLs.
*
- * Note that this method is called by the DocletInvoker.
+ * Note that this method is called by apt and the DocletInvoker.
*
* @param path the search path string
* @return the resulting array of directory and JAR file URLs
*/
public static URL[] pathToURLs(String path) {
- java.util.List<URL> urls = new ArrayList<>();
- for (String s: path.split(Pattern.quote(File.pathSeparator))) {
- if (!s.isEmpty()) {
- URL url = fileToURL(Paths.get(s));
- if (url != null) {
- urls.add(url);
- }
+ StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
+ URL[] urls = new URL[st.countTokens()];
+ int count = 0;
+ while (st.hasMoreTokens()) {
+ URL url = fileToURL(new File(st.nextToken()));
+ if (url != null) {
+ urls[count++] = url;
}
}
- return urls.toArray(new URL[urls.size()]);
+ urls = Arrays.copyOf(urls, count);
+ return urls;
}
/**
* Returns the directory or JAR file URL corresponding to the specified local file name.
*
- * @param file the Path object
+ * @param file the File object
* @return the resulting directory or JAR file URL, or null if unknown
*/
- private static URL fileToURL(Path file) {
- Path p;
+ private static URL fileToURL(File file) {
+ String name;
try {
- p = file.toRealPath();
+ name = file.getCanonicalPath();
} catch (IOException e) {
- p = file.toAbsolutePath();
+ name = file.getAbsolutePath();
+ }
+ name = name.replace(File.separatorChar, '/');
+ if (!name.startsWith("/")) {
+ name = "/" + name;
+ }
+ // If the file does not exist, then assume that it's a directory
+ if (!file.isFile()) {
+ name = name + "/";
}
try {
- return p.normalize().toUri().toURL();
+ return new URL("file", "", name);
} catch (MalformedURLException e) {
- return null;
+ throw new IllegalArgumentException(file.toString());
}
}
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RegularFileObject.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RegularFileObject.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,9 @@
package com.sun.tools.javac.file;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -36,13 +39,9 @@
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharsetDecoder;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
+import javax.tools.JavaFileObject;
import java.text.Normalizer;
-import javax.tools.JavaFileObject;
-
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
@@ -60,33 +59,33 @@
*/
private boolean hasParents = false;
private String name;
- final Path file;
- private Reference<Path> absFileRef;
+ final File file;
+ private Reference<File> absFileRef;
final static boolean isMacOS = System.getProperty("os.name", "").contains("OS X");
- public RegularFileObject(JavacFileManager fileManager, Path f) {
- this(fileManager, f.getFileName().toString(), f);
+ public RegularFileObject(JavacFileManager fileManager, File f) {
+ this(fileManager, f.getName(), f);
}
- public RegularFileObject(JavacFileManager fileManager, String name, Path f) {
+ public RegularFileObject(JavacFileManager fileManager, String name, File f) {
super(fileManager);
- if (Files.isDirectory(f)) {
+ if (f.isDirectory()) {
throw new IllegalArgumentException("directories not supported");
}
this.name = name;
this.file = f;
- if (getLastModified() > System.currentTimeMillis())
+ if (f.lastModified() > System.currentTimeMillis())
fileManager.log.warning("file.from.future", f);
}
@Override @DefinedBy(Api.COMPILER)
public URI toUri() {
- return file.toUri().normalize();
+ return file.toURI().normalize();
}
@Override @DefinedBy(Api.COMPILER)
public String getName() {
- return file.toString();
+ return file.getPath();
}
@Override
@@ -101,21 +100,21 @@
@Override @DefinedBy(Api.COMPILER)
public InputStream openInputStream() throws IOException {
- return Files.newInputStream(file);
+ return new FileInputStream(file);
}
@Override @DefinedBy(Api.COMPILER)
public OutputStream openOutputStream() throws IOException {
fileManager.flushCache(this);
ensureParentDirectoriesExist();
- return Files.newOutputStream(file);
+ return new FileOutputStream(file);
}
@Override @DefinedBy(Api.COMPILER)
public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
CharBuffer cb = fileManager.getCachedContent(this);
if (cb == null) {
- try (InputStream in = Files.newInputStream(file)) {
+ try (InputStream in = new FileInputStream(file)) {
ByteBuffer bb = fileManager.makeByteBuffer(in);
JavaFileObject prev = fileManager.log.useSource(this);
try {
@@ -136,26 +135,17 @@
public Writer openWriter() throws IOException {
fileManager.flushCache(this);
ensureParentDirectoriesExist();
- return new OutputStreamWriter(Files.newOutputStream(file), fileManager.getEncodingName());
+ return new OutputStreamWriter(new FileOutputStream(file), fileManager.getEncodingName());
}
@Override @DefinedBy(Api.COMPILER)
public long getLastModified() {
- try {
- return Files.getLastModifiedTime(file).toMillis();
- } catch (IOException e) {
- return 0;
- }
+ return file.lastModified();
}
@Override @DefinedBy(Api.COMPILER)
public boolean delete() {
- try {
- Files.delete(file);
- return true;
- } catch (IOException e) {
- return false;
- }
+ return file.delete();
}
@Override
@@ -164,21 +154,20 @@
}
@Override
- protected String inferBinaryName(Iterable<? extends Path> path) {
- String fPath = file.toString();
+ protected String inferBinaryName(Iterable<? extends File> path) {
+ String fPath = file.getPath();
//System.err.println("RegularFileObject " + file + " " +r.getPath());
- for (Path dir: path) {
+ for (File dir: path) {
//System.err.println("dir: " + dir);
- String sep = dir.getFileSystem().getSeparator();
- String dPath = dir.toString();
+ String dPath = dir.getPath();
if (dPath.length() == 0)
dPath = System.getProperty("user.dir");
- if (!dPath.endsWith(sep))
- dPath += sep;
+ if (!dPath.endsWith(File.separator))
+ dPath += File.separator;
if (fPath.regionMatches(true, 0, dPath, 0, dPath.length())
- && Paths.get(fPath.substring(0, dPath.length())).equals(Paths.get(dPath))) {
+ && new File(fPath.substring(0, dPath.length())).equals(new File(dPath))) {
String relativeName = fPath.substring(dPath.length());
- return removeExtension(relativeName).replace(sep, ".");
+ return removeExtension(relativeName).replace(File.separatorChar, '.');
}
}
return null;
@@ -210,7 +199,7 @@
if (name.equalsIgnoreCase(n)) {
try {
// allow for Windows
- return file.toRealPath().getFileName().toString().equals(n);
+ return file.getCanonicalFile().getName().equals(n);
} catch (IOException e) {
}
}
@@ -219,12 +208,12 @@
private void ensureParentDirectoriesExist() throws IOException {
if (!hasParents) {
- Path parent = file.getParent();
- if (parent != null && !Files.isDirectory(parent)) {
- try {
- Files.createDirectories(parent);
- } catch (IOException e) {
- throw new IOException("could not create parent directories", e);
+ File parent = file.getParentFile();
+ if (parent != null && !parent.exists()) {
+ if (!parent.mkdirs()) {
+ if (!parent.exists() || !parent.isDirectory()) {
+ throw new IOException("could not create parent directories");
+ }
}
}
hasParents = true;
@@ -253,10 +242,10 @@
return getAbsoluteFile().hashCode();
}
- private Path getAbsoluteFile() {
- Path absFile = (absFileRef == null ? null : absFileRef.get());
+ private File getAbsoluteFile() {
+ File absFile = (absFileRef == null ? null : absFileRef.get());
if (absFile == null) {
- absFile = file.toAbsolutePath();
+ absFile = file.getAbsoluteFile();
absFileRef = new SoftReference<>(absFile);
}
return absFile;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,9 @@
package com.sun.tools.javac.file;
-import java.nio.file.Path;
-import java.nio.file.Paths;
+import java.io.File;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import javax.tools.JavaFileObject;
/**
@@ -54,14 +52,12 @@
public abstract String basename();
- public Path getFile(Path directory) {
- if (directory == null)
- directory = Paths.get("");
- String sep = directory.getFileSystem().getSeparator();
- return directory.resolve(path.replace("/", sep));
+ public File getFile(File directory) {
+ if (path.length() == 0)
+ return directory;
+ return new File(directory, path.replace('/', File.separatorChar));
}
- @Override
public int compareTo(RelativePath other) {
return path.compareTo(other.path);
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/SymbolArchive.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/SymbolArchive.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,10 @@
package com.sun.tools.javac.file;
+import java.io.File;
import java.io.IOException;
-import java.nio.file.Path;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import javax.tools.JavaFileObject;
import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
@@ -44,10 +43,10 @@
*/
public class SymbolArchive extends ZipArchive {
- final Path origFile;
+ final File origFile;
final RelativeDirectory prefix;
- public SymbolArchive(JavacFileManager fileManager, Path orig, ZipFile zdir, RelativeDirectory prefix) throws IOException {
+ public SymbolArchive(JavacFileManager fileManager, File orig, ZipFile zdir, RelativeDirectory prefix) throws IOException {
super(fileManager, zdir, false);
this.origFile = orig;
this.prefix = prefix;
@@ -95,7 +94,7 @@
}
@Override
- protected String inferBinaryName(Iterable<? extends Path> path) {
+ protected String inferBinaryName(Iterable<? extends File> path) {
String entryName = entry.getName();
String prefix = ((SymbolArchive) zarch).prefix.path;
if (entryName.startsWith(prefix))
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipArchive.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipArchive.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,18 +25,15 @@
package com.sun.tools.javac.file;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Writer;
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharsetDecoder;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
@@ -52,6 +49,8 @@
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
import com.sun.tools.javac.util.List;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
/**
* <p><b>This is NOT part of any supported API.
@@ -132,10 +131,10 @@
return "ZipArchive[" + zfile.getName() + "]";
}
- private Path getAbsoluteFile() {
- Path absFile = (absFileRef == null ? null : absFileRef.get());
+ private File getAbsoluteFile() {
+ File absFile = (absFileRef == null ? null : absFileRef.get());
if (absFile == null) {
- absFile = Paths.get(zfile.getName()).toAbsolutePath();
+ absFile = new File(zfile.getName()).getAbsoluteFile();
absFileRef = new SoftReference<>(absFile);
}
return absFile;
@@ -156,7 +155,7 @@
/**
* A reference to the absolute filename for the zip file for the archive.
*/
- protected Reference<Path> absFileRef;
+ protected Reference<File> absFileRef;
/**
* A subclass of JavaFileObject representing zip entries.
@@ -176,7 +175,7 @@
@DefinedBy(Api.COMPILER)
public URI toUri() {
- Path zipFile = Paths.get(zarch.zfile.getName());
+ File zipFile = new File(zarch.zfile.getName());
return createJarUri(zipFile, entry.getName());
}
@@ -187,7 +186,7 @@
@Override
public String getShortName() {
- return Paths.get(zarch.zfile.getName()).getFileName() + "(" + entry + ")";
+ return new File(zarch.zfile.getName()).getName() + "(" + entry + ")";
}
@Override @DefinedBy(Api.COMPILER)
@@ -247,7 +246,7 @@
}
@Override
- protected String inferBinaryName(Iterable<? extends Path> path) {
+ protected String inferBinaryName(Iterable<? extends File> path) {
String entryName = entry.getName();
return removeExtension(entryName).replace('/', '.');
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndex.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndex.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,20 +26,18 @@
package com.sun.tools.javac.file;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -93,14 +91,14 @@
Collections.<RelativeDirectory>emptySet();
// ZipFileIndex data entries
- final Path zipFile;
- private Reference<Path> absFileRef;
+ final File zipFile;
+ private Reference<File> absFileRef;
long zipFileLastModified = NOT_MODIFIED;
private RandomAccessFile zipRandomFile;
private Entry[] entries;
private boolean readFromIndex = false;
- private Path zipIndexFile = null;
+ private File zipIndexFile = null;
private boolean triedToReadIndex = false;
final RelativeDirectory symbolFilePrefix;
private final int symbolFilePrefixLength;
@@ -119,7 +117,7 @@
return (zipRandomFile != null);
}
- ZipFileIndex(Path zipFile, RelativeDirectory symbolFilePrefix, boolean writeIndex,
+ ZipFileIndex(File zipFile, RelativeDirectory symbolFilePrefix, boolean writeIndex,
boolean useCache, String cacheLocation) throws IOException {
this.zipFile = zipFile;
this.symbolFilePrefix = symbolFilePrefix;
@@ -130,7 +128,7 @@
this.preindexedCacheLocation = cacheLocation;
if (zipFile != null) {
- this.zipFileLastModified = Files.getLastModifiedTime(zipFile).toMillis();
+ this.zipFileLastModified = zipFile.lastModified();
}
// Validate integrity of the zip file
@@ -150,11 +148,10 @@
}
private boolean isUpToDate() {
- try {
- return (zipFile != null
- && ((!NON_BATCH_MODE) || zipFileLastModified == Files.getLastModifiedTime(zipFile).toMillis())
- && hasPopulatedData);
- } catch (IOException ignore) {
+ if (zipFile != null
+ && ((!NON_BATCH_MODE) || zipFileLastModified == zipFile.lastModified())
+ && hasPopulatedData) {
+ return true;
}
return false;
@@ -202,7 +199,7 @@
private void openFile() throws FileNotFoundException {
if (zipRandomFile == null && zipFile != null) {
- zipRandomFile = new RandomAccessFile(zipFile.toFile(), "r");
+ zipRandomFile = new RandomAccessFile(zipFile, "r");
}
}
@@ -788,11 +785,11 @@
entries.add(zipFileIndex.entries[i]);
}
} else {
- Path indexFile = zipFileIndex.getIndexFile();
+ File indexFile = zipFileIndex.getIndexFile();
if (indexFile != null) {
RandomAccessFile raf = null;
try {
- raf = new RandomAccessFile(indexFile.toFile(), "r");
+ raf = new RandomAccessFile(indexFile, "r");
raf.seek(writtenOffsetOffset);
for (int nFiles = 0; nFiles < numEntries; nFiles++) {
@@ -859,11 +856,11 @@
triedToReadIndex = true;
RandomAccessFile raf = null;
try {
- Path indexFileName = getIndexFile();
- raf = new RandomAccessFile(indexFileName.toFile(), "r");
+ File indexFileName = getIndexFile();
+ raf = new RandomAccessFile(indexFileName, "r");
long fileStamp = raf.readLong();
- if (Files.getLastModifiedTime(zipFile).toMillis() != fileStamp) {
+ if (zipFile.lastModified() != fileStamp) {
ret = false;
} else {
directories = new LinkedHashMap<>();
@@ -911,7 +908,7 @@
return true;
}
- Path indexFile = getIndexFile();
+ File indexFile = getIndexFile();
if (indexFile == null) {
return false;
}
@@ -919,7 +916,7 @@
RandomAccessFile raf = null;
long writtenSoFar = 0;
try {
- raf = new RandomAccessFile(indexFile.toFile(), "rw");
+ raf = new RandomAccessFile(indexFile, "rw");
raf.writeLong(zipFileLastModified);
writtenSoFar += 8;
@@ -1019,27 +1016,27 @@
}
}
- private Path getIndexFile() {
+ private File getIndexFile() {
if (zipIndexFile == null) {
if (zipFile == null) {
return null;
}
- zipIndexFile = Paths.get((preindexedCacheLocation == null ? "" : preindexedCacheLocation) +
- zipFile.getFileName() + ".index");
+ zipIndexFile = new File((preindexedCacheLocation == null ? "" : preindexedCacheLocation) +
+ zipFile.getName() + ".index");
}
return zipIndexFile;
}
- public Path getZipFile() {
+ public File getZipFile() {
return zipFile;
}
- Path getAbsoluteFile() {
- Path absFile = (absFileRef == null ? null : absFileRef.get());
+ File getAbsoluteFile() {
+ File absFile = (absFileRef == null ? null : absFileRef.get());
if (absFile == null) {
- absFile = zipFile.toAbsolutePath();
+ absFile = zipFile.getAbsoluteFile();
absFileRef = new SoftReference<>(absFile);
}
return absFile;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java Tue Oct 21 17:50:13 2014 -0700
@@ -25,8 +25,12 @@
package com.sun.tools.javac.file;
+import java.io.IOException;
+import java.util.Set;
+import javax.tools.JavaFileObject;
+
import java.io.ByteArrayInputStream;
-import java.io.IOException;
+import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Writer;
@@ -34,10 +38,6 @@
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharsetDecoder;
-import java.nio.file.Path;
-import java.util.Set;
-
-import javax.tools.JavaFileObject;
import com.sun.tools.javac.file.JavacFileManager.Archive;
import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
@@ -56,7 +56,7 @@
public class ZipFileIndexArchive implements Archive {
private final ZipFileIndex zfIndex;
- private final JavacFileManager fileManager;
+ private JavacFileManager fileManager;
public ZipFileIndexArchive(JavacFileManager fileManager, ZipFileIndex zdir) throws IOException {
super();
@@ -111,10 +111,10 @@
/** The name of the zip file where this entry resides.
*/
- Path zipName;
+ File zipName;
- ZipFileIndexFileObject(JavacFileManager fileManager, ZipFileIndex zfIndex, ZipFileIndex.Entry entry, Path zipFileName) {
+ ZipFileIndexFileObject(JavacFileManager fileManager, ZipFileIndex zfIndex, ZipFileIndex.Entry entry, File zipFileName) {
super(fileManager);
this.name = entry.getFileName();
this.zfIndex = zfIndex;
@@ -134,7 +134,7 @@
@Override
public String getShortName() {
- return zipName.getFileName() + "(" + entry.getName() + ")";
+ return zipName.getName() + "(" + entry.getName() + ")";
}
@Override @DefinedBy(Api.COMPILER)
@@ -194,7 +194,7 @@
}
@Override
- protected String inferBinaryName(Iterable<? extends Path> path) {
+ protected String inferBinaryName(Iterable<? extends File> path) {
String entryName = entry.getName();
if (zfIndex.symbolFilePrefix != null) {
String prefix = zfIndex.symbolFilePrefix.path;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndexCache.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndexCache.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,22 +25,21 @@
package com.sun.tools.javac.file;
+import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
+import com.sun.tools.javac.util.Context;
+import java.io.File;
import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
-import com.sun.tools.javac.util.Context;
-
/** A cache for ZipFileIndex objects. */
public class ZipFileIndexCache {
- private final Map<Path, ZipFileIndex> map = new HashMap<>();
+ private final Map<File, ZipFileIndex> map = new HashMap<>();
/** Get a shared instance of the cache. */
private static ZipFileIndexCache sharedInstance;
@@ -90,13 +89,13 @@
return zipFileIndexes;
}
- public synchronized ZipFileIndex getZipFileIndex(Path zipFile,
+ public synchronized ZipFileIndex getZipFileIndex(File zipFile,
RelativeDirectory symbolFilePrefix,
boolean useCache, String cacheLocation,
boolean writeIndex) throws IOException {
ZipFileIndex zi = getExistingZipIndex(zipFile);
- if (zi == null || (zi != null && Files.getLastModifiedTime(zipFile).toMillis() != zi.zipFileLastModified)) {
+ if (zi == null || (zi != null && zipFile.lastModified() != zi.zipFileLastModified)) {
zi = new ZipFileIndex(zipFile, symbolFilePrefix, writeIndex,
useCache, cacheLocation);
map.put(zipFile, zi);
@@ -104,7 +103,7 @@
return zi;
}
- public synchronized ZipFileIndex getExistingZipIndex(Path zipFile) {
+ public synchronized ZipFileIndex getExistingZipIndex(File zipFile) {
return map.get(zipFile);
}
@@ -113,7 +112,7 @@
}
public synchronized void clearCache(long timeNotUsed) {
- for (Path cachedFile : map.keySet()) {
+ for (File cachedFile : map.keySet()) {
ZipFileIndex cachedZipIndex = map.get(cachedFile);
if (cachedZipIndex != null) {
long timeToTest = cachedZipIndex.lastReferenceTimeStamp + timeNotUsed;
@@ -125,7 +124,7 @@
}
}
- public synchronized void removeFromCache(Path file) {
+ public synchronized void removeFromCache(File file) {
map.remove(file);
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Oct 21 17:50:13 2014 -0700
@@ -29,27 +29,23 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.CharBuffer;
-import java.nio.file.Path;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-
+import javax.tools.JavaFileObject;
import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
+import com.sun.tools.javac.comp.Annotate;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Lint.LintCategory;
+import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.code.Scope.WriteableScope;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.code.Type.*;
-import com.sun.tools.javac.comp.Annotate;
import com.sun.tools.javac.file.BaseFileObject;
-import com.sun.tools.javac.jvm.ClassFile.NameAndType;
-import com.sun.tools.javac.jvm.ClassFile.Version;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.DefinedBy.Api;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -2485,7 +2481,7 @@
}
@Override
- protected String inferBinaryName(Iterable<? extends Path> path) {
+ protected String inferBinaryName(Iterable<? extends File> path) {
return flatname.toString();
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java Tue Oct 21 17:50:13 2014 -0700
@@ -29,10 +29,10 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
-import java.nio.file.NoSuchFileException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+
import java.util.Set;
import javax.tools.JavaFileManager;
@@ -166,7 +166,7 @@
try {
argv = CommandLine.parse(argv);
- } catch (FileNotFoundException | NoSuchFileException e) {
+ } catch (FileNotFoundException e) {
warning("err.file.not.found", e.getMessage());
return Result.SYSERR;
} catch (IOException ex) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Tue Oct 21 17:50:13 2014 -0700
@@ -30,13 +30,12 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
+import java.nio.file.Files;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
@@ -49,7 +48,6 @@
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
-
import javax.lang.model.SourceVersion;
import javax.tools.FileObject;
import javax.tools.JavaFileManager;
@@ -57,6 +55,9 @@
import javax.tools.JavaFileObject.Kind;
import javax.tools.StandardLocation;
+import static java.nio.file.FileVisitOption.*;
+import static javax.tools.StandardLocation.*;
+
import com.sun.tools.javac.util.BaseFileManager;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.DefinedBy;
@@ -64,10 +65,6 @@
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
-import static java.nio.file.FileVisitOption.*;
-
-import static javax.tools.StandardLocation.*;
-
import static com.sun.tools.javac.main.Option.*;
@@ -224,7 +221,7 @@
}
private void setDefaultForLocation(Location locn) {
- Collection<Path> files = null;
+ Collection<File> files = null;
if (locn instanceof StandardLocation) {
switch ((StandardLocation) locn) {
case CLASS_PATH:
@@ -238,12 +235,12 @@
break;
case CLASS_OUTPUT: {
String arg = options.get(D);
- files = (arg == null ? null : Collections.singleton(Paths.get(arg)));
+ files = (arg == null ? null : Collections.singleton(new File(arg)));
break;
}
case SOURCE_OUTPUT: {
String arg = options.get(S);
- files = (arg == null ? null : Collections.singleton(Paths.get(arg)));
+ files = (arg == null ? null : Collections.singleton(new File(arg)));
break;
}
}
@@ -251,8 +248,8 @@
PathsForLocation pl = new PathsForLocation();
if (files != null) {
- for (Path f: files)
- pl.add(f);
+ for (File f: files)
+ pl.add(f.toPath());
}
if (!pl.isEmpty())
pathsForLocation.put(locn, pl);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,6 @@
*/
package com.sun.tools.javac.util;
-import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
@@ -49,7 +48,6 @@
import com.sun.tools.javac.jvm.Profile;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.tree.Pretty;
-
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
/**
@@ -188,7 +186,7 @@
else if (arg instanceof JCExpression) {
return expr2String((JCExpression)arg);
}
- else if (arg instanceof Iterable<?> && !(arg instanceof Path)) {
+ else if (arg instanceof Iterable<?>) {
return formatIterable(d, (Iterable<?>)arg, l);
}
else if (arg instanceof Type) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Tue Oct 21 17:50:13 2014 -0700
@@ -24,7 +24,6 @@
*/
package com.sun.tools.javac.util;
-import java.nio.file.Path;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
@@ -40,8 +39,8 @@
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.code.Types;
+import static com.sun.tools.javac.code.TypeTag.*;
import static com.sun.tools.javac.code.Flags.*;
-import static com.sun.tools.javac.code.TypeTag.*;
import static com.sun.tools.javac.code.Kinds.*;
import static com.sun.tools.javac.code.Kinds.Kind.*;
import static com.sun.tools.javac.util.LayoutCharacters.*;
@@ -187,7 +186,7 @@
else if (arg instanceof JCDiagnostic) {
preprocessDiagnostic((JCDiagnostic)arg);
}
- else if (arg instanceof Iterable<?> && !(arg instanceof Path)) {
+ else if (arg instanceof Iterable<?>) {
for (Object o : (Iterable<?>)arg) {
preprocessArgument(o);
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/Gen.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/Gen.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
package com.sun.tools.javah;
+import java.io.UnsupportedEncodingException;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -32,8 +33,6 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -41,6 +40,7 @@
import java.util.Stack;
import javax.annotation.processing.ProcessingEnvironment;
+
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
@@ -48,6 +48,7 @@
import javax.lang.model.util.ElementFilter;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
+
import javax.tools.FileObject;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
@@ -203,7 +204,7 @@
event = "[Overwriting file ";
}
- } catch (FileNotFoundException | NoSuchFileException e) {
+ } catch (FileNotFoundException e) {
mustWrite = true;
event = "[Creating file ";
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java Tue Oct 21 17:50:13 2014 -0700
@@ -31,7 +31,6 @@
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
-import java.nio.file.NoSuchFileException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -51,6 +50,7 @@
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
+
import javax.lang.model.SourceVersion;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
@@ -62,6 +62,7 @@
import javax.lang.model.util.ElementFilter;
import javax.lang.model.util.SimpleTypeVisitor9;
import javax.lang.model.util.Types;
+
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.JavaCompiler;
@@ -71,15 +72,13 @@
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;
+import static javax.tools.Diagnostic.Kind.*;
import com.sun.tools.javac.code.Symbol.CompletionFailure;
import com.sun.tools.javac.main.CommandLine;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
-import static javax.tools.Diagnostic.Kind.*;
-
-
/**
* Javah generates support files for native methods.
* Parse commandline options and invokes javadoc to execute those commands.
@@ -421,7 +420,7 @@
List<String> l = new ArrayList<>();
for (String arg: args) l.add(arg);
return Arrays.asList(CommandLine.parse(l.toArray(new String[l.size()])));
- } catch (FileNotFoundException | NoSuchFileException e) {
+ } catch (FileNotFoundException e) {
throw new BadArgs("at.args.file.not.found", e.getLocalizedMessage());
} catch (IOException e) {
throw new BadArgs("at.args.io.exception", e.getLocalizedMessage());
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javap/JavapTask.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javap/JavapTask.java Tue Oct 21 17:50:13 2014 -0700
@@ -36,10 +36,6 @@
import java.io.StringWriter;
import java.io.Writer;
import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.file.NoSuchFileException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -65,6 +61,10 @@
import javax.tools.StandardLocation;
import com.sun.tools.classfile.*;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
@@ -568,7 +568,7 @@
} catch (EOFException e) {
reportError("err.end.of.file", className);
result = EXIT_ERROR;
- } catch (FileNotFoundException | NoSuchFileException e) {
+ } catch (FileNotFoundException e) {
reportError("err.file.not.found", e.getLocalizedMessage());
result = EXIT_ERROR;
} catch (IOException e) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/JavacState.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/JavacState.java Tue Oct 21 17:50:13 2014 -0700
@@ -26,17 +26,16 @@
package com.sun.tools.sjavac;
import java.io.*;
-import java.net.URI;
-import java.nio.file.NoSuchFileException;
-import java.text.SimpleDateFormat;
-import java.util.*;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
+import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
+import java.util.HashMap;
+import java.text.SimpleDateFormat;
+import java.net.URI;
+import java.util.*;
import com.sun.tools.sjavac.options.Options;
import com.sun.tools.sjavac.server.Sjavac;
@@ -365,7 +364,7 @@
}
}
}
- } catch (FileNotFoundException | NoSuchFileException e) {
+ } catch (FileNotFoundException e) {
// Silently create a new javac_state file.
noFileFound = true;
} catch (IOException e) {
@@ -842,7 +841,7 @@
}
listedSources.add(l);
}
- } catch (FileNotFoundException | NoSuchFileException e) {
+ } catch (FileNotFoundException e) {
throw new ProblemException("Could not open "+makefileSourceList.getPath()+" since it does not exist!");
} catch (IOException e) {
throw new ProblemException("Could not read "+makefileSourceList.getPath());
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java Tue Oct 21 17:50:13 2014 -0700
@@ -44,12 +44,12 @@
import com.sun.tools.sjavac.Log;
import com.sun.tools.sjavac.ProblemException;
import com.sun.tools.sjavac.Util;
-import com.sun.tools.sjavac.options.Options;
import com.sun.tools.sjavac.server.CompilationResult;
import com.sun.tools.sjavac.server.PortFile;
import com.sun.tools.sjavac.server.Sjavac;
import com.sun.tools.sjavac.server.SjavacServer;
import com.sun.tools.sjavac.server.SysInfo;
+import com.sun.tools.sjavac.options.Options;
/**
* Sjavac implementation that delegates requests to a SjavacServer.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SmartFileObject.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SmartFileObject.java Tue Oct 21 17:50:13 2014 -0700
@@ -27,8 +27,6 @@
import java.io.*;
import java.net.URI;
-import java.nio.file.NoSuchFileException;
-
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.JavaFileObject;
@@ -110,7 +108,7 @@
while (r.ready()) {
s.append(r.readLine()+lineseparator);
}
- } catch (FileNotFoundException | NoSuchFileException e) {
+ } catch (FileNotFoundException e) {
// Perfectly ok.
}
return new SmartWriter(file, s.toString(), file.getName(), stdout);
--- a/langtools/test/tools/javac/T6725036.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/test/tools/javac/T6725036.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,7 @@
long jarEntryTime = je.getTime();
ZipFileIndexCache zfic = ZipFileIndexCache.getSharedInstance();
- ZipFileIndex zfi = zfic.getZipFileIndex(rt_jar.toPath(), null, false, null, false);
+ ZipFileIndex zfi = zfic.getZipFileIndex(rt_jar, null, false, null, false);
long zfiTime = zfi.getLastModified(TEST_ENTRY_NAME);
check(je, jarEntryTime, zfi + ":" + TEST_ENTRY_NAME.getPath(), zfiTime);
--- a/langtools/test/tools/javac/api/6440528/T6440528.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/test/tools/javac/api/6440528/T6440528.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
import java.io.File;
import java.lang.reflect.Field;
-import java.nio.file.Path;
import java.util.Arrays;
import static javax.tools.StandardLocation.CLASS_OUTPUT;
import javax.tools.*;
@@ -60,10 +59,10 @@
System.err.println("Got: " + got);
}
- private File getUnderlyingFile(FileObject o) throws Exception {
- Field file = o.getClass().getDeclaredField("file"); // assumes RegularFileObject
+ private File getUnderlyingFile(Object o) throws Exception {
+ Field file = o.getClass().getDeclaredField("file");
file.setAccessible(true);
- return ((Path)file.get(o)).toFile();
+ return (File)file.get(o);
}
public static void main(String... args) throws Exception {
--- a/langtools/test/tools/javac/file/T7018098.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/test/tools/javac/file/T7018098.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -99,7 +99,7 @@
round++;
if (round == 1) {
boolean expect = Boolean.valueOf(options.get("expect"));
- checkEqual("cache result", fsInfo.isDirectory(testDir.toPath()), expect);
+ checkEqual("cache result", fsInfo.isDirectory(testDir), expect);
initialFSInfo = fsInfo;
} else {
checkEqual("fsInfo", fsInfo, initialFSInfo);
--- a/langtools/test/tools/javac/file/T7068437.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/test/tools/javac/file/T7068437.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Writer;
-import java.nio.file.NoSuchFileException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
@@ -105,7 +104,7 @@
messager.printMessage(Kind.NOTE, "found previous content of length " +
filer.getResource(StandardLocation.SOURCE_OUTPUT, "p", "C.java").getCharContent(false).length());
found = true;
- } catch (FileNotFoundException | NoSuchFileException x) {
+ } catch (FileNotFoundException x) {
messager.printMessage(Kind.NOTE, "not previously there");
found = false;
} catch (IOException x) {
--- a/langtools/test/tools/javac/file/T7068451.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/test/tools/javac/file/T7068451.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,6 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
-import java.nio.file.NoSuchFileException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -141,7 +140,7 @@
try {
int len = filer.getResource(StandardLocation.SOURCE_OUTPUT, "p", "C.java").getCharContent(false).length();
messager.printMessage(Kind.NOTE, "C.java: found previous content of length " + len);
- } catch (FileNotFoundException | NoSuchFileException x) {
+ } catch (FileNotFoundException x) {
messager.printMessage(Kind.NOTE, "C.java: not previously there");
} catch (IOException x) {
messager.printMessage(Kind.ERROR, "while reading: " + x);
--- a/langtools/test/tools/javac/processing/errors/CrashOnNonExistingAnnotation/Processor.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/test/tools/javac/processing/errors/CrashOnNonExistingAnnotation/Processor.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -88,7 +88,7 @@
if (!testFile.canRead()) throw new IllegalStateException("Cannot read the test source");
JavacTool compiler = JavacTool.create();
JavacFileManager fm = compiler.getStandardFileManager(null, null, null);
- testContent = fm.getRegularFile(testFile.toPath()).getCharContent(true).toString();
+ testContent = fm.getRegularFile(testFile).getCharContent(true).toString();
JavaFileObject testFileObject = new TestFO(new URI("mem://" + args[0]), testContent);
TestFM testFileManager = new TestFM(fm);
JavacTask task = compiler.getTask(null,
--- a/langtools/test/tools/javac/processing/errors/StopOnInapplicableAnnotations/Processor.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/test/tools/javac/processing/errors/StopOnInapplicableAnnotations/Processor.java Tue Oct 21 17:50:13 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -71,7 +71,7 @@
File inp = new File(sp, args[0]);
if (inp.canRead()) {
- testContent = fm.getRegularFile(inp.toPath()).getCharContent(true).toString();
+ testContent = fm.getRegularFile(inp).getCharContent(true).toString();
}
}
if (testContent == null) throw new IllegalStateException();
@@ -167,4 +167,4 @@
}
}
-}
+}
\ No newline at end of file
--- a/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java Tue Oct 21 17:50:13 2014 -0700
@@ -74,7 +74,7 @@
File inp = new File(sp, args[0]);
if (inp.canRead()) {
- testContent = fm.getRegularFile(inp.toPath()).getCharContent(true).toString();
+ testContent = fm.getRegularFile(inp).getCharContent(true).toString();
}
}
if (testContent == null) throw new IllegalStateException();
--- a/langtools/test/tools/javap/WhitespaceTest.java Tue Oct 21 13:08:20 2014 -0700
+++ b/langtools/test/tools/javap/WhitespaceTest.java Tue Oct 21 17:50:13 2014 -0700
@@ -57,7 +57,7 @@
if (line.endsWith(" "))
error("line has trailing whitespace: " + line);
int comment = line.indexOf(doubleSlash);
- if (comment > 0 && line.charAt(comment - 1) != ' ' && !line.contains("file:///"))
+ if (comment > 0 && line.charAt(comment - 1) != ' ')
error("no space before comment: " + line);
if (line.matches(" +}"))
error("bad indentation: " + line);