Commons Lang
  1. Commons Lang
  2. LANG-132

[lang] SystemUtils.IS_OS_*, IS_JAVA_* are always false.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      SystemUtils.IS_OS_, IS_JAVA_ always returns false.

      This case is on Mac OS X.


      % java -version
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-39)
      Java HotSpot(TM) Client VM (build 1.4.1_01-14, mixed mode)


      The test code is:

      import org.apache.commons.lang.*;

      public class OSNameTest {

      static public void main(String[] arg)

      { System.out.println(System.getProperty("os.name")); System.out.println(SystemUtils.IS_OS_MAC_OSX); System.out.println(SystemUtils.IS_OS_WINDOWS); System.out.println(SystemUtils.IS_JAVA_1_4); }

      }


      The result is:

      Mac OS X
      false
      false
      false

      It should be:

      Mac OS X
      true
      false
      true

      The cause: IS_JAVA_, IS_OS_ values are based on
      JAVA_VERSOIN, OS_NAME, OS_VERSION. But JAVA_VERSION, OS_NAME,
      OS_VERSION are initialized after IS_JAVA_, IS_OS_ values.
      When IS_OS_* are initialized, OS_NAME == null.

      They should be declared considering the initialization order.

        Activity

        Hide
        KANEUCHI Tetsuya added a comment -

        Created an attachment (id=7421)
        patch to o.a.c.l.SystemUtils.java. Modified declaration order.

        Show
        KANEUCHI Tetsuya added a comment - Created an attachment (id=7421) patch to o.a.c.l.SystemUtils.java. Modified declaration order.
        Hide
        KANEUCHI Tetsuya added a comment -

        Created an attachment (id=7422)
        patch to o.a.c.l.SystemUtilsTest.java. Proposal of the test for this bug.

        Show
        KANEUCHI Tetsuya added a comment - Created an attachment (id=7422) patch to o.a.c.l.SystemUtilsTest.java. Proposal of the test for this bug.
        Hide
        Stephen Colebourne added a comment -

        Very good catch. This would have been very embarrasing...
        Thanks

        Show
        Stephen Colebourne added a comment - Very good catch. This would have been very embarrasing... Thanks

          People

          • Assignee:
            Unassigned
            Reporter:
            KANEUCHI Tetsuya
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development