Compile Date

R

Roedy Green

Is the compile date of a class embedded in the class file somewhere? I
could see not putting it in to avoid false deltas when the code did
not really change.

It there a method to find out when a class was most recently compiled?

I suppose it could be handled with a script that generates a little
class containing today's date that gets freshly recompiled each day,
but that really just tells you when the jar was built.
 
J

John W Kennedy

Roedy said:
Is the compile date of a class embedded in the class file somewhere? I
could see not putting it in to avoid false deltas when the code did
not really change.

It there a method to find out when a class was most recently compiled?

I suppose it could be handled with a script that generates a little
class containing today's date that gets freshly recompiled each day,
but that really just tells you when the jar was built.

A quick experiment on my Mac yields no "diff"erence between class files
compiled at separate times from the same source.

When I wanted to "About" the code timestamps for one application, I
wrote a program that directory-walked the *.java files and placed the
timestamps into a Java properties file, which I then included in the
distributed JAR to be retrieved by ClassLoader.getResourceAsStream.
 
M

Mark Space

Zig said:
You should be able to get the lastmodified information for the .class
file from the filesystem. A jar utility should preserve the modification
date for each file in the archive. So:

public static Date getCompileTime(Class<?> cls) throws IOException

This seems to work from within NetBeans and as a seperate jar run from
the command line.

$ java -jar GenericOverrideTest.jar
Found class genericoverridetest.Main at
jar:file:/C:/Users/Dev/misc/GenericOverrideTest/dist/GenericOverrideTest.jar!/genericoverridetest/Main.class
Wed Jul 30 21:07:21 PDT 2008


init:
deps-jar:
compile:
run:
Found class genericoverridetest.Main at
file:/C:/Users/Dev/misc/GenericOverrideTest/build/classes/genericoverridetest/Main.class
Wed Jul 30 21:07:21 PDT 2008
BUILD SUCCESSFUL (total time: 0 seconds)


Nice!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top