Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
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.