Compile Date

Discussion in 'Java' started by Roedy Green, Jul 30, 2008.

  1. Roedy Green

    Roedy Green Guest

    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.

    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Jul 30, 2008
    #1
    1. Advertising

  2. Roedy Green wrote:
    > 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.
    --
    John W. Kennedy
    "Compact is becoming contract,
    Man only earns and pays."
    -- Charles Williams. "Bors to Elayne: On the King's Coins"
     
    John W Kennedy, Jul 30, 2008
    #2
    1. Advertising

  3. Roedy Green

    Roedy Green Guest

    On Wed, 30 Jul 2008 20:01:12 GMT, Roedy Green
    <> wrote, quoted or indirectly quoted
    someone who 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.


    thanks. I have compiled your comments into an entry at
    http://mindprod.com/jgloss/compiletimestamp.html
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Jul 31, 2008
    #3
  4. Roedy Green

    Mark Space Guest

    Zig wrote:

    > 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!
     
    Mark Space, Jul 31, 2008
    #4
  5. Roedy Green

    Roedy Green Guest

    On Wed, 30 Jul 2008 19:15:27 -0400, Zig <> wrote,
    quoted or indirectly quoted someone who said :

    >long time=connection.getLastModified();


    that is so sneaky. I never would have thought of that.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Jul 31, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    631
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,327
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    549
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    744
    Richard Heathfield
    Nov 8, 2003
  5. Nagaraj
    Replies:
    1
    Views:
    900
    Lionel B
    Mar 1, 2007
Loading...

Share This Page