35 * @run main T6725036 |
35 * @run main T6725036 |
36 */ |
36 */ |
37 |
37 |
38 import java.io.File; |
38 import java.io.File; |
39 import java.io.IOException; |
39 import java.io.IOException; |
|
40 import java.util.Collections; |
40 import java.util.Date; |
41 import java.util.Date; |
41 import java.util.jar.JarEntry; |
42 import java.util.jar.JarEntry; |
42 import java.util.jar.JarFile; |
43 import java.util.jar.JarFile; |
|
44 |
43 import javax.tools.*; |
45 import javax.tools.*; |
44 |
46 |
45 import com.sun.tools.javac.file.JavacFileManager; |
47 import com.sun.tools.javac.file.JavacFileManager; |
46 import com.sun.tools.javac.file.RelativePath.RelativeFile; |
48 import com.sun.tools.javac.file.RelativePath.RelativeFile; |
47 import com.sun.tools.javac.file.ZipFileIndex; |
|
48 import com.sun.tools.javac.file.ZipFileIndexArchive; |
|
49 import com.sun.tools.javac.file.ZipFileIndexCache; |
|
50 import com.sun.tools.javac.util.Context; |
49 import com.sun.tools.javac.util.Context; |
51 |
50 |
52 public class T6725036 { |
51 public class T6725036 { |
53 public static void main(String... args) throws Exception { |
52 public static void main(String... args) throws Exception { |
54 new T6725036().run(); |
53 new T6725036().run(); |
61 |
60 |
62 try (JarFile j = new JarFile(testJar)) { |
61 try (JarFile j = new JarFile(testJar)) { |
63 JarEntry je = j.getJarEntry(TEST_ENTRY_NAME.getPath()); |
62 JarEntry je = j.getJarEntry(TEST_ENTRY_NAME.getPath()); |
64 long jarEntryTime = je.getTime(); |
63 long jarEntryTime = je.getTime(); |
65 |
64 |
66 ZipFileIndexCache zfic = ZipFileIndexCache.getSharedInstance(); |
|
67 ZipFileIndex zfi = zfic.getZipFileIndex(testJar.toPath(), null, false, null, false); |
|
68 long zfiTime = zfi.getLastModified(TEST_ENTRY_NAME); |
|
69 |
|
70 check(je, jarEntryTime, zfi + ":" + TEST_ENTRY_NAME.getPath(), zfiTime); |
|
71 |
|
72 Context context = new Context(); |
65 Context context = new Context(); |
73 JavacFileManager fm = new JavacFileManager(context, false, null); |
66 JavacFileManager fm = new JavacFileManager(context, false, null); |
74 ZipFileIndexArchive zfia = new ZipFileIndexArchive(fm, zfi); |
67 fm.setLocation(StandardLocation.CLASS_PATH, Collections.singletonList(testJar)); |
75 JavaFileObject jfo = |
68 FileObject fo = |
76 zfia.getFileObject(TEST_ENTRY_NAME.dirname(), |
69 fm.getFileForInput(StandardLocation.CLASS_PATH, "", TEST_ENTRY_NAME.getPath()); |
77 TEST_ENTRY_NAME.basename()); |
70 long jfoTime = fo.getLastModified(); |
78 long jfoTime = jfo.getLastModified(); |
|
79 |
71 |
80 check(je, jarEntryTime, jfo, jfoTime); |
72 check(je, jarEntryTime, fo, jfoTime); |
81 |
73 |
82 if (errors > 0) |
74 if (errors > 0) |
83 throw new Exception(errors + " occurred"); |
75 throw new Exception(errors + " occurred"); |
84 } |
76 } |
85 } |
77 } |