Search in sources :

Example 1 with ZipFileIndexArchive

use of com.sun.tools.javac.file.ZipFileIndexArchive 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)

Aggregations

JavacFileManager (com.sun.tools.javac.file.JavacFileManager)1 RelativeFile (com.sun.tools.javac.file.RelativePath.RelativeFile)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 File (java.io.File)1 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1 JavaFileObject (javax.tools.JavaFileObject)1