Overriding the getProperties() method in java.lang

I have been approached by a system admin guy, who reckons they would like to control the way the properties hashtable is distributed by overriding the method getProperties() in the java.lang package. Does anyone have any experience with this, or reasons why this is a bad idea.

I have to say, from a developers point of view I have fears about overiding base classes, but its not a final method, so I thought I would ask the experts ;-).

Kind regards,

Dean James Greenwood

[497 byte] By [dgreenwoa] at [2007-9-27 12:53:31]
# 1

I'm no expert, but I see that you cannot override the getProperties() method of the java.lang.System class, for:

1. though not final, the getProperties() method is static. Static methods cannot be overriden.

2. The java.lang.System is final. You cannot extend it, so how will you override the method?

However, the System.setProperties() and System.setProperty() methods allow you to customize the hashtable to your needs.

stoopidboia at 2007-7-9 8:08:13 > top of Java-index,Archived Forums,Java Programming...
# 2

What is meant by "control the way the properties hashtable is distributed"? I'm not certain what you mean.

Please note: packages starting with "java" must be loaded from the JRE lib directory. Attempting to load them from anywhere else will cause a runtime security exception. This will make overloading getProperties() difficult, although you can probably do it if you are willing to install the class properly in the JRE. I personally agree with you, changing the behavior of a base class is asking for trouble, because your new behavior will conflict with all of the normal documentation.

I guess that brings us back to my question, what are they trying to accomplish? There are probably better ways of doing whatever it is.

pmisnera at 2007-7-9 8:08:14 > top of Java-index,Archived Forums,Java Programming...