
By Alfredo Diaz | Article Rating: |
|
November 30, 2013 11:00 AM EST | Reads: |
6,272 |

Many libraries use system properties for settings. For example, you usually have to set a property to enable debug traces or to activate certain behaviors. However, sometimes system properties that are used are not well documented or you are not sure that they are having some effect. In such cases it would be useful to have a way to know which system properties are queried.
There are several manners to do this but I have found a simple way that is not so intrusive. By creating a custom Security Manager you can define a method that checks property accesses. This method is able to send to the logger or to the standard output what property has been queried.
public class PropertyAccessPrinterSecurityManager extends SecurityManager { @Override public void checkPropertyAccess(String key) { System.out.println("System.getProperty(\""+key+"\")"); } }
This article explains how to know which JVM System Properties are actually being queried by libraries. This class should be compiled and available in the classpath.
Now we create in the current directory a file named “java.policy” with the following content:
grant { permission java.security.AllPermission; };
We just have everything we need to trace calls to System.getProperty. Next we add these parameters to the java call:
java -Djava.security.manager=PropertyAccessPrinterSecurityManager -Djava.security.policy==java.policy
Published November 30, 2013 Reads 6,272
Copyright © 2013 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Alfredo Diaz
Alfredo Diaz is a Java EE Architect with over 10 years of experience. He is an expert in SOA, real-time processing, scalability and HA. He is an Agile enthusiast.
![]() Apr. 24, 2018 03:15 AM EDT Reads: 5,460 |
By Pat Romanski ![]() Apr. 24, 2018 01:15 AM EDT Reads: 16,156 |
By Yeshim Deniz Apr. 24, 2018 01:00 AM EDT Reads: 2,436 |
By SmartBear Blog ![]() Apr. 24, 2018 01:00 AM EDT Reads: 2,005 |
By Liz McMillan ![]() Apr. 24, 2018 12:00 AM EDT Reads: 8,115 |
By Pat Romanski ![]() Apr. 23, 2018 11:30 PM EDT Reads: 1,981 |
By Pat Romanski Apr. 23, 2018 11:15 PM EDT Reads: 2,820 |
By Elizabeth White ![]() Apr. 23, 2018 11:00 PM EDT Reads: 1,140 |
By Elizabeth White ![]() Apr. 23, 2018 11:00 PM EDT Reads: 6,436 |
By Liz McMillan ![]() Apr. 23, 2018 10:45 PM EDT Reads: 7,000 |
By Pat Romanski ![]() Apr. 23, 2018 10:45 PM EDT Reads: 7,190 |
By Liz McMillan ![]() Apr. 23, 2018 10:30 PM EDT Reads: 17,453 |
By Yeshim Deniz ![]() Apr. 23, 2018 09:45 PM EDT Reads: 6,866 |
By Liz McMillan ![]() Apr. 23, 2018 09:45 PM EDT Reads: 22,661 |
By Elizabeth White ![]() Apr. 23, 2018 08:45 PM EDT Reads: 9,241 |