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

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

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

BCClass.getDeclaredMethod介绍

[英]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 <init> and static initializers are named <clinit>.
[中]返回具有给定名称的声明方法,如果没有,则返回null。如果使用给定名称声明了多个方法,则返回的名称是未定义的。请注意,在字节码中,构造函数名为<init>,静态初始值设定项名为<clinit>

代码示例

代码示例来源: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, Class[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethod(name, (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethod(name, paramNames);
}

代码示例来源: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, Class[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethod(name, (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethod(name, paramNames);
}

代码示例来源: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, BCClass[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethod(name, (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethod(name, paramNames);
}

代码示例来源: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, Class returnType, 
  Class[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethod(name, returnType.getName(), 
      (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethod(name, returnType.getName(), paramNames);
}

代码示例来源: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, Class returnType, 
  Class[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethod(name, returnType.getName(), 
      (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethod(name, returnType.getName(), paramNames);
}

代码示例来源: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, BCClass[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethod(name, (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethod(name, paramNames);
}

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

private BCMethod getBCMethod(Method meth) {
  BCClass bc = pc.getProject().loadClass(meth.getDeclaringClass());
  return bc.getDeclaredMethod(meth.getName(), meth.getParameterTypes());
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

private BCMethod getBCMethod(Method meth) {
  BCClass bc = pc.getProject().loadClass(meth.getDeclaringClass());
  return bc.getDeclaredMethod(meth.getName(), meth.getParameterTypes());
}

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

private BCMethod getBCMethod(Method meth) {
  BCClass bc = pc.getProject().loadClass(meth.getDeclaringClass());
  return bc.getDeclaredMethod(meth.getName(), meth.getParameterTypes());
}

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

private BCMethod getBCMethod(Method meth) {
  BCClass bc = pc.getProject().loadClass(meth.getDeclaringClass());
  return bc.getDeclaredMethod(meth.getName(), meth.getParameterTypes());
}

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

private BCMethod getBCMethod(Method meth) {
  BCClass bc = pc.getProject().loadClass(meth.getDeclaringClass());
  return bc.getDeclaredMethod(meth.getName(), meth.getParameterTypes());
}

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

/**
 * Proxy setter methods of the given type.
 * 
 * @return true if we find any setters, false otherwise
 */
private boolean proxySetters(BCClass bc, Class type) {
  Method[] meths = type.getMethods();
  int setters = 0;
  for (int i = 0; i < meths.length; i++) {
    if (isSetter(meths[i]) && !Modifier.isFinal(meths[i].getModifiers())
      && bc.getDeclaredMethod(meths[i].getName(),
      meths[i].getParameterTypes()) == null) {
      setters++;
      proxySetter(bc, type, meths[i]);
    }
  } 
  return setters > 0;
}

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

/**
 * Proxy setter methods of the given type.
 * 
 * @return true if we find any setters, false otherwise
 */
private boolean proxySetters(BCClass bc, Class type) {
  Method[] meths = type.getMethods();
  int setters = 0;
  for (int i = 0; i < meths.length; i++) {
    if (isSetter(meths[i]) && !Modifier.isFinal(meths[i].getModifiers())
      && bc.getDeclaredMethod(meths[i].getName(),
      meths[i].getParameterTypes()) == null) {
      setters++;
      proxySetter(bc, type, meths[i]);
    }
  } 
  return setters > 0;
}

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

/**
 * Proxy setter methods of the given type.
 * 
 * @return true if we find any setters, false otherwise
 */
private boolean proxySetters(BCClass bc, Class type) {
  Method[] meths = type.getMethods();
  int setters = 0;
  for (int i = 0; i < meths.length; i++) {
    if (isSetter(meths[i]) && !Modifier.isFinal(meths[i].getModifiers())
      && bc.getDeclaredMethod(meths[i].getName(),
      meths[i].getParameterTypes()) == null) {
      setters++;
      proxySetter(bc, type, meths[i]);
    }
  } 
  return setters > 0;
}

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

/**
 * Proxy setter methods of the given type.
 * 
 * @return true if we find any setters, false otherwise
 */
private boolean proxySetters(BCClass bc, Class type) {
  Method[] meths = type.getMethods();
  int setters = 0;
  for (int i = 0; i < meths.length; i++) {
    if (isSetter(meths[i]) && !Modifier.isFinal(meths[i].getModifiers())
      && bc.getDeclaredMethod(meths[i].getName(),
      meths[i].getParameterTypes()) == null) {
      setters++;
      proxySetter(bc, type, meths[i]);
    }
  } 
  return setters > 0;
}

代码示例来源: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, BCClass returnType, 
  BCClass[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethod(name, returnType.getName(), 
      (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethod(name, returnType.getName(), paramNames);
}

代码示例来源: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, BCClass returnType, 
  BCClass[] paramTypes) {
  if (paramTypes == null)
    return getDeclaredMethod(name, returnType.getName(), 
      (String[]) null);
  String[] paramNames = new String[paramTypes.length];
  for (int i = 0; i < paramTypes.length; i++)
    paramNames[i] = paramTypes[i].getName();
  return getDeclaredMethod(name, returnType.getName(), paramNames);
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

/**
 * Proxy setter methods of the given type.
 * 
 * @return true if we find any setters, false otherwise
 */
private boolean proxySetters(BCClass bc, Class type) {
  Method[] meths = type.getMethods();
  int setters = 0;
  for (int i = 0; i < meths.length; i++) {
    if (isSetter(meths[i]) && !Modifier.isFinal(meths[i].getModifiers())
      && bc.getDeclaredMethod(meths[i].getName(),
      meths[i].getParameterTypes()) == null) {
      setters++;
      proxySetter(bc, type, meths[i]);
    }
  } 
  return setters > 0;
}

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

/**
 * Convenience method to add a default constructor to this class.
 * If a default constructor already exists, this method will return it
 * without modification.
 * This method can only be called if the superclass has been set.
 *
 * @return the default constructor
 */
public BCMethod addDefaultConstructor() {
  BCMethod method = getDeclaredMethod("<init>", (String[]) null);
  if (method != null)
    return method;
  method = declareMethod("<init>", void.class, null);
  Code code = method.getCode(true);
  code.setMaxStack(1);
  code.setMaxLocals(1);
  code.xload().setThis();
  code.invokespecial()
    .setMethod(getSuperclassName(), "<init>", "void", null);
  code.vreturn();
  return method;
}

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

/**
 * Enhance constructor to initialize fields
 */
private void enhanceConstructor(BCClass bc) {
  BCMethod cons = bc.getDeclaredMethod("<init>", (String[]) null);
  Code code = cons.getCode(false);
  code.afterLast();
  code.previous();
  // private BitSet loaded = new BitSet();
  BCField loaded = addBeanField(bc, "loaded", BitSet.class);
  loaded.setFinal(true);
  code.aload().setThis();
  code.anew().setType(BitSet.class);
  code.dup();
  code.constant().setValue(bc.getFields().length);
  code.invokespecial().setMethod(BitSet.class, "<init>", void.class,
    new Class[]{ int.class });
  code.putfield().setField(loaded);
  code.calculateMaxStack();
  code.calculateMaxLocals();
}

相关文章

微信公众号

最新文章

更多