use of com.sun.tools.javac.file.RelativePath.RelativeFile in project ceylon-compiler by ceylon.
the class T6725036 method run.
void run() throws Exception {
RelativeFile TEST_ENTRY_NAME = new RelativeFile("java/lang/String.class");
File f = new File(System.getProperty("java.home"));
if (!f.getName().equals("jre"))
f = new File(f, "jre");
File rt_jar = new File(new File(f, "lib"), "rt.jar");
JarFile j = new JarFile(rt_jar);
JarEntry je = j.getJarEntry(TEST_ENTRY_NAME.getPath());
long jarEntryTime = je.getTime();
ZipFileIndexCache zfic = ZipFileIndexCache.getSharedInstance();
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);
Context context = new Context();
JavacFileManager fm = new JavacFileManager(context, false, null);
ZipFileIndexArchive zfia = new ZipFileIndexArchive(fm, zfi);
JavaFileObject jfo = zfia.getFileObject(TEST_ENTRY_NAME.dirname(), TEST_ENTRY_NAME.basename());
long jfoTime = jfo.getLastModified();
check(je, jarEntryTime, jfo, jfoTime);
if (errors > 0)
throw new Exception(errors + " occurred");
}
use of com.sun.tools.javac.file.RelativePath.RelativeFile in project ceylon-compiler by ceylon.
the class ZipFileIndexArchive method getFileObject.
public JavaFileObject getFileObject(RelativeDirectory subdirectory, String file) {
RelativeFile fullZipFileName = new RelativeFile(subdirectory, file);
ZipFileIndex.Entry entry = zfIndex.getZipIndexEntry(fullZipFileName);
JavaFileObject ret = new ZipFileIndexFileObject(fileManager, zfIndex, entry, zfIndex.getZipFile());
return ret;
}
use of com.sun.tools.javac.file.RelativePath.RelativeFile in project ceylon-compiler by ceylon.
the class JavacFileManager method getFileForOutput.
protected JavaFileObject getFileForOutput(Location location, RelativeFile fileName, FileObject sibling) throws IOException {
File dir;
if (location == CLASS_OUTPUT) {
if (getClassOutDir() != null) {
dir = getClassOutDir();
} else {
File siblingDir = null;
if (sibling != null && sibling instanceof RegularFileObject) {
siblingDir = ((RegularFileObject) sibling).file.getParentFile();
}
return new RegularFileObject(this, new File(siblingDir, fileName.basename()));
}
} else if (location == SOURCE_OUTPUT) {
dir = (getSourceOutDir() != null ? getSourceOutDir() : getClassOutDir());
} else {
Iterable<? extends File> path = paths.getPathForLocation(location);
dir = null;
for (File f : path) {
dir = f;
break;
}
}
// null-safe
File file = fileName.getFile(dir);
return new RegularFileObject(this, file);
}
use of com.sun.tools.javac.file.RelativePath.RelativeFile in project ceylon-compiler by ceylon.
the class SymbolArchive method getFileObject.
@Override
public JavaFileObject getFileObject(RelativeDirectory subdirectory, String file) {
RelativeDirectory prefix_subdir = new RelativeDirectory(prefix, subdirectory.path);
ZipEntry ze = new RelativeFile(prefix_subdir, file).getZipEntry(zfile);
return new SymbolFileObject(this, file, ze);
}
use of com.sun.tools.javac.file.RelativePath.RelativeFile in project ceylon-compiler by ceylon.
the class JavacFileManager method getFileForOutput.
public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException {
nullCheck(location);
// validatePackageName(packageName);
nullCheck(packageName);
if (!isRelativeUri(relativeName))
throw new IllegalArgumentException("Invalid relative name: " + relativeName);
RelativeFile name = packageName.length() == 0 ? new RelativeFile(relativeName) : new RelativeFile(RelativeDirectory.forPackage(packageName), relativeName);
return getFileForOutput(location, name, sibling);
}
Aggregations