when trying run coverage or run maven build using emma:emma following:
java.lang.illegalstateexception: not access method: can not set static final [z field packagename.classname.$jacocodata [z
so searched around online , found following on eclemma website:
my code uses reflection. why fail when execute jacoco?
to collect execution data jacoco instruments classes under test adds 2 members classes: private static field $jacocodata , private static method $jacocoinit(). both members marked synthetic.
please change code ignore synthetic members. practice anyways java compiler creates synthetic members in situation.
but cannot find documentation on web on how ignore synthetic members emma.
in sts under preferences/java/code coverage , see excludes box put exclusions (and know put exclusion in pom).
i wondering needs go in there exclude synthetic classes.
thanks
i ran issue generic csv export helper using. exception seeing jacoco/emma can't set synthetic field uses track code coverage. need allow emma access synthetic field.
if have stopped emma accessing synthetic fields because adding synthetic field causing problems reflection, eg. using reflection iterate on collection of field
objects, following:
field[] fields = fooobject.getclass().getdeclaredfields(); field[] nonsyntheticfields = new field[fields.length]; for(int = 0; < fields.length; i++){ if(!fields[i].issynthetic()){ nonsyntheticfields[i] = fields[i]; //or whatever processing doing here fields. } }
the above allows separate out synthetic fields, application shouldn't know about, fields have declared on classes. know seems bit hacky, it's elegant solution come with. emma needs field able instrument code, best thing can make sure code doesn't mess synthetic variable.
Comments
Post a Comment