获取java类的编译时间戳 [英] Getting compilation timestamp of a java class

查看:41
本文介绍了获取java类的编译时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以可靠地确定给定类的编译时间戳,用于本地运行的 Java 应用程序以及作为小程序和/或 JNLP webapps 的 Java 应用程序?

Is it possible to reliably determine the compilation time stamp of a given class for both java applications running locally and as applets and/or JNLP webapps ?

推荐答案

根据 Java 虚拟机规范,Class File Format 不需要任何类型的时间戳,因此您可以做的最好的事情是检查包含班级.不幸的是,文件系统操作,尤其是不同主机之间的文件系统操作,可能无法保留此类时间戳.

According to the Java Virtual Machine Specification, the Class File Format does not require a timestamp of any sort, so the best you could do is check the modification time of the Class or Jar file that contains the class. Unfortunately, filesystem operations, especially between various hosts, might not preserve such timestamps.

我会说默认情况下没有可靠的方法.但是,作为构建过程的一部分,您可以轻松地将此类时间戳嵌入 Jar 文件或 Class 文件中.

I would say there isn't a reliable way by default. However, you could easily embed such a timestamp in a Jar file or a Class file as part of your build process.

这篇关于获取java类的编译时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆