本文整理汇总了Java中org.apache.bcel.classfile.ConstantMethodref类的典型用法代码示例。如果您正苦于以下问题:Java ConstantMethodref类的具体用法?Java ConstantMethodref怎么用?Java ConstantMethodref使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstantMethodref类属于org.apache.bcel.classfile包,在下文中一共展示了ConstantMethodref类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visitConstantMethodref
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
public void visitConstantMethodref(ConstantMethodref ref)
{
ConstantPool pool = javaClass.getConstantPool();
String cstr = ref.getClass(pool);
if (cstr.equals("java.lang.Class"))
{
int iname = ref.getNameAndTypeIndex();
String name = ((ConstantNameAndType)pool.getConstant(iname)).getName(pool);
if (name.equals("forName")) {
System.out.println("found Class.forName('" + javaClass.getClassName() + "')");
ConstantNameAndType cnat = (ConstantNameAndType)pool.getConstant(iname);
String cfnStr = cnat.getName(pool);
if (lastConst != null) {
refClasses.add(lastConst.replace('.', '/'));
lastConst = null;
}
}
}
}
开发者ID:thahn0720,项目名称:agui_eclipse_plugin,代码行数:22,代码来源:ClassVisitorSearchCFN.java
示例2: checkCode
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
public boolean checkCode(InstructionHandle[] match)
{
InstructionHandle ih = match[0];
CPInstruction ldc_w = (CPInstruction) ih.getInstruction();
Constant cc = cpool.getConstant(ldc_w.getIndex());
if (cc.getTag() != CONSTANT_Class)
return false;
ih = match[1];
CPInstruction invokevirtual = (CPInstruction) ih.getInstruction();
ConstantMethodref cm = (ConstantMethodref) cpool.getConstant(invokevirtual.getIndex());
ConstantNameAndType cnt = (ConstantNameAndType) cpool.getConstant(cm.getNameAndTypeIndex());
if (!cnt.getName(cpool.getConstantPool()).equals("desiredAssertionStatus"))
return false;
return true;
}
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:17,代码来源:Downgrader.java
示例3: visitClassContext
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
JavaClass jclass = classContext.getJavaClass();
// We can ignore classes that were compiled for anything
// less than JDK 1.5. This should avoid lots of unnecessary work
// when analyzing code for older VM targets.
if (BCELUtil.preTiger(jclass))
return;
boolean sawUtilConcurrentLocks = false;
for (Constant c : jclass.getConstantPool().getConstantPool())
if (c instanceof ConstantMethodref) {
ConstantMethodref m = (ConstantMethodref) c;
ConstantClass cl = (ConstantClass) jclass.getConstantPool().getConstant(m.getClassIndex());
ConstantUtf8 name = (ConstantUtf8) jclass.getConstantPool().getConstant(cl.getNameIndex());
String nameAsString = name.getBytes();
if (nameAsString.startsWith("java/util/concurrent/locks"))
sawUtilConcurrentLocks = true;
}
if (sawUtilConcurrentLocks)
super.visitClassContext(classContext);
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:FindUnreleasedLock.java
示例4: addMethodref
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
/**
* Add a new Methodref constant to the ConstantPool, if it is not already
* in there.
*
* @param class_name class name string to add
* @param method_name method name string to add
* @param signature method signature string to add
* @return index of entry
*/
public int addMethodref( String class_name, String method_name, String signature ) {
int ret, class_index, name_and_type_index;
if ((ret = lookupMethodref(class_name, method_name, signature)) != -1) {
return ret; // Already in CP
}
adjustSize();
name_and_type_index = addNameAndType(method_name, signature);
class_index = addClass(class_name);
ret = index;
constants[index++] = new ConstantMethodref(class_index, name_and_type_index);
String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature;
if (!cp_table.containsKey(key)) {
cp_table.put(key, new Index(ret));
}
return ret;
}
开发者ID:Hu6,项目名称:VestaClient,代码行数:26,代码来源:ConstantPoolGen.java
示例5: visitConstantMethodref
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
@Override
public void visitConstantMethodref(ConstantMethodref obj) {
String name = obj.getClass(this.cp);
String variableType = ParseTool.getType2(name);
if (variableType != null && !jClass.getDetail().getSupers().contains(variableType)) {
jClass.getDetail().addVariableType(variableType);
if (this.parser.isDebug()) {
this.parser.debug("visitConstantMethodref: variable type = " + variableType);
}
}
}
开发者ID:jdepend,项目名称:cooper,代码行数:12,代码来源:SmallClassFileVisitor.java
示例6: visitConstantMethodref
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
public void visitConstantMethodref(ConstantMethodref obj){
if (obj.getTag() != Constants.CONSTANT_Methodref){
throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
}
checkIndex(obj, obj.getClassIndex(), CONST_Class);
checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType);
}
开发者ID:Hu6,项目名称:VestaClient,代码行数:8,代码来源:Pass2Verifier.java
示例7: visit
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
public void visit(ConstantMethodref obj) {
visit((ConstantCP) obj);
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java
示例8: visitConstantMethodref
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
public void visitConstantMethodref(ConstantMethodref obj) {
visit(obj);
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java
示例9: init
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
private void init(JavaClass jclass) {
ConstantPool cp = jclass.getConstantPool();
int numConstants = cp.getLength();
for (int i = 0; i < numConstants; ++i) {
try {
Constant c = cp.getConstant(i);
if (c instanceof ConstantMethodref) {
ConstantMethodref cmr = (ConstantMethodref) c;
ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex(),
CONSTANT_NameAndType);
String methodName = ((ConstantUtf8) cp.getConstant(cnat.getNameIndex(), CONSTANT_Utf8)).getBytes();
String className = cp.getConstantString(cmr.getClassIndex(), CONSTANT_Class).replace('/', '.');
String methodSig = ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex(), CONSTANT_Utf8)).getBytes();
String classNameLC = className.toLowerCase();
String methodNameLC = methodName.toLowerCase();
boolean voidReturnType = methodSig.endsWith(")V");
boolean boolReturnType = methodSig.endsWith(")Z");
if (DEBUG) {
System.out.print("Is " + className + "." + methodName + " assertion method: " + voidReturnType);
}
if (isUserAssertionMethod(className, methodName)
|| className.endsWith("Assert")
&& methodName.startsWith("is")
|| (voidReturnType || boolReturnType)
&& (classNameLC.indexOf("assert") >= 0 || methodNameLC.startsWith("throw")
|| methodName.startsWith("affirm") || methodName.startsWith("panic")
|| methodName.equals("logTerminal") || methodName.startsWith("logAndThrow")
|| methodNameLC.equals("insist") || methodNameLC.equals("usage")
|| methodNameLC.equals("exit") || methodNameLC.startsWith("fail")
|| methodNameLC.startsWith("fatal") || methodNameLC.indexOf("assert") >= 0
|| methodNameLC.indexOf("legal") >= 0 || methodNameLC.indexOf("error") >= 0
|| methodNameLC.indexOf("abort") >= 0
// || methodNameLC.indexOf("check") >= 0
|| methodNameLC.indexOf("failed") >= 0) || methodName.equals("addOrThrowException")) {
assertionMethodRefSet.set(i);
if (DEBUG) {
System.out.println("==> YES");
}
} else {
if (DEBUG) {
System.out.println("==> NO");
}
}
}
} catch (ClassFormatException e) {
// FIXME: should report
}
}
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:56,代码来源:AssertionMethods.java
示例10: init
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
private void init(JavaClass jclass) {
ConstantPool cp = jclass.getConstantPool();
int numConstants = cp.getLength();
for (int i = 0; i < numConstants; ++i) {
try {
Constant c = cp.getConstant(i);
if (c instanceof ConstantMethodref) {
ConstantMethodref cmr = (ConstantMethodref) c;
ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex(),
CONSTANT_NameAndType);
String methodName = ((ConstantUtf8) cp.getConstant(cnat.getNameIndex(), CONSTANT_Utf8)).getBytes();
String className = cp.getConstantString(cmr.getClassIndex(), CONSTANT_Class).replace('/', '.');
String methodSig = ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex(), CONSTANT_Utf8)).getBytes();
String classNameLC = className.toLowerCase();
String methodNameLC = methodName.toLowerCase();
boolean voidReturnType = methodSig.endsWith(")V");
boolean boolReturnType = methodSig.endsWith(")Z");
if (DEBUG) {
System.out.print("Is " + className + "." + methodName + " assertion method: " + voidReturnType);
}
if (isUserAssertionMethod(className, methodName)
|| className.endsWith("Assert")
&& methodName.startsWith("is")
|| (voidReturnType || boolReturnType)
&& (classNameLC.indexOf("assert") >= 0 || methodNameLC.startsWith("throw")
|| methodName.startsWith("affirm") || methodName.startsWith("panic")
|| methodName.equals("logTerminal") || methodName.startsWith("logAndThrow")
|| methodNameLC.equals("insist") || methodNameLC.equals("usage")
|| methodNameLC.equals("exit") || methodNameLC.startsWith("fail")
|| methodNameLC.startsWith("fatal") || methodNameLC.indexOf("assert") >= 0
|| methodNameLC.indexOf("legal") >= 0 || methodNameLC.indexOf("error") >= 0
|| methodNameLC.indexOf("abort") >= 0
// || methodNameLC.indexOf("check") >= 0
|| methodNameLC.indexOf("failed") >= 0) || methodName.equals("addOrThrowException")) {
assertionMethodRefSet.set(i);
if (DEBUG) {
System.out.println("==> YES");
}
} else {
if (DEBUG) {
System.out.println("==> NO");
}
}
}
} catch (ClassFormatException e) {
// FIXME: should report
}
}
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:56,代码来源:AssertionMethods.java
示例11: visitConstantMethodref
import org.apache.bcel.classfile.ConstantMethodref; //导入依赖的package包/类
public void visitConstantMethodref(ConstantMethodref obj) {
tostring = toString(obj);
}
开发者ID:Hu6,项目名称:VestaClient,代码行数:4,代码来源:StringRepresentation.java
注:本文中的org.apache.bcel.classfile.ConstantMethodref类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论