Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-132

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.0
    • None
    • None
    • Operating System: other
      Platform: Other

    • 21761

    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.

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--fix_sysutil_constants.txt
          3 kB
          KANEUCHI Tetsuya
        2. ASF.LICENSE.NOT.GRANTED--jjj.txt
          3 kB
          KANEUCHI Tetsuya

        Activity

          People

            Unassigned Unassigned
            tetsuyak@ka2.so-net.ne.jp KANEUCHI Tetsuya
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: