Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

JPA Classes Generating Underscore class

2012-07-20
2013-04-24
  • Melloware Inc
    Melloware Inc
    2012-07-20

    For every one of my JPA classes I am seeing both Cobertura and Jacoco report two classes.  So for example if my JPA annotated class is called HelloJpa.java I will see Jacoco have two entries…

    HelloJpa
    HelloJpa_

    When I click on the _ version of the report it simply says Missed Instructions 3 of 3 for a method like this…

    HelloJpa_()

    Is this the default constructor it is missing or something?

     
  • Yes, if the class is called "HelloJpa_" the method shown in the report with name "HelloJpa_()" is the default constructor. Actually JaCoCo reporting uses a strategy to transform internal class files names (which would be "<init>") to more source-like names.

     
  • Melloware Inc
    Melloware Inc
    2012-07-23

    Is there anything I can do to make this behavior stop.  Even if I add my own default constructor and write a unit test that covers it this extra HelloJpa_ is still showing up and showing that it is "untested".  Any help would be appreciated!

     
  • Melloware Inc
    Melloware Inc
    2012-07-23

    I can attach a sample class if you want?

     
  • You can filter those generated class files when generating a JaCoCo report. Simply add exclude="*_" to the class file set you supply to the Ant report task (or Maven goal). See documentation for details.

     
  • Melloware Inc
    Melloware Inc
    2012-07-26

    Perfect!  That solved my issue.