serp.bytecode.BCClass.getDeclaredMethods()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(13.1k)|赞(0)|评价(0)|浏览(77)

本文整理了Java中serp.bytecode.BCClass.getDeclaredMethods()方法的一些代码示例,展示了BCClass.getDeclaredMethods()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BCClass.getDeclaredMethods()方法的具体详情如下:
包路径:serp.bytecode.BCClass
类名称:BCClass
方法名:getDeclaredMethods

BCClass.getDeclaredMethods介绍

[英]Return all methods declared by this class. Constructors and static initializers are included.
[中]返回该类声明的所有方法。包括构造函数和静态初始值设定项。

代码示例

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Return all declared methods with the given name and parameter types.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod[] getDeclaredMethods(String name, Class[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethods(name, (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethods(name, paramNames);
}

代码示例来源:origin: net.sourceforge.serp/serp

/**
 * Return all declared methods with the given name and parameter types.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod[] getDeclaredMethods(String name, Class[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethods(name, (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethods(name, paramNames);
}

代码示例来源:origin: net.sourceforge.serp/serp

/**
 * Return all declared methods with the given name and parameter types.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod[] getDeclaredMethods(String name, BCClass[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethods(name, (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethods(name, paramNames);
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Return all declared methods with the given name and parameter types.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod[] getDeclaredMethods(String name, BCClass[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethods(name, (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethods(name, paramNames);
}

代码示例来源:origin: net.sourceforge.serp/serp

/**
 * Return all the declared methods with the given name, or an empty array
 * if none.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod[] getDeclaredMethods(String name) {
  Collection matches = new LinkedList();
  BCMethod[] methods = getDeclaredMethods();
  for (int i = 0; i < methods.length; i++)
    if (methods[i].getName().equals(name))
      matches.add(methods[i]);
  return (BCMethod[]) matches.toArray(new BCMethod[matches.size()]);
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Return the declared method with the given name, or null if none.
 * If multiple methods are declared with the given name, which is returned
 * is undefined.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod getDeclaredMethod(String name) {
  BCMethod[] methods = getDeclaredMethods();
  for (int i = 0; i < methods.length; i++)
    if (methods[i].getName().equals(name))
      return methods[i];
  return null;
}

代码示例来源:origin: net.sourceforge.serp/serp

/**
 * Return the declared method with the given name, or null if none.
 * If multiple methods are declared with the given name, which is returned
 * is undefined.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod getDeclaredMethod(String name) {
  BCMethod[] methods = getDeclaredMethods();
  for (int i = 0; i < methods.length; i++)
    if (methods[i].getName().equals(name))
      return methods[i];
  return null;
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Return all the declared methods with the given name, or an empty array
 * if none.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod[] getDeclaredMethods(String name) {
  Collection matches = new LinkedList();
  BCMethod[] methods = getDeclaredMethods();
  for (int i = 0; i < methods.length; i++)
    if (methods[i].getName().equals(name))
      matches.add(methods[i]);
  return (BCMethod[]) matches.toArray(new BCMethod[matches.size()]);
}

代码示例来源:origin: net.sourceforge.serp/serp

/**
 * Return the methods of this class, including those of all superclasses,
 * or an empty array if none.
 * The base version of methods that are overridden will be included, as
 * will all constructors and static initializers.
 * The methods will be ordered from those in the most-specific type up to
 * those in {@link Object}.
 */
public BCMethod[] getMethods() {
  Collection allMethods = new LinkedList();
  BCMethod[] methods;
  for (BCClass type = this; type != null; type = type.getSuperclassBC()) {
    methods = type.getDeclaredMethods();
    for (int i = 0; i < methods.length; i++)
      allMethods.add(methods[i]);
  }
  return (BCMethod[]) allMethods.toArray(new BCMethod[allMethods.size()]);
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Return the methods of this class, including those of all superclasses,
 * or an empty array if none.
 * The base version of methods that are overridden will be included, as
 * will all constructors and static initializers.
 * The methods will be ordered from those in the most-specific type up to
 * those in {@link Object}.
 */
public BCMethod[] getMethods() {
  Collection allMethods = new LinkedList();
  BCMethod[] methods;
  for (BCClass type = this; type != null; type = type.getSuperclassBC()) {
    methods = type.getDeclaredMethods();
    for (int i = 0; i < methods.length; i++)
      allMethods.add(methods[i]);
  }
  return (BCMethod[]) allMethods.toArray(new BCMethod[allMethods.size()]);
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Return all declared methods with the given name and parameter types.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod[] getDeclaredMethods(String name, String[] paramTypes) {
  if (paramTypes == null)
    paramTypes = new String[0];
  BCMethod[] methods = getDeclaredMethods();
  List matches = null;
  for (int i = 0; i < methods.length; i++) {
    if (methods[i].getName().equals(name) 
      && paramsMatch(methods[i], paramTypes)) {
      if (matches == null)
        matches = new ArrayList(3);
      matches.add(methods[i]);
    }
  }
  if (matches == null)
    return new BCMethod[0];
  return (BCMethod[]) matches.toArray(new BCMethod[matches.size()]);
}

代码示例来源:origin: net.sourceforge.serp/serp

/**
 * Return all declared methods with the given name and parameter types.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod[] getDeclaredMethods(String name, String[] paramTypes) {
  if (paramTypes == null)
    paramTypes = new String[0];
  BCMethod[] methods = getDeclaredMethods();
  List matches = null;
  for (int i = 0; i < methods.length; i++) {
    if (methods[i].getName().equals(name) 
      && paramsMatch(methods[i], paramTypes)) {
      if (matches == null)
        matches = new ArrayList(3);
      matches.add(methods[i]);
    }
  }
  if (matches == null)
    return new BCMethod[0];
  return (BCMethod[]) matches.toArray(new BCMethod[matches.size()]);
}

代码示例来源:origin: net.sourceforge.serp/serp

/**
 * Return the declared method with the given name and parameter types,
 * or null if none. If multiple methods are declared with the given name
 * and parameters, which is returned is undefined.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod getDeclaredMethod(String name, String[] paramTypes) {
  if (paramTypes == null)
    paramTypes = new String[0];
  BCMethod[] methods = getDeclaredMethods();
  for (int i = 0; i < methods.length; i++) {
    if (methods[i].getName().equals(name) 
      && paramsMatch(methods[i], paramTypes))
      return methods[i];
  }
  return null;
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Return the declared method with the given name and parameter types,
 * or null if none. If multiple methods are declared with the given name
 * and parameters, which is returned is undefined.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod getDeclaredMethod(String name, String[] paramTypes) {
  if (paramTypes == null)
    paramTypes = new String[0];
  BCMethod[] methods = getDeclaredMethods();
  for (int i = 0; i < methods.length; i++) {
    if (methods[i].getName().equals(name) 
      && paramsMatch(methods[i], paramTypes))
      return methods[i];
  }
  return null;
}

代码示例来源:origin: net.sourceforge.serp/serp

/**
 * Return the declared method with the given name and signature,
 * or null if none.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod getDeclaredMethod(String name, String returnType, 
  String[] paramTypes) {
  if (paramTypes == null)
    paramTypes = new String[0];
  BCMethod[] methods = getDeclaredMethods();
  for (int i = 0; i < methods.length; i++) {
    if (methods[i].getName().equals(name) 
      && methods[i].getReturnName().equals(_project.getNameCache().
        getExternalForm(returnType, false))
      && paramsMatch(methods[i], paramTypes))
      return methods[i];
  }
  return null;
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Return the declared method with the given name and signature,
 * or null if none.
 * Note that in bytecode, constructors are named <code>&lt;init&gt;</code>
 * and static initializers are named <code>&lt;clinit&gt;</code>.
 */
public BCMethod getDeclaredMethod(String name, String returnType, 
  String[] paramTypes) {
  if (paramTypes == null)
    paramTypes = new String[0];
  BCMethod[] methods = getDeclaredMethods();
  for (int i = 0; i < methods.length; i++) {
    if (methods[i].getName().equals(name) 
      && methods[i].getReturnName().equals(_project.getNameCache().
        getExternalForm(returnType, false))
      && paramsMatch(methods[i], paramTypes))
      return methods[i];
  }
  return null;
}

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

private void addSynchronization(BCClass bc) {
  BCMethod[] methods = bc.getDeclaredMethods();
  for (int i = 0; i < methods.length; i++) {
    if (methods[i].isPublic()
      && _synchs.contains(methods[i].getName()))
      methods[i].setSynchronized(true);
  }
  // add synchronized isLoaded call.
  // public synchronized boolean isLoaded (int field)
  // {
  // 		return super.isLoaded (field);
  // }
  BCMethod method = bc.declareMethod("isLoaded", boolean.class,
    new Class[]{ int.class });
  method.setSynchronized(true);
  Code code = method.getCode(true);
  code.aload().setThis();
  code.iload().setParam(0);
  code.invokespecial().setMethod(AbstractPCData.class, "isLoaded",
    boolean.class, new Class[]{ int.class });
  code.calculateMaxLocals();
  code.calculateMaxStack();
  code.ireturn();
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

private void addSynchronization(BCClass bc) {
  BCMethod[] methods = bc.getDeclaredMethods();
  for (int i = 0; i < methods.length; i++) {
    if (methods[i].isPublic()
      && _synchs.contains(methods[i].getName()))
      methods[i].setSynchronized(true);
  }
  // add synchronized isLoaded call.
  // public synchronized boolean isLoaded (int field)
  // {
  // 		return super.isLoaded (field);
  // }
  BCMethod method = bc.declareMethod("isLoaded", boolean.class,
    new Class[]{ int.class });
  method.setSynchronized(true);
  Code code = method.getCode(true);
  code.aload().setThis();
  code.iload().setParam(0);
  code.invokespecial().setMethod(AbstractPCData.class, "isLoaded",
    boolean.class, new Class[]{ int.class });
  code.calculateMaxLocals();
  code.calculateMaxStack();
  code.ireturn();
}

代码示例来源:origin: org.apache.openjpa/openjpa-kernel

private void addSynchronization(BCClass bc) {
  BCMethod[] methods = bc.getDeclaredMethods();
  for (int i = 0; i < methods.length; i++) {
    if (methods[i].isPublic()
      && _synchs.contains(methods[i].getName()))
      methods[i].setSynchronized(true);
  }
  // add synchronized isLoaded call.
  // public synchronized boolean isLoaded (int field)
  // {
  // 		return super.isLoaded (field);
  // }
  BCMethod method = bc.declareMethod("isLoaded", boolean.class,
    new Class[]{ int.class });
  method.setSynchronized(true);
  Code code = method.getCode(true);
  code.aload().setThis();
  code.iload().setParam(0);
  code.invokespecial().setMethod(AbstractPCData.class, "isLoaded",
    boolean.class, new Class[]{ int.class });
  code.calculateMaxLocals();
  code.calculateMaxStack();
  code.ireturn();
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

public void acceptVisit(BCVisitor visit) {
  visit.enterBCClass(this);
  ConstantPool pool = null;
  try {
    pool = _state.getPool();
  } catch (UnsupportedOperationException uoe) {
  }
  if (pool != null)
    pool.acceptVisit(visit);
  BCField[] fields = getDeclaredFields();
  for (int i = 0; i < fields.length; i++) {
    visit.enterBCMember(fields[i]);
    fields[i].acceptVisit(visit);
    visit.exitBCMember(fields[i]);
  }
  BCMethod[] methods = getDeclaredMethods();
  for (int i = 0; i < methods.length; i++) {
    visit.enterBCMember(methods[i]);
    methods[i].acceptVisit(visit);
    visit.exitBCMember(methods[i]);
  }
  visitAttributes(visit);
  visit.exitBCClass(this);
}

相关文章

微信公众号

最新文章

更多