-
Enhancement
-
Resolution: Fixed
-
P3
-
7
-
b94
-
generic
-
generic
-
Verified
JDK version: 7/pit/b126
The following code (attached) and running output show that file times of entry in zipfs display different string values when handling zip file generated by 3rd party tools (WinRAR in this case). But this issue does not exist when handling zip file whose entries' file times are set by zipfs's functions.
====Begin of Code====
import static java.lang.System.*;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.FileTime;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import com.sun.nio.zipfs.ZipFileSystem;
public class testFileTimesForDifferentTimeZones {
public static void main(String[] args) throws IOException {
Map<String, Object> env = new HashMap<String, Object>();
Path file = Paths.get("TimeZoneThirdPartyToolGenerated.zip");
ZipFileSystem fs = (ZipFileSystem) FileSystems.newFileSystem(file, env,
null);
Path path = fs.getPath("file1.txt");
Path file2 = Paths.get("TimeZoneZIPFSGenerated.zip");
ZipFileSystem fs2 = (ZipFileSystem) FileSystems.newFileSystem(file2, env,
null);
Path path2 = fs2.getPath("file1.txt");
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
out.println(TimeZone.getDefault());
printTimes(path);
printTimes(path2);
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
out.println(TimeZone.getDefault());
printTimes(path);
printTimes(path2);
}
private static void printTimes(Path path) throws IOException {
out.println(path.getFileSystem());
FileTime atime = path
.getFileAttributeView(BasicFileAttributeView.class)
.readAttributes().lastAccessTime();
FileTime mtime = path
.getFileAttributeView(BasicFileAttributeView.class)
.readAttributes().lastModifiedTime();
FileTime ctime = path
.getFileAttributeView(BasicFileAttributeView.class)
.readAttributes().creationTime();
System.out.println("mtime: " + mtime);
System.out.println("ctime: " + ctime);
System.out.println("atime: " + atime);
}
}
====End of Code====
====Begin of Output====
sun.util.calendar.ZoneInfo[id="Asia/Shanghai",offset=28800000,dstSavings=0,useDaylight=false,transitions=19,lastRule=null]
TimeZoneThirdPartyToolGenerated.zip
mtime: 2010-10-25T06:59:46Z
ctime: null
atime: null
TimeZoneZIPFSGenerated.zip
mtime: 1982-02-08T00:00:00Z
ctime: 1983-07-24T00:00:00Z
atime: 1983-05-29T00:00:00Z
sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
TimeZoneThirdPartyToolGenerated.zip
mtime: 2010-10-25T21:59:46Z
ctime: null
atime: null
TimeZoneZIPFSGenerated.zip
mtime: 1982-02-08T00:00:00Z
ctime: 1983-07-24T00:00:00Z
atime: 1983-05-29T00:00:00Z
====End Of Output====
The following code (attached) and running output show that file times of entry in zipfs display different string values when handling zip file generated by 3rd party tools (WinRAR in this case). But this issue does not exist when handling zip file whose entries' file times are set by zipfs's functions.
====Begin of Code====
import static java.lang.System.*;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.FileTime;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import com.sun.nio.zipfs.ZipFileSystem;
public class testFileTimesForDifferentTimeZones {
public static void main(String[] args) throws IOException {
Map<String, Object> env = new HashMap<String, Object>();
Path file = Paths.get("TimeZoneThirdPartyToolGenerated.zip");
ZipFileSystem fs = (ZipFileSystem) FileSystems.newFileSystem(file, env,
null);
Path path = fs.getPath("file1.txt");
Path file2 = Paths.get("TimeZoneZIPFSGenerated.zip");
ZipFileSystem fs2 = (ZipFileSystem) FileSystems.newFileSystem(file2, env,
null);
Path path2 = fs2.getPath("file1.txt");
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
out.println(TimeZone.getDefault());
printTimes(path);
printTimes(path2);
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
out.println(TimeZone.getDefault());
printTimes(path);
printTimes(path2);
}
private static void printTimes(Path path) throws IOException {
out.println(path.getFileSystem());
FileTime atime = path
.getFileAttributeView(BasicFileAttributeView.class)
.readAttributes().lastAccessTime();
FileTime mtime = path
.getFileAttributeView(BasicFileAttributeView.class)
.readAttributes().lastModifiedTime();
FileTime ctime = path
.getFileAttributeView(BasicFileAttributeView.class)
.readAttributes().creationTime();
System.out.println("mtime: " + mtime);
System.out.println("ctime: " + ctime);
System.out.println("atime: " + atime);
}
}
====End of Code====
====Begin of Output====
sun.util.calendar.ZoneInfo[id="Asia/Shanghai",offset=28800000,dstSavings=0,useDaylight=false,transitions=19,lastRule=null]
TimeZoneThirdPartyToolGenerated.zip
mtime: 2010-10-25T06:59:46Z
ctime: null
atime: null
TimeZoneZIPFSGenerated.zip
mtime: 1982-02-08T00:00:00Z
ctime: 1983-07-24T00:00:00Z
atime: 1983-05-29T00:00:00Z
sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
TimeZoneThirdPartyToolGenerated.zip
mtime: 2010-10-25T21:59:46Z
ctime: null
atime: null
TimeZoneZIPFSGenerated.zip
mtime: 1982-02-08T00:00:00Z
ctime: 1983-07-24T00:00:00Z
atime: 1983-05-29T00:00:00Z
====End Of Output====
- relates to
-
JDK-8015666 test/tools/pack200/TimeStamp.java failing
-
- Closed
-