Open dmivankov opened 3 years ago
Actually, looks like -da:smth -ea
still disables asserts in da, which is good enough as a workaround for specific assertsions.
java_test(
...
jvm_flags = ["-disableassertions:com.example.SomeClass"],
)
Would still be good to be able to optionally remove all asserts.
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.
Additionally assertions status depend on use_testrunner
attribute
Description of the problem / feature request:
It is not possible to (easily) disable java 1.4+ asserts in java_test targets. Easiest way is not setting -ea jvm flag, or to allow to overriding it with -da https://docs.oracle.com/en/java/javase/15/docs/specs/man/java.html#standard-options-for-java Uglier way is to (pre)configure the ClassLoader https://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#desiredAssertionStatus%28%29
Feature requests: what underlying problem are you trying to solve with this feature?
assert keyword is still used in some projects, but it has major flaws
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Create a java test with test body
It should be possible to have a flag that makes this test pass. This minimal test of course doesn't make much sense, real intended use is
What operating system are you running Bazel on?
NixOS
What's the output of
bazel info release
?release 3.3.1- (@non-git)
Have you found anything relevant by searching the web?
This seems to be the place where bazel adds -ea flag https://github.com/bazelbuild/bazel/blob/11d85c0e370755e24287af66362eb18c14310231/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java#L598 Note that java_test.jvm_args go before it and so can't override it. Maybe just moving -ea forward is a good enough solution.