IBM Support

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

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Error Message: org.mockito.exceptions.base.MockitoException:
    Could not modify all classes [... class
    java.lang.Object] 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
    IBM SDK, Java Technology Edition
     8   SR8 FP15    8.0.8.15
    .
    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

    2025-02-20

  • 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":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7.0","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
20 February 2025