com.tc.object.bytecode.rwsync
Interface MethodStrategy

All Known Implementing Classes:
AddOrRemoveSynchronizedKeywordMethodStrategy, InitMethodStrategy, LockingMethodStrategy, NoLockMethodStrategy, SimpleLockMethodStrategy

public interface MethodStrategy

A strategy for modifying a method. The difference between this and a MethodAdapter is that a MethodStrategy has access to the ClassVisitor and therefore can create additional methods if needed, for example to rename a method and create a wrapper.

MethodStrategy instances are kept in statically initialized tables and reused. Implementations should not contain any mutable state.


Method Summary
 MethodVisitor visitMethod(ClassVisitor cv, java.lang.String ownerType, java.lang.String outerType, java.lang.String outerDesc, int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
          Instrument a method, possibly creating other methods in the process.
 

Method Detail

visitMethod

MethodVisitor visitMethod(ClassVisitor cv,
                          java.lang.String ownerType,
                          java.lang.String outerType,
                          java.lang.String outerDesc,
                          int access,
                          java.lang.String name,
                          java.lang.String desc,
                          java.lang.String signature,
                          java.lang.String[] exceptions)
Instrument a method, possibly creating other methods in the process. A do-nothing implementation might look like:
   visitMethod(...) {
     return cv.visitMethod(access, name, desc, signature, exceptions);
   }
 
This would delegate the visitMethod() call to the next class adapter in the chain, returning a method visitor which could then be visited with the method's contents.

Parameters:
cv - a way of calling the next class adapter in the chain. Do not pass in the samed ClassVisitor that is invoking the method strategy, or you'll recurse endlessly! Note that cv.visitMethod may be called more than once during a single call to this method, and must return a distinct MethodVisitor instance for each call.
ownerType - the internal type name of the class that contains the method, e.g., "org/xyz/Foo$Bar"
outerType - null if ownerType is a top-level type, or else the internal type name of its outer class e.g. "org/xyz/Foo"
outerDesc - null if ownerType is a top-level type, or else the type descriptor of its outer class, e.g. "Lorg/xyz/Foo;"
Returns:
a method visitor which can be called with the contents of the original method. Implementations must not return null, but may return a visitor that ignores all calls.


Copyright © 2010 Terracotta, Inc.. All Rights Reserved.