24 import com.ibm.oti.vm.VM; |
24 import com.ibm.oti.vm.VM; |
25 |
25 |
26 import com.nokia.mj.impl.rt.SystemPropertyHashtable; |
26 import com.nokia.mj.impl.rt.SystemPropertyHashtable; |
27 import com.nokia.mj.impl.rt.support.Finalizer; |
27 import com.nokia.mj.impl.rt.support.Finalizer; |
28 import com.nokia.mj.impl.rt.JvmPort; |
28 import com.nokia.mj.impl.rt.JvmPort; |
|
29 import com.nokia.mj.impl.utils.Logger; |
29 |
30 |
30 /** |
31 /** |
31 * A class that implements a system property extension mechanism provided |
32 * A class that implements a system property extension mechanism provided |
32 * by J9 for CLDC. The idea is that the VM provides the original system |
33 * by J9 for CLDC. The idea is that the VM provides the original system |
33 * properties in a Hashtable object as an argument in extendSystemProperties |
34 * properties in a Hashtable object as an argument in extendSystemProperties |
42 public class SystemPropertyExtension implements SystemPropertiesHook |
43 public class SystemPropertyExtension implements SystemPropertiesHook |
43 { |
44 { |
44 |
45 |
45 public Hashtable extendSystemProperties(Hashtable originalProperties) |
46 public Hashtable extendSystemProperties(Hashtable originalProperties) |
46 { |
47 { |
47 // Vital to make finalizer implementation reliable. If this is not done |
48 try |
48 // the first class registering for finalization never receves |
49 { |
49 // finalization serverces - i.e. none of the instances of that |
50 // Vital to make finalizer implementation reliable. If this is not |
50 // particular class will ever be finalized. |
51 // done the first class registering for finalization never receves |
51 VM.enableFinalization(Finalizer.class); |
52 // finalization serverces - i.e. none of the instances of that |
52 |
53 // particular class will ever be finalized. |
53 // Create a new object extending java.util.Hashtable and fill with the |
54 VM.enableFinalization(Finalizer.class); |
54 // original properties. |
55 |
55 SystemPropertyHashtable newProperties = |
56 // Create a new object extending java.util.Hashtable and fill with |
56 new SystemPropertyHashtable(originalProperties); |
57 // the original properties. |
57 |
58 SystemPropertyHashtable newProperties = |
58 // Store the hashtable to be able to add properties during runtime. |
59 new SystemPropertyHashtable(originalProperties); |
59 JvmPort.setPropertiesContainer(newProperties); |
60 // Store the hashtable to be able to add properties during runtime. |
60 |
61 JvmPort.setPropertiesContainer(newProperties); |
61 // Override existing line.separator |
62 |
62 newProperties.put("line.separator", "\n"); |
63 // Override existing line.separator |
63 |
64 newProperties.put("line.separator", "\n"); |
64 return newProperties; |
65 return newProperties; |
|
66 } |
|
67 catch (Throwable t) |
|
68 { |
|
69 Logger.LOG(Logger.EUtils, Logger.EInfo, |
|
70 "Failed to init system properties", t); |
|
71 // In case of error, return original properties. |
|
72 } |
|
73 return originalProperties; |
65 } |
74 } |
66 } |
75 } |