Version of JMockit that was used: 1.23 It works in versions <= 1.22 . It's broken only in 1.23
Description of the problem or enhancement request:
A LinkageError (attempted duplicate class definition) happened to me several times, under different circumstances, when I was adding tests to our production code, trying to mock interfaces using @Capturing.
Although I cannot bring up the production code here, I created a simplified test instead, which is more or less similar to what I have in real tests. The test works fine with @Mocked, but fails with @Capturing. It's taken from my sample repository, where I used JMockit+JUnit4 to test code based on ICU4J library. But, certainly, it fails not only for ICU4J.
The interface Log is nowhere used in the underlying ICU4J classes, and the test fails with the following error:
java.lang.LinkageError: loader (instance of sun/misc/Launcher$AppClassLoader):
attempted duplicate class definition for name:
"com/ibm/icu/impl/ICUResourceBundleImpl$ResourceTable"
at com.keeprg.icu4test.Test_Main.testCount(Test_Main.java:13)
Being run with -verbose:class it shows that it attempted to load com/ibm/icu/impl/ICUResourceBundleImpl$ResourceTable twice indeed:
[Loaded com.ibm.icu.impl.ICUResourceBundle from __VM_RedefineClasses__]
[Loaded com.ibm.icu.impl.ICUResourceBundleImpl from file:/home/eugene/.m2/repository/com/ibm/icu/icu4j/57.1/icu4j-57.1.jar]
[Loaded com.ibm.icu.impl.ICUResourceBundleImpl$ResourceContainer from file:/home/eugene/.m2/repository/com/ibm/icu/icu4j/57.1/icu4j-57.1.jar]
[Loaded com.ibm.icu.impl.ICUResourceBundleImpl$ResourceTable from file:/home/eugene/.m2/repository/com/ibm/icu/icu4j/57.1/icu4j-57.1.jar]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Loaded com.ibm.icu.impl.ICUResourceBundleReader$Container from file:/home/eugene/.m2/repository/com/ibm/icu/icu4j/57.1/icu4j-57.1.jar]
[Loaded com.ibm.icu.impl.ICUResourceBundleReader$Table from file:/home/eugene/.m2/repository/com/ibm/icu/icu4j/57.1/icu4j-57.1.jar]
[Loaded com.ibm.icu.impl.ICUResourceBundleReader$Array from file:/home/eugene/.m2/repository/com/ibm/icu/icu4j/57.1/icu4j-57.1.jar]
[Loaded com.ibm.icu.impl.CacheBase from file:/home/eugene/.m2/repository/com/ibm/icu/icu4j/57.1/icu4j-57.1.jar]
[Loaded com.ibm.icu.impl.SoftCache from file:/home/eugene/.m2/repository/com/ibm/icu/icu4j/57.1/icu4j-57.1.jar]
[Loaded com.ibm.icu.impl.ICUResourceBundle$2 from file:/home/eugene/.m2/repository/com/ibm/icu/icu4j/57.1/icu4j-57.1.jar]
[Loaded com.ibm.icu.util.UResourceBundle from __VM_RedefineClasses__]
[Loaded java.util.ResourceBundle from __VM_RedefineClasses__]
[Loaded com.ibm.icu.impl.ICUResourceBundleImpl$ResourceTable from file:/home/eugene/.m2/repository/com/ibm/icu/icu4j/57.1/icu4j-57.1.jar]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The text was updated successfully, but these errors were encountered:
eugoss
changed the title
@Capturing and java.lang.LinkageError
@Capturing causes java.lang.LinkageError in 1.23
May 24, 2016
eugoss
changed the title
@Capturing causes java.lang.LinkageError in 1.23
@Capturing causes java.lang.LinkageError in JMockit 1.23 (works in earlier versions)
May 24, 2016
Awesome! Thanks a lot, Rogério! Yes, I've just noticed, there's 1.24 now,
but didn't have a chance to try it yet, since it's not in the maven repo
yet :)
It works in versions <= 1.22 . It's broken only in 1.23
A LinkageError (attempted duplicate class definition) happened to me several times, under different circumstances, when I was adding tests to our production code, trying to mock interfaces using
@Capturing
.Although I cannot bring up the production code here, I created a simplified test instead, which is more or less similar to what I have in real tests. The test works fine with
@Mocked
, but fails with@Capturing
. It's taken from my sample repository, where I used JMockit+JUnit4 to test code based on ICU4J library. But, certainly, it fails not only for ICU4J.The interface
Log
is nowhere used in the underlying ICU4J classes, and the test fails with the following error:Being run with
-verbose:class
it shows that it attempted to loadcom/ibm/icu/impl/ICUResourceBundleImpl$ResourceTable
twice indeed:The text was updated successfully, but these errors were encountered: