Menu

How to avoid reporting private constructor?

2004-11-09
2013-05-09
  • Ravi Chamarthy

    Ravi Chamarthy - 2004-11-09

    Hi,

    One of the common patterns I use to make a class abstract and final (this type of class has only static methods and should have no objects created) is to create a private default constructor with an empty block.

    There is no way that this method can be called as the constructor is private and the Class itself never creates and object of its type. Emma reports that this block is not covered. It will be nice if we can avoid reporting coverage for this block.

    Is there are way to filter such blocks from coverage metrics?

    I also noticed that Emma reports coverage for default constructor created by the compiler if one is not declared. Is this not considered as synthetic code? If yes, why is emma reporting coverage when the default behavior of Emma is to ignore synthetic code.

    Thanks,
    Ravi

     
    • Vlad Roubtsov

      Vlad Roubtsov - 2004-11-10

      The first feature (private constructors) is planned for a future version (http://sourceforge.net/mailarchive/forum.php?thread_id=5244259&forum_id=40481)

      Regarding undeclared constructors, they used to be marked as Synthetic (and so excluded by EMMA by default), but no longer are by Sun's recent compilers. (Sun has changed position on this.)

       

Log in to post a comment.