Java Code Examples for java.util.jar.JarEntry#getTime()

The following examples show how to use java.util.jar.JarEntry#getTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: I18nJavaUtil.java    From grammaticus with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static long urlLastModified(URL url) throws URISyntaxException, IOException {
    url = osgiToJar(url);
    if ("jar".equalsIgnoreCase(url.getProtocol())) {
        JarURLConnection jarEntryConn = (JarURLConnection)url.openConnection();
        // Check that the jar file actually exists on the file system
        File file = new File(jarEntryConn.getJarFileURL().getPath());
        if (!file.exists()) throw new IOException("Unable to process JAR url. JAR file is missing: " + file);
        try (JarFile jarFile = new JarFile(file)) {
            // Automatically reject any JAR URL which does not contain a JAR entry
            String jarEntryName = jarEntryConn.getEntryName();
            if (jarEntryName == null) throw new IOException("Unsupported JAR url. Missing JAR entry: " + url);
            JarEntry jarEntry = jarFile.getJarEntry(jarEntryName);
            return jarEntry != null ? jarEntry.getTime() : -1;
        }
     }

    return new File(url.toURI()).lastModified();
}
 
Example 2
Source File: JarUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
private static void copyStream(InputStream inputStream, JarOutputStream jos, JarEntry ze, String pathName) {
        try {

            ZipEntry newEntry = new ZipEntry(pathName);
            // Make sure there is date and time set.
            if (ze.getTime() != -1) {
                newEntry.setTime(ze.getTime());
                newEntry.setCrc(ze.getCrc()); // If found set it into output file.
            }
            jos.putNextEntry(newEntry);
            IOUtils.copy(inputStream, jos);
            IOUtils.closeQuietly(inputStream);
        } catch (Exception e) {
            e.printStackTrace();
            //throw new GradleException("copy stream exception", e);
            //e.printStackTrace();
//            logger.error("copy stream exception >>> " + pathName + " >>>" + e.getMessage());
        }
    }
 
Example 3
Source File: JarRefactor.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void copyStream(InputStream inputStream, JarOutputStream jos, JarEntry ze, String pathName) {
    try {

        ZipEntry newEntry = new ZipEntry(pathName);
        // Make sure there is date and time set.
        if (ze.getTime() != -1) {
            newEntry.setTime(ze.getTime());
            newEntry.setCrc(ze.getCrc()); // If found set it into output file.
        }
        jos.putNextEntry(newEntry);
        IOUtils.copy(inputStream, jos);
        IOUtils.closeQuietly(inputStream);
    } catch (Exception e) {
        //throw new GradleException("copy stream exception", e);
        //e.printStackTrace();
        logger.error("copy stream exception >>> " + pathName + " >>>" + e.getMessage());
    }
}
 
Example 4
Source File: ExtractJavaResourcesTask.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * process one jar entry in an input jar file and optionally stores the entry in the output
 * folder.
 *
 * @param jarFile   the input jar file
 * @param jarEntry  the jar entry in the jarFile to process
 * @param outputDir the output folder to use to copy/merge the entry in.
 * @throws IOException
 */
private static void processJarEntry(JarFile jarFile, JarEntry jarEntry, File outputDir) throws IOException {
    File outputFile = new File(outputDir, jarEntry.getName());
    Action action = getAction(jarEntry.getName());
    if (action == Action.COPY) {
        if (!outputFile.getParentFile().exists() &&
                !outputFile.getParentFile().mkdirs()) {
            throw new RuntimeException("Cannot create directory " + outputFile.getParent());
        }
        if (!outputFile.exists() || outputFile.lastModified()
                < jarEntry.getTime()) {
            InputStream inputStream = null;
            OutputStream outputStream = null;
            try {
                inputStream = jarFile.getInputStream(jarEntry);
                if (inputStream != null) {
                    outputStream = new BufferedOutputStream(
                            new FileOutputStream(outputFile));
                    ByteStreams.copy(inputStream, outputStream);
                    outputStream.flush();
                } else {
                    throw new RuntimeException("Cannot copy " + jarEntry.getName());
                }
            } finally {
                try {
                    if (outputStream != null) {
                        outputStream.close();
                    }
                } finally {
                    if (inputStream != null) {
                        inputStream.close();
                    }
                }
            }
        }
    }
}
 
Example 5
Source File: TEnv.java    From Voovan with Apache License 2.0 5 votes vote down vote up
/**
 * 获取 Class 的修改时间
 * @param clazz Class 对象
 * @return 修改时间, 返回: -1 文件不存在 / 文件不是 Class 文件 / IO 异常
 */
public static long getClassModifyTime(Class clazz){
	String location = getClassLocation(clazz);
	if(location==null){
		return -1;
	}
	String classNamePath = TEnv.classToResource(clazz);
	try {
		if(location.endsWith(".jar")) {
			try(JarFile jarFile = new JarFile(location)) {
				JarEntry jarEntry = jarFile.getJarEntry(classNamePath);
				if(jarEntry!=null) {
					return jarEntry.getTime();
				}else{
					return -1;
				}
			}
		} else if (location.endsWith(File.separator)) {
			File classFile = new File(location+classNamePath);
			if(classFile!=null && classFile.exists()) {
				return classFile.lastModified();
			}else{
				return -1;
			}
		} else {
			return -1;
		}
	}catch (IOException e){
		return -1;
	}
}
 
Example 6
Source File: JarEntryNode.java    From ghidra with Apache License 2.0 4 votes vote down vote up
public long lastModified() {
	JarFile jarFile = getJarFile();
	JarEntry jarEntry = jarFile.getJarEntry(getPath());
	return jarEntry.getTime();
}
 
Example 7
Source File: ResourceBundle.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName(toBundleName(baseName, locale), format);
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 8
Source File: ResourceBundle.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 9
Source File: ResourceBundle.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName(toBundleName(baseName, locale), format);
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 10
Source File: ResourceBundle.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 11
Source File: ResourceBundle.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 12
Source File: ResourceBundle.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 13
Source File: ResourceBundle.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 14
Source File: ResourceBundle.java    From jdk-1.7-annotated with Apache License 2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName(toBundleName(baseName, locale), format);
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 15
Source File: ResourceBundle.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 16
Source File: ResourceBundle.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 17
Source File: ResourceBundle.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 18
Source File: ResourceBundle.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 19
Source File: ResourceBundle.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}
 
Example 20
Source File: ResourceBundle.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determines if the expired <code>bundle</code> in the cache needs
 * to be reloaded based on the loading time given by
 * <code>loadTime</code> or some other criteria. The method returns
 * <code>true</code> if reloading is required; <code>false</code>
 * otherwise. <code>loadTime</code> is a millisecond offset since
 * the <a href="Calendar.html#Epoch"> <code>Calendar</code>
 * Epoch</a>.
 *
 * The calling <code>ResourceBundle.getBundle</code> factory method
 * calls this method on the <code>ResourceBundle.Control</code>
 * instance used for its current invocation, not on the instance
 * used in the invocation that originally loaded the resource
 * bundle.
 *
 * <p>The default implementation compares <code>loadTime</code> and
 * the last modified time of the source data of the resource
 * bundle. If it's determined that the source data has been modified
 * since <code>loadTime</code>, <code>true</code> is
 * returned. Otherwise, <code>false</code> is returned. This
 * implementation assumes that the given <code>format</code> is the
 * same string as its file suffix if it's not one of the default
 * formats, <code>"java.class"</code> or
 * <code>"java.properties"</code>.
 *
 * @param baseName
 *        the base bundle name of the resource bundle, a
 *        fully qualified class name
 * @param locale
 *        the locale for which the resource bundle
 *        should be instantiated
 * @param format
 *        the resource bundle format to be loaded
 * @param loader
 *        the <code>ClassLoader</code> to use to load the bundle
 * @param bundle
 *        the resource bundle instance that has been expired
 *        in the cache
 * @param loadTime
 *        the time when <code>bundle</code> was loaded and put
 *        in the cache
 * @return <code>true</code> if the expired bundle needs to be
 *        reloaded; <code>false</code> otherwise.
 * @exception NullPointerException
 *        if <code>baseName</code>, <code>locale</code>,
 *        <code>format</code>, <code>loader</code>, or
 *        <code>bundle</code> is <code>null</code>
 */
public boolean needsReload(String baseName, Locale locale,
                           String format, ClassLoader loader,
                           ResourceBundle bundle, long loadTime) {
    if (bundle == null) {
        throw new NullPointerException();
    }
    if (format.equals("java.class") || format.equals("java.properties")) {
        format = format.substring(5);
    }
    boolean result = false;
    try {
        String resourceName = toResourceName0(toBundleName(baseName, locale), format);
        if (resourceName == null) {
            return result;
        }
        URL url = loader.getResource(resourceName);
        if (url != null) {
            long lastModified = 0;
            URLConnection connection = url.openConnection();
            if (connection != null) {
                // disable caches to get the correct data
                connection.setUseCaches(false);
                if (connection instanceof JarURLConnection) {
                    JarEntry ent = ((JarURLConnection)connection).getJarEntry();
                    if (ent != null) {
                        lastModified = ent.getTime();
                        if (lastModified == -1) {
                            lastModified = 0;
                        }
                    }
                } else {
                    lastModified = connection.getLastModified();
                }
            }
            result = lastModified >= loadTime;
        }
    } catch (NullPointerException npe) {
        throw npe;
    } catch (Exception e) {
        // ignore other exceptions
    }
    return result;
}