Is there a way to determine if a System property was overridden on the command line when the JVM was started? In other words, if I do something like: System.getProperty("file.encoding") is there a way to determine whether or not the returned value is from the JVM being started with a -Dfile.encoding=foo parameter?
I looked through the System and Runtime API docs, but didn't see anything that would help.
1. Maintain a set (java.util.Set) of all system properties that is populated at application start time (in your main method before anything else exists). This represents all system properties that were set with -D but without the distinction between the usual system properties that always appear (see API spec. for System.getProperties).
2. Use bytecode enhancement to intercept all calls to System.setProperty after application start - unfortunately you can't use a Proxy (since the method does not exist on an interface where it should).