Hi, Seems that this was answered already in https://stackoverflow.com/a/49232726/244993
In future for cross posts please consider providing cross link and notification that answer was already given. Thank you for your understanding. On Monday, March 12, 2018 at 3:29:22 AM UTC+1, [email protected] wrote: > > Hi, > > I followed the CoreTutorial example class at > http://www.jacoco.org/jacoco/trunk/doc/examples/java/CoreTutorial.java to > understand how to incorporate Jacoco into a project. > > However, I am facing java.lang.LinkageError problem that is related to the > MemoryClassLoader class that is used. > > Specifically, I have two classes, MyClass and MySubClass where MySubClass > extends MyClass. I instrument both classes so that I can get coverage > information related to each. I've found that if I instrument MySubClass > first, MemoryClassLoader will call defineClass with the instrumented bytes > for MySubClass. However, in doing so, MyClass, which is the parent class, > also gets loaded in by the parent class loader. Thus, when I next > instrument and load MyClass, I receive the java.lang.LinkageError which > claims that there is already a definition of MyClass that has been loaded > by a ClassLoader. The problem here is that the initial version of MyClass > that was loaded in was not instrumented. > > If I load in classes in the reverse order, this issue does not arise. > > I've tried something a bit different here: > https://github.com/huangwaylon/randoop/blob/bloodhound/src/main/java/randoop/main/MemoryClassLoader.java > > by immediately attempting to instrument the parent class upon a recursive > call to loadClass. However, this isn't entirely working due to reasons I > haven't figured out yet. I am observing that the coverage information for > both classes are not changing if I use this faulty approach. > > My question overall is, how can I instrument and load in classes that are > related to each other in a parent, child relationship such that the > behavior isn't affected by the order? Am I able to replace the definition > of a class? Another problem seems to be super.load which would be the > parent ClassLoader to MemoryClassLoader which I don't have control over. > > > -- You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/f6dfe57a-e973-4802-ad81-79dbdb1a8979%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
