Include claims for package

Is it possible to include java statements for each package? I want to use statements in my code, but one of the things that go along with my code violates some unrelated statements, and the authors refuse to correct it (at least for now, and this is not a critical error).

+5
source share
1 answer

Maybe see http://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html#enable-disable

Enabling and disabling claims

To include statements in different details, use -enableassertions or -ea . To disable claims in different details, use the -disableassertions or -da options. You specify granularity with the arguments that you provide to the switch :

  • packageName ...
    Enables or disables claims in the name of the package and any subpackages.
  • ...
    Enables or disables claims in an unnamed package in the current working directory.
  • class name
    Enables or disables statements in a named class

For example, the following command launches the BatTutor program, with approval only included in the package com.wombat.fruitbat and its subpackages:

java -ea:com.wombat.fruitbat... BatTutor

You can enable claims for all packages, and then disable them for some packages. Or else - disable for all packages, then enable only for some of them.

+5
source

Source: https://habr.com/ru/post/1263577/


All Articles