title: Detecting System.setProperty method invocations
body: <p>I'm facing a conundrum here.</p>
  
  <p>One of the applications that I've developed is loading an incorrect implementation of the <a href="http://download.oracle.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilderFactory.html" rel="nofollow">DocumentBuilderFactory</a> class of JAXP. This behavior was later deduced to be resulting from another class in different application built by a different team/company. The said class had changed the preferred DocumentBuilderFactory class upon loading, by inclusion of a static block similar to the one below:</p>
  
  <pre><code>  static
    {
      System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "a new factory");
    }
  </code></pre>
  
  <p>If one goes by the <a href="http://download.oracle.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#newInstance%28%29" rel="nofollow">Javadocs of the DocumentBuilderFactory.newInstance</a> method, it would be quite obvious that the above code was responsible for changing the parser implementation returned to all applications, when the newInstance method is invoked.</p>
  
  <p>A patch was applied, which corrected this problem, but it leads me to ask this question - <strong>how does one determine which class is performing the System.setProperty call at runtime?</strong></p>
  
  <p>We had produced a custom build of OpenJDK with a modified System class that was responsible for nailing the culprit, for the very simple reason that we did not have access to all the sources for all the applications deployed on the server. But this was possible only due to the fact that the production environment was replicated in its entiriety. The question therefore, could also be interpreted as -  <strong>how does one determine which class is performing the System.setProperty call at runtime, in a production environment?</strong></p>