New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Capturing causes java.lang.LinkageError in JMockit 1.23 (works in earlier versions) #280

Closed
eugoss opened this Issue May 23, 2016 · 3 comments

Comments

2 participants
@eugoss

eugoss commented May 23, 2016

  • 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.

package com.keeprg.icu4test;

import mockit.Capturing;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class Test_Main
{
    @Test
    public void testCount(@Capturing final Log log)
    {
        assertEquals(3, Main.countCharacters("ABC", log));
    }
}

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]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@eugoss eugoss changed the title from @Capturing and java.lang.LinkageError to @Capturing causes java.lang.LinkageError in 1.23 May 24, 2016

@eugoss eugoss changed the title from @Capturing causes java.lang.LinkageError in 1.23 to @Capturing causes java.lang.LinkageError in JMockit 1.23 (works in earlier versions) May 24, 2016

@rliesenfeld rliesenfeld added the bug label May 24, 2016

@rliesenfeld rliesenfeld self-assigned this May 24, 2016

@rliesenfeld

This comment has been minimized.

Show comment
Hide comment
@rliesenfeld

rliesenfeld May 24, 2016

Member

Fixed by a previous (and unrelated) commit.

Thanks for reporting.

Member

rliesenfeld commented May 24, 2016

Fixed by a previous (and unrelated) commit.

Thanks for reporting.

@eugoss

This comment has been minimized.

Show comment
Hide comment
@eugoss

eugoss 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 :)

eugoss commented 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 :)

@eugoss

This comment has been minimized.

Show comment
Hide comment
@eugoss

eugoss May 24, 2016

By the way, thanks for such an awesome framework! Very well designed and
the documentation is excellent. It's a pleasure to work with it.

eugoss commented May 24, 2016

By the way, thanks for such an awesome framework! Very well designed and
the documentation is excellent. It's a pleasure to work with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment