Weird Static Block Behaviour

Hi There,

I have a class to provide constants that is initialised using a static block...

publicfinalclass ConstantNames{

publicstaticfinal String NAME1="Name 1",

NAME2="Name 2",

NAME3="Name 3",

NAME4="Name 4",

NAME5="Name 5",

NAME6="Name 6",

NAME7="Name 7";

privatestaticfinal Set<String> VALUES;

static{

VALUES = CollectionsUtils.makeSet(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7);

}

publicstatic Set<String> values(){

return VALUES;

}

/**

* Prevents construction.

*/

private ConstantNames (){

}

}

It works as expected in my local environment (Win XP/JDK 1.5) but in the production environment (Linux/JDK 1.5) It 'loses' NAME7 such that...

ConstantNames.values().contains("Name 7")

...returns false (its true for "Name 1" .. "Name 6")

Can anyone shed any light on this for me - thanks

[1888 byte] By [MrTa] at [2007-11-27 1:41:47]
# 1
What happens if you add a "Name 8", or change the order of the stuff added?
paulcwa at 2007-7-12 0:57:33 > top of Java-index,Java Essentials,Java Programming...
# 2

On WinXP, its fine - you can add re-arrange doesn't make any difference. Its harder for me to make quick tests/changes in the Linux production environment. The latest change I'm releasing has done away with the static block so the Set is defined as...

private static final Set<String> VALUES = CollectionsUtils.makeSet(NAME1, NAME2, NAME3, NAME4, NAME5, NAME6, NAME7);

...hoping (blindly) that this will make a difference. I'll see if I can do some more testing in the 'problem' environment without having to go through the whole release procedure.

Thanks

MrTa at 2007-7-12 0:57:33 > top of Java-index,Java Essentials,Java Programming...
# 3
Try to write the smallest possible test program that exhibits the behavior.It would only be a few lines of code, and would be easy to copy to and compile on a linux box.It would also make it easier to isolate the problem.
paulcwa at 2007-7-12 0:57:33 > top of Java-index,Java Essentials,Java Programming...