Package com.sun.org.apache.bcel.internal.generic

Examples of com.sun.org.apache.bcel.internal.generic.MethodGen


   */
  private Method createMethod(String className,MethodDef mdef) throws GenerationError {
    int access_flags = getMethodAccessFlags(mdef) ;
    Type return_type = TypeDefConverter.makeType(mdef.returnType) ;
    Type[] arg_types = createArgs(mdef.parameters) ;
    MethodGen mgen ;
    if (!mdef.isAbstract) {
      mgen = createNonAbstractMethod(className,mdef, access_flags, return_type,arg_types);
    }
    else {
      mgen = createAbstractMethod(className,mdef, access_flags, return_type,arg_types);
    }
    for(TypeName ex: mdef.throwList) {
      mgen.addException(ex.toString()) ;
    }
    mgen.setMaxStack() ;
    mgen.setMaxLocals() ;
    Method method = mgen.getMethod();
    return method;
  }
View Full Code Here


   * @param arg_types
   * @return a MethodGen for an abstract method.
   */
  private MethodGen createAbstractMethod(String className,MethodDef mdef, int access_flags,
      Type return_type, Type[] arg_types) {
    return new MethodGen(access_flags,
        return_type,
        arg_types,
        null,
        mdef.name,
        className,
View Full Code Here

   * @throws GenerationError
   */
  private MethodGen createNonAbstractMethod(String className,MethodDef mdef, int access_flags,
      Type return_type, Type[] arg_types) throws GenerationError {
    InstructionListContext ilc = generateInstructions(mdef);
    MethodGen mgen = new MethodGen(access_flags,
        return_type,
        arg_types,
        null,
        mdef.name,
        className,
        ilc.instList,
        instructionFactory.getClassGen().getConstantPool()) ;
    for(Map.Entry<InstructionHandle, Integer> e: ilc.lineNumbers.entrySet()) {
      InstructionHandle h = e.getKey() ;
      Integer linenum = e.getValue() ;
      mgen.addLineNumber(h, linenum.intValue()) ;
    }
    addExceptionHandlers(mgen, ilc);
    return mgen;
  }
View Full Code Here

TOP

Related Classes of com.sun.org.apache.bcel.internal.generic.MethodGen

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.