close
The Wayback Machine - https://web.archive.org/web/20201030183713/https://github.com/microsoft/vscode-java-debug/issues/876
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting to enable asserts. #876

Closed
safield opened this issue Sep 2, 2020 · 6 comments
Closed

Add setting to enable asserts. #876

safield opened this issue Sep 2, 2020 · 6 comments
Labels

Comments

@safield
Copy link

@safield safield commented Sep 2, 2020

Currently when I run the debugger, my asserts are not being triggered.

It would be nice if there was a way I could turn on asserts, potentially in an extension setting or something.

@testforstephen
Copy link
Contributor

@testforstephen testforstephen commented Sep 3, 2020

What's asserts? Please explain your user scenario with more details.

@safield
Copy link
Author

@safield safield commented Sep 3, 2020

assert is a keyword in Java, and it behaves like assert does in c++.

https://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html

They can be enabled normally by adding a flag to java at runtime. They are not enabled by default when debugging using the vscode extension.

@no-response no-response bot removed the needs more info label Sep 3, 2020
@testforstephen
Copy link
Contributor

@testforstephen testforstephen commented Sep 4, 2020

Thanks for the details. Currently you can add vmArgs to "-ea" in the launch.json to enable assert. In future, we're planning to expose a global vmArgs in the user settings, where you can add "-ea" as the default value.

@safield
Copy link
Author

@safield safield commented Sep 4, 2020

I currently don't have a launch.json. Should I be expecting one to be present?

@testforstephen
Copy link
Contributor

@testforstephen testforstephen commented Sep 4, 2020

By default, the debugger just generates the config in memory. But you could go the debug view to create a launch.json.

image

@testforstephen
Copy link
Contributor

@testforstephen testforstephen commented Oct 19, 2020

With the latest debugger, you could achieve this by adding user setting "java.debug.settings.vmArgs": "-ea".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.