Concurrent primitives

Supported concurrent primitives #

JMC agent instruments instantiations, calls to concurrent primitives seen in the target codebase. Here we list all the concurrent primitives currently supported along with caveats of special usage constraints.

java.land.Thread #

Thread creation, either by extending the Thread class or passing a Runnable is supported. The agent redirects the calls made to java.land.Thread towards org.mpi_sws.jmc.api.util.concurrent.JmcThread

JmcThread creates new tasks, yields at start, join and interrupt events.

synchronized #

Synchronized blocks and methods are supported. The blocks are converted into lock and unlock over JmcReentrantLock instances that are statically maintained in the JmcRuntime. Further, a synchronized method is split into two un-synchronized methods. The first retains the original signature and invokes the second surrounded by a lock and unlock. The second contains the body of the original method.

java.util.concurrent.ReentrantLock #

Locks are replaced with org.mpi_sws.jmc.api.util.concurrent.JmcReentrantLock instances. The lock and unlock method yields control to the JmcRuntime

Futures #

Calls to FutureTask are redirected to org.mpi_sws.jmc.api.util.concurrent.JmcFuture which implements RunnableFuture interface and contains yields. Similarly CompletableFuture calls are redirected to JmcCompletableFuture.

Internally, future creation is mapped similar to thread creation and future get is mapped to join.

Atomic data types #

Instance of Atomic primitives such as AtomicInteger and AtomicBoolean are replaced with JmcAtomicInteger and JmcAtomicBoolean respectively. The complete list of atomic primitives supported are,

  • AtomicInteger
  • AtomicLong
  • AtomicBoolean
  • AtomicReference
  • AtomicMarkableReference
  • AtomicIntegerArray
  • AtomicLongArray
  • AtomicReferenceArray
  • AtomicStampedReference
  • AtomicIntegerFieldUpdater
  • AtomicLongFieldUpdater
  • AtomicReferenceFieldUpdater