]> source.dussan.org Git - aspectj.git/commitdiff
fix for 155213: made using date formatter lazy.
authoraclement <aclement>
Fri, 25 Aug 2006 12:41:38 +0000 (12:41 +0000)
committeraclement <aclement>
Fri, 25 Aug 2006 12:41:38 +0000 (12:41 +0000)
ajde/src/org/aspectj/ajde/ui/swing/OptionsFrame.java
bridge/src/org/aspectj/bridge/Version.java
bridge/testsrc/org/aspectj/bridge/VersionTest.java
weaver/src/org/aspectj/weaver/AjAttribute.java

index e6d6879baec4bd2411ee64f9df1c826eae074d01..b1c210f7d87b81514f02e5a2a8e90f0cd229f65b 100644 (file)
@@ -111,7 +111,7 @@ public class OptionsFrame extends JFrame {
             this.setLocation(200, 100);
 
                        version_label.setText("Version: " + Version.text);
-                       built_label.setText("Built: " + new Date(Version.time).toString());
+                       built_label.setText("Built: " + new Date(Version.getTime()).toString());
 
             addOptionsPanel(new BuildOptionsPanel());
             loadOptions();
index c08d24f608ca145e8e5a73776015c70caa4e3dbf..028cdd96de24185fd5f9f8f2a1cf2041d35d2a83 100644 (file)
@@ -43,22 +43,25 @@ public class Version {
       * time in seconds-since-... format, used by programmatic clients.
       * (if DEVELOPMENT version, NOTIME)
       */
-    public static final long time;
+    private static long time = -1; // -1 = uninitialized
     
        /** format used by build script to set time_text */
     public static final String SIMPLE_DATE_FORMAT = "EEEE MMM d, yyyy 'at' HH:mm:ss z";
     
-    // if not DEVELOPMENT version, read time text using format used to set time 
-    static {
-        long foundTime = NOTIME;
-               try {
-                   SimpleDateFormat format = new SimpleDateFormat(SIMPLE_DATE_FORMAT);
-                   ParsePosition pos = new ParsePosition(0);
-                   Date date = format.parse(time_text, pos);
-                   foundTime = date.getTime();
-               } catch (Throwable t) {            
-               }
-        time = foundTime;
+    public static long getTime() {
+       if (time==-1) {
+               long foundTime = NOTIME;
+           // if not DEVELOPMENT version, read time text using format used to set time 
+            try {
+                SimpleDateFormat format = new SimpleDateFormat(SIMPLE_DATE_FORMAT);
+                ParsePosition pos = new ParsePosition(0);
+                Date date = format.parse(time_text, pos);
+                if (date!=null) foundTime = date.getTime();
+            } catch (Throwable t) {            
+            }
+            time = foundTime;
+       }
+       return time;
     }
 
     /**
index 6339a16331026f0973dfa5de267f8015181d521a..1da10675c0603966944381d9a7cf6e1b9a1901f4 100644 (file)
@@ -44,7 +44,7 @@ public class VersionTest extends TestCase {
         
     public void testVersion() {
        if (Version.time_text.equals("")) return;  // dev build, we can only test this on the build server.
-        Date date = new Date(Version.time);
+        Date date = new Date(Version.getTime());
         SimpleDateFormat format = new SimpleDateFormat(Version.SIMPLE_DATE_FORMAT, Locale.getDefault());
         format.setTimeZone(TimeZone.getTimeZone("GMT"));
         String timeString = format.format(date);
index 6a7ff1ced68725b855681760ecccc3d127a4b7f3..a1fc5fcc4dd9d208906d24616da189c62fa9eb11 100644 (file)
@@ -247,7 +247,7 @@ public abstract class AjAttribute {
                public void write(DataOutputStream s) throws IOException {
                        s.writeShort(CURRENT_VERSION_MAJOR);
                        s.writeShort(CURRENT_VERSION_MINOR);
-                       s.writeLong(Version.time); // build used to construct the class...
+                       s.writeLong(Version.getTime()); // build used to construct the class...
                }
                
                public static WeaverVersionInfo read(VersionedDataInputStream s) throws IOException {