IBM Support

IJ47758: MOCKITO FAILS WITH "CANNOT MOCK" EXCEPTIONS IN OPENJ9

Subscribe to this APAR

By subscribing, you receive periodic emails alerting you to the status of the APAR, along with a link to the fix after it becomes available. You can track this item individually or track all items by product.

Notify me when this APAR changes.

Notify me when an APAR for this component changes.

 

APAR status

  • Closed as program error.

Error description

  • Error Message: org.mockito.exceptions.base.MockitoException:
    Could not modify all classes <OSB>... class
    java.lang.Object<CSB> Caused by:
    java.lang.instrument.UnmodifiableClassException
    .
    Stack Trace:
    .
    

Local fix

Problem summary

  • OpenJ9 does not allow java.lang.Object to be
    modified/transformed at runtime, which prevents Mockito (and
    possibly other frameworks or scenarios) from working correctly.
    Mockito throws the following Exception:
    org.mockito.exceptions.base.MockitoException: Could not modify
    all classes [<other classes>, class
    java.lang.Object]
    With a "Caused by" Exception similar to this:
    Caused by: java.lang.instrument.UnmodifiableClassException
        at
    java.instrument/sun.instrument.InstrumentationImpl.retransformCl
    asses0(Native Method)
        at
    java.instrument/sun.instrument.InstrumentationImpl.retransformCl
    asses(InstrumentationImpl.java:167)
        ...
    Further information can be found in this Eclipse OpenJ9 issue:
    https://github.com/eclipse-openj9/openj9/issues/17454
    

Problem conclusion

  • OpenJ9 has been updated to allow java.lang.Object to be
    transformed.
    .
    This APAR will be fixed in the following Releases:
    .
    IBM Semeru Runtimes
       11              11.0.21.0
       17              17.0.9.0
        8              8.0.392.0
    .
    Contact your IBM Product's Service Team for these Service
    Refreshes and Fix Packs.
    For those running stand-alone, information about the available
    maintenance can be found at:
               https://www.ibm.com/support/pages/java-sdk
    

Temporary fix

Comments

APAR Information

  • APAR number

    IJ47758

  • Reported component name

    J9 COMMON CODE

  • Reported component ID

    620700127

  • Reported release

    270

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2023-08-01

  • Closed date

    2023-08-01

  • Last modified date

    2023-08-01

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    J9 COMMON CODE

  • Fixed component ID

    620700127

Applicable component levels

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7.0","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
01 August 2023