title: How to exclude source code from coverage measurement in IntelliJ IDEA?
body: <p>In a project, I have a <em>Utility class</em> which looks like this:</p>
  <pre><code>public final class Util {
      private Util() {}
      public static String method1(InputStream in) {...}
      public static String method2(BufferedReader in) {...}
      public static String method3(File file) {...}
  }
  </code></pre>
  <p>The class is a Utility class in the sense that it contains <em>only <code>static</code> methods</em>.
  Therefore it is declared <code>final</code> and its <strong>constructor is <code>private</code></strong>.
  Creating instances or deriving subclasses would simply not make any sense.</p>
  <p>I have a suite of unit tests which tests the project.
  I am using <em>IntelliJ IDEA</em> to run the tests, measure and visualize the code coverage.
  The constructor of the Utility <code>class Util</code> now brings down coverage.
  I would like to see a 100% on 100% logical coverage.
  Code like the private constructor of the Utility class brings down the coverage.</p>
  <p><strong>Is there a possibility, preferably by means of an annotation, to mark a method or constructor as not relevant for code coverage in order to exclude such code from the coverage reports and thus getting a 100% coverage displayed?</strong></p>
  <p>I know that in general hiding code from the coverage report is lying to your own disadvantage. I wouldn't mind if the report would have a list of &quot;ignored items&quot; - actually, that would be good, to check if someone is ignoring stuff which shouldn't be ignored. The point is really about code for which coverage makes no sense, like the private constructor of a Utility class.</p>
  <p>I've tried to find if <code>annotations.jar</code> contains a candidate. The only annotation which looked even remotely as if it could do it was <code>TestOnly</code>, but it does not fulfill this purpose.
  I also peeked around in <code>plugins/coverage/lib/*.jar</code> and couldn't find a candidate, but maybe I just missed it?</p>
  <p><strong>Update</strong>
  This question is obsolete now. Meanwhile, IntelliJ IDEA as well as Jacoco learned how to ignore the coverage of private constructurs that don't have callers. I do not know of any other example of intentionally unreachable code in Java that would spark a conversation for exclusion from coverage reports.</p>
  <p><strong>Update 2</strong>
  This question may become relevant again about the accessors of Java record classes.</p>