This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Detect -X options

 
Victor Ho
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to find out if there is any programmatic interface to check if a particular -X option is specified when the JVM is launched.

Thanks
Victor
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first guess is that you should check the String array that is passed as a parameter to main(). I'm not sure if these arguments are removed from the list before main() is called.

But why do you want to do this? The -X options are spcifically for the JVM. If your program wants command-line arguments, you should define your own set that can be taken from the String array passed to main(). If you can explain why you want to do this, perhaps it will make more sense to me.

Layne
 
Victor Ho
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Layne.

I have tried the String[] args to main(), but -X options are not included in the cmd-line args array.

I am using the native jvmdi interface (C APIs) in my program for self-debugging purposes. The trick about jvmdi is that it is only available if -Xdebug is specified when JVM is launched. I am looking for a way to automatically turn off the self-debugging feature if -Xdebug is not there.

Thanks
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't the API provide a method to detect if debug information is available (i.e. this flag has been specified)? If not, that seems like a flaw in the API to me.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic