use of org.apache.bcel.generic.InstructionList in project qpid-broker-j by apache.
the class LDAPSSLSocketFactoryGenerator method createGetDefaultStaticMethod.
/**
* Create a static method 'getDefault' returning {@link SocketFactory}
* that creates a new instance of the sub-class and calls its no-argument
* constructor, the newly created is returned to the caller.
*
* @param classGen
* @param constantPoolGen
* @param instructionFactory
*/
private static void createGetDefaultStaticMethod(ClassGen classGen, ConstantPoolGen constantPoolGen, InstructionFactory instructionFactory) {
InstructionList il = new InstructionList();
String methodName = "getDefault";
MethodGen mg = new // access flags
MethodGen(// access flags
ACC_STATIC | ACC_PUBLIC, // return type
Type.getType(SSLSocketFactory.class), // argument types - no args
new Type[0], // arg names - no args
new String[0], methodName, // method, class
classGen.getClassName(), il, constantPoolGen);
il.append(instructionFactory.createNew(classGen.getClassName()));
il.append(InstructionConstants.DUP);
il.append(instructionFactory.createInvoke(classGen.getClassName(), "<init>", Type.VOID, new Type[] {}, Constants.INVOKESPECIAL));
il.append(InstructionConstants.ARETURN);
mg.setMaxStack();
classGen.addMethod(mg.getMethod());
il.dispose();
}
use of org.apache.bcel.generic.InstructionList in project contribution by checkstyle.
the class VisitorSet method visitCode.
/**
* @see org.apache.bcel.classfile.Visitor#visitCode
*/
public void visitCode(Code aCode) {
for (Iterator iter = mVisitors.iterator(); iter.hasNext(); ) {
IDeepVisitor visitor = (IDeepVisitor) iter.next();
Visitor v = visitor.getClassFileVisitor();
aCode.accept(v);
}
// perform a deep visit
final byte[] code = aCode.getCode();
final InstructionList list = new InstructionList(code);
final Iterator it = list.iterator();
for (Iterator iter = list.iterator(); iter.hasNext(); ) {
InstructionHandle instruction = (InstructionHandle) iter.next();
visitInstructionHandle(instruction);
}
}
Aggregations