本文整理汇总了Java中sun.tools.java.ClassFile.lastModified方法的典型用法代码示例。如果您正苦于以下问题:Java ClassFile.lastModified方法的具体用法?Java ClassFile.lastModified怎么用?Java ClassFile.lastModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.tools.java.ClassFile
的用法示例。
在下文中一共展示了ClassFile.lastModified方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requiresGeneration
import sun.tools.java.ClassFile; //导入方法依赖的package包/类
/**
* Return true if the specified file needs generation.
*/
public boolean requiresGeneration (File target, Type theType) {
boolean result = alwaysGenerate;
if (!result) {
// Get a ClassFile instance for base source or class
// file. We use ClassFile so that if the base is in
// a zip file, we can still get at it's mod time...
ClassFile baseFile;
ClassPath path = env.getClassPath();
String className = theType.getQualifiedName().replace('.',File.separatorChar);
// First try the source file...
baseFile = path.getFile(className + ".source");
if (baseFile == null) {
// Then try class file...
baseFile = path.getFile(className + ".class");
}
// Do we have a baseFile?
if (baseFile != null) {
// Yes, grab baseFile's mod time...
long baseFileMod = baseFile.lastModified();
// Get a File instance for the target. If it is a source
// file, create a class file instead since the source file
// will frequently be deleted...
String targetName = IDLNames.replace(target.getName(),".java",".class");
String parentPath = target.getParent();
File targetFile = new File(parentPath,targetName);
// Does the target file exist?
if (targetFile.exists()) {
// Yes, so grab it's mod time...
long targetFileMod = targetFile.lastModified();
// Set result...
result = targetFileMod < baseFileMod;
} else {
// No, so we must generate...
result = true;
}
} else {
// No, so we must generate...
result = true;
}
}
return result;
}