if (data != null) { return data; } } data = readZoneInfoFile(JAVAZM_FILE_NAME); if (data == null) { return null; } int index; for (index = 0; index < JAVAZM_LABEL.length; index++) { if (data[index] != JAVAZM_LABEL[index]) { System.err.println("ZoneInfo: wrong magic number: " + JAVAZM_FILE_NAME); return null; } } if (data[index++] > JAVAZM_VERSION) { System.err.println("ZoneInfo: incompatible version (" + data[index - 1] + "): " + JAVAZM_FILE_NAME); return null; } zoneInfoMappings = new SoftReference<byte[]>(data); return data; } /** * Reads the specified file under <java.home>/lib/zi into a buffer. * @return the buffer, or null if any I/O error occurred. */ private static byte[] readZoneInfoFile(final String fileName) { byte[] buffer = null; try { buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws IOException { File file = new File(ziDir, fileName); if (!file.exists() || !file.isFile()) { return null; } file = file.getCanonicalFile(); String path = file.getCanonicalPath(); byte[] buf = null; if (path != null && path.startsWith(ziDir)) { int filesize = (int)file.length(); if (filesize > 0) { FileInputStream fis = new FileInputStream(file); buf = new byte[filesize]; try { if (fis.read(buf) != filesize) { throw new IOException("read error on " + fileName); } } finally { fis.close(); } } } return buf; } }); } catch (PrivilegedActionException e) { Exception ex = e.getException(); if (!(ex instanceof FileNotFoundException) || JAVAZM_FILE_NAME.equals(fileName)) { System.err.println("ZoneInfo: " + ex.getMessage()); } } return buffer; }}Lines 1001–1071 of 1071. Previous lines
if (data != null) { return data; } } data = readZoneInfoFile(JAVAZM_FILE_NAME); if (data == null) { return null; } int index; for (index = 0; index < JAVAZM_LABEL.length; index++) { if (data[index] != JAVAZM_LABEL[index]) { System.err.println("ZoneInfo: wrong magic number: " + JAVAZM_FILE_NAME); return null; } } if (data[index++] > JAVAZM_VERSION) { System.err.println("ZoneInfo: incompatible version (" + data[index - 1] + "): " + JAVAZM_FILE_NAME); return null; } zoneInfoMappings = new SoftReference<byte[]>(data); return data; } /** * Reads the specified file under <java.home>/lib/zi into a buffer. * @return the buffer, or null if any I/O error occurred. */ private static byte[] readZoneInfoFile(final String fileName) { byte[] buffer = null; try { buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws IOException { File file = new File(ziDir, fileName); if (!file.exists() || !file.isFile()) { return null; } file = file.getCanonicalFile(); String path = file.getCanonicalPath(); byte[] buf = null; if (path != null && path.startsWith(ziDir)) { int filesize = (int)file.length(); if (filesize > 0) { FileInputStream fis = new FileInputStream(file); buf = new byte[filesize]; try { if (fis.read(buf) != filesize) { throw new IOException("read error on " + fileName); } } finally { fis.close(); } } } return buf; } }); } catch (PrivilegedActionException e) { Exception ex = e.getException(); if (!(ex instanceof FileNotFoundException) || JAVAZM_FILE_NAME.equals(fileName)) { System.err.println("ZoneInfo: " + ex.getMessage()); } } return buffer; } }