Skip to content

Debug Build Jacoco Instrumentation Verify Error #17

@tannerhawkins

Description

@tannerhawkins

Description

When instrumenting in debug builds using Jacoco, binaries fail to verify due to this error:

java.lang.VerifyError: Verifier rejected class stardevicediscoverymanager:
failed to verify: java.lang.Object stardevicediscoverymanager:
[0x103] expected to be within a catch-all for an instruction where a monitor is held

From what I can read online, this is a common issue when instrumenting java/kotlin code targeting an older Java version. The offending code is most likely something of the format:

    val obj = Any()
    try {
        synchronized(obj) {
            Log.d("Test", "Succeeded")
        }
    } catch (ex: Exception) {
        Log.e("Test", "Failed", ex)
    }

Oftentimes, the solution to this is the move the synchronized block outside of the try/catch like so:

    val obj = Any()
    synchronized(obj) {
       try {
          Log.d("Test", "Succeeded")
       } catch (ex: Exception) {
          Log.e("Test", "Failed", ex)
       }
    }

Jacoco Issue: jacoco/jacoco#1381

Your device where the bug occurs

  • Device:
    Android Emulator / Microtouch Android Device
  • OS:
    Android 13.0
  • Browser:
    N/A
  • Version
    SDK Version 1.11.1

Your printer

  • Model Names:
    N/A
  • Firmware Version:
    N/A
  • Interface:
    N/A

Your development environment

MacOS 15.7.1

To Reproduce

Steps to reproduce the behavior:

  1. Clone this fork of the example Android App
  2. Run app
  3. Start printer discovery flow
  4. See crash/error

Expected behavior

Expect no error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions