Created
October 12, 2017 05:33
-
-
Save baybatu/795b28966a8fe396c074be78e63f1032 to your computer and use it in GitHub Desktop.
getting info on whether JVM started in debug mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* ----------------------------------------------------------------------------------- | |
* From : org.junit.rules.DisableOnDebug#isDebugging(java.util.List<java.lang.String>) | |
* ----------------------------------------------------------------------------------- | |
* | |
* Parses arguments passed to the runtime environment for debug flags | |
* <p> | |
* Options specified in: | |
* <ul> | |
* <li> | |
* <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/jpda/conninv.html#Invocation" | |
* >javase-6</a></li> | |
* <li><a href="http://docs.oracle.com/javase/7/docs/technotes/guides/jpda/conninv.html#Invocation" | |
* >javase-7</a></li> | |
* <li><a href="http://docs.oracle.com/javase/8/docs/technotes/guides/jpda/conninv.html#Invocation" | |
* >javase-8</a></li> | |
* | |
* | |
* @param arguments | |
* the arguments passed to the runtime environment, usually this | |
* will be {@link RuntimeMXBean#getInputArguments()} | |
* @return true if the current JVM was started in debug mode, false | |
* otherwise. | |
*/ | |
private static boolean isDebugging(List<String> arguments) { | |
for (final String argument : arguments) { | |
if ("-Xdebug".equals(argument)) { | |
return true; | |
} else if (argument.startsWith("-agentlib:jdwp")) { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment