Java Magazine, July/August 2018
ORACLE COM JAVAMAGAZINE JULY AUGUST 2018 43 libraries The correspondence between the Java bytecode instructions and the calls to the visitor API is clear especially in the main method On the whole ASM tries to stay very close to the bytecode format while still providing enough of a high level API to allow you to be productive Lets consider two more examples with a bit more complexity Exploring the lost update problem as illustrated by trying to increment a counter safely Exploring a prototype of a safe class loader that tries to prevent any user code from executing any native methods Defeating Lost Update Protection Ill start with some simple code to demonstrate the lost update efect which Ill describe in a moment One of the classic ways to introduce the efect is via an incrementing class public class Counter private int i 0 public int increment return i i 1 This class needs a driver int MAX_ INC 10_ 000_ 000 Counter c new Counter Runnable r for int i 0 i MAX_ INC i c increment Thread t1 new Thread r
You must have JavaScript enabled to view digital editions.