Search in sources :

Example 1 with RelativeFile

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");
}
Also used : Context(com.sun.tools.javac.util.Context) JavacFileManager(com.sun.tools.javac.file.JavacFileManager) ZipFileIndexArchive(com.sun.tools.javac.file.ZipFileIndexArchive) JavaFileObject(javax.tools.JavaFileObject) ZipFileIndex(com.sun.tools.javac.file.ZipFileIndex) RelativeFile(com.sun.tools.javac.file.RelativePath.RelativeFile) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry) RelativeFile(com.sun.tools.javac.file.RelativePath.RelativeFile) JarFile(java.util.jar.JarFile) File(java.io.File) ZipFileIndexCache(com.sun.tools.javac.file.ZipFileIndexCache)

Example 2 with RelativeFile

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;
}
Also used : JavaFileObject(javax.tools.JavaFileObject) RelativeFile(com.sun.tools.javac.file.RelativePath.RelativeFile)

Example 3 with RelativeFile

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);
}
Also used : RelativeFile(com.sun.tools.javac.file.RelativePath.RelativeFile) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 4 with RelativeFile

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);
}
Also used : RelativeDirectory(com.sun.tools.javac.file.RelativePath.RelativeDirectory) RelativeFile(com.sun.tools.javac.file.RelativePath.RelativeFile) ZipEntry(java.util.zip.ZipEntry)

Example 5 with RelativeFile

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);
}
Also used : RelativeFile(com.sun.tools.javac.file.RelativePath.RelativeFile)

Aggregations

RelativeFile (com.sun.tools.javac.file.RelativePath.RelativeFile)6 File (java.io.File)2 JavaFileObject (javax.tools.JavaFileObject)2 JavacFileManager (com.sun.tools.javac.file.JavacFileManager)1 RelativeDirectory (com.sun.tools.javac.file.RelativePath.RelativeDirectory)1 ZipFileIndex (com.sun.tools.javac.file.ZipFileIndex)1 ZipFileIndexArchive (com.sun.tools.javac.file.ZipFileIndexArchive)1 ZipFileIndexCache (com.sun.tools.javac.file.ZipFileIndexCache)1 Context (com.sun.tools.javac.util.Context)1 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1 ZipEntry (java.util.zip.ZipEntry)1 ZipFile (java.util.zip.ZipFile)1