There seems to be an issue with dueling byte-code
instrumenting/weaving/enhancing between Emma and OpenJPA. I found this old
issue for OpenJPA
https://issues.apache.org/jira/browse/OPENJPA-1095?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12991027and
that points over to a SERP issue which is where they decided the
problem
was.

BTW ... I am using the terms "instrument", "enhance" and "weave" willy-nilly
as they mean almost the same thing in this context. It is the process of
modifying the byte code of a class after javac compiles and and before
"java" executes it.

Anyway ... the short form is that if OpenJPA attempts to enhance a class
after Emma has instrumented it, an error message says
"IllegalArgumentException: 5" with a stack trace.Then the tests fail when
they run with a message saying they aren't enhanced.  Because the OpenJPA
enhance error message is so limited, nobody seems to know whether its just
some classes or all of them that have the issue. All of the unit tests
complain about the lack of enhancement.

There are other comments here and there I found by Googling that seem to say
there is a similar problem with Cobertura but it only happens depending on
the order of the "instrumenting". I don't recall if it fails when Cobertura
instruments first or if OpenJPA has to enhance first to have it fail.

Emma instruments at "compile" time. Cobertura instruments at run time. My
problems are, obviously, with running JUnit 3 tests inside Maven. I have
read that they run twice--once without Emma instrumentation and once with.

OpenJPA can enhance at compile time. There is a maven plugin to do that. Or,
if not already enhanced, it will happen at run time, perhaps when the class
loads. (It depends on the JDK version. I'm using JDK 5 or 6)

Finally the question ... what would I have to do to make sure that OpenJPA
enhances the classes before Emma instruments them. I don't know if this will
make my tests run correctly but its the only thing I have come up with to
try. It's not clear to me which phase of the lifecycle is the one in which
the Emma instrumentation takes place. if I know that, I might be able to do
the OpenJPA enhancing prior to that point.

I'm also wondering about a typical way to do the OpenJPA enhancing after
comiple and before running tests. This should make my tests run faster since
there would be no enhancing going for every one of the hundreds of tests.
I/m assuming if there are classes marked with @Entity they get enhanced if
loaded even if no actual database activity goes on in the test. (This
question came up as I thought about how Emma instruments one time and
Coburtura instruments when every test runs so Emma runs tests faster.)

If it doesn't work to reverse the enhancing order with Emma, my next plan is
to see what I can do with Cobertura, though I have found Emma easier to use.

Thanks

-- Lee Meador
Sent from gmail. My real email address is lee AT leemeador.com

Reply via email to