Is ASM thread safe?
The Type and ClassReader classes are thread safe, i.e. several threads can use a single Type object or a single ClassReader object concurrently without problems. The ClassWriter and MethodWriter classes are not thread safe, i.e. a single class cannot be generated by several concurrent threads (but, of course, several threads can generate distinct classes concurrently, if each thread uses its own ClassWriter instance). In order to generate a single class by using several concurrent threads, one should use ClassAdapter and MethodAdapter instances that delegate to normal ClassWriter and MethodWriter instances, and whose methods are all synchronized. More generally, ClassVisitor and MethodVisitor implementations, such as ClassWriter and ClassAdapter, do not have to be thread safe. However, non thread safe visitors can be made thread safe just by using a synchronizing class adapter in front of them.