• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Attribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.bcel.classfile.Attribute的典型用法代码示例。如果您正苦于以下问题:Java Attribute类的具体用法?Java Attribute怎么用?Java Attribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Attribute类属于org.apache.bcel.classfile包,在下文中一共展示了Attribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getOuterClass

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
/**
 * Determine the outer class of obj.
 * 
 * @param obj
 * @return JavaClass for outer class, or null if obj is not an outer class
 * @throws ClassNotFoundException
 */

@CheckForNull
public static JavaClass getOuterClass(JavaClass obj) throws ClassNotFoundException {
    for (Attribute a : obj.getAttributes())
        if (a instanceof InnerClasses) {
            for (InnerClass ic : ((InnerClasses) a).getInnerClasses()) {
                if (obj.getClassNameIndex() == ic.getInnerClassIndex()) {
                    // System.out.println("Outer class is " +
                    // ic.getOuterClassIndex());
                    ConstantClass oc = (ConstantClass) obj.getConstantPool().getConstant(ic.getOuterClassIndex());
                    String ocName = oc.getBytes(obj.getConstantPool());
                    return Repository.lookupClass(ocName);
                }
            }
        }
    return null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:Util.java


示例2: markedAsNotUsable

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
private boolean markedAsNotUsable(Method obj) {
    for (Attribute a : obj.getAttributes())
        if (a instanceof Deprecated)
            return true;
    Code code = obj.getCode();
    if (code == null)
        return false;
    byte[] codeBytes = code.getCode();
    if (codeBytes.length > 1 && codeBytes.length < 10) {
        int lastOpcode = codeBytes[codeBytes.length - 1] & 0xff;
        if (lastOpcode != ATHROW)
            return false;
        for (int b : codeBytes)
            if ((b & 0xff) == RETURN)
                return false;
        return true;
    }
    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:20,代码来源:Naming.java


示例3: TypeAnalysis

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param method
 *            TODO
 * @param methodGen
 *            the MethodGen whose CFG we'll be analyzing
 * @param cfg
 *            the control flow graph
 * @param dfs
 *            DepthFirstSearch of the method
 * @param typeMerger
 *            object to merge types
 * @param visitor
 *            a TypeFrameModelingVisitor to use to model the effect of
 *            instructions
 * @param lookupFailureCallback
 *            lookup failure callback
 * @param exceptionSetFactory
 *            factory for creating ExceptionSet objects
 */
public TypeAnalysis(Method method, MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, TypeMerger typeMerger,
        TypeFrameModelingVisitor visitor, RepositoryLookupFailureCallback lookupFailureCallback,
        ExceptionSetFactory exceptionSetFactory) {
    super(dfs);
    this.method = method;
    Code code = method.getCode();
    if (code == null)
        throw new IllegalArgumentException(method.getName() + " has no code");
    for (Attribute a : code.getAttributes()) {
        if (a instanceof LocalVariableTypeTable) 
            visitor.setLocalTypeTable((LocalVariableTypeTable) a);
    }
    this.methodGen = methodGen;
    this.cfg = cfg;
    this.typeMerger = typeMerger;
    this.visitor = visitor;
    this.thrownExceptionSetMap = new HashMap<BasicBlock, CachedExceptionSet>();
    this.lookupFailureCallback = lookupFailureCallback;
    this.exceptionSetFactory = exceptionSetFactory;
    this.instanceOfCheckMap = new HashMap<BasicBlock, InstanceOfCheck>();
    if (DEBUG) {
        System.out.println("\n\nAnalyzing " + methodGen);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:46,代码来源:TypeAnalysis.java


示例4: getOuterClass

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
/**
 * Determine the outer class of obj.
 *
 * @param obj
 * @return JavaClass for outer class, or null if obj is not an outer class
 * @throws ClassNotFoundException
 */

@CheckForNull
public static JavaClass getOuterClass(JavaClass obj) throws ClassNotFoundException {
    for (Attribute a : obj.getAttributes())
        if (a instanceof InnerClasses) {
            for (InnerClass ic : ((InnerClasses) a).getInnerClasses()) {
                if (obj.getClassNameIndex() == ic.getInnerClassIndex()) {
                    // System.out.println("Outer class is " +
                    // ic.getOuterClassIndex());
                    ConstantClass oc = (ConstantClass) obj.getConstantPool().getConstant(ic.getOuterClassIndex());
                    String ocName = oc.getBytes(obj.getConstantPool());
                    return Repository.lookupClass(ocName);
                }
            }
        }
    return null;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:25,代码来源:Util.java


示例5: TypeAnalysis

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param method
 *            TODO
 * @param methodGen
 *            the MethodGen whose CFG we'll be analyzing
 * @param cfg
 *            the control flow graph
 * @param dfs
 *            DepthFirstSearch of the method
 * @param typeMerger
 *            object to merge types
 * @param visitor
 *            a TypeFrameModelingVisitor to use to model the effect of
 *            instructions
 * @param lookupFailureCallback
 *            lookup failure callback
 * @param exceptionSetFactory
 *            factory for creating ExceptionSet objects
 */
public TypeAnalysis(Method method, MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, TypeMerger typeMerger,
        TypeFrameModelingVisitor visitor, RepositoryLookupFailureCallback lookupFailureCallback,
        ExceptionSetFactory exceptionSetFactory) {
    super(dfs);
    this.method = method;
    Code code = method.getCode();
    if (code == null)
        throw new IllegalArgumentException(method.getName() + " has no code");
    for (Attribute a : code.getAttributes()) {
        if (a instanceof LocalVariableTypeTable)
            visitor.setLocalTypeTable((LocalVariableTypeTable) a);
    }
    this.methodGen = methodGen;
    this.cfg = cfg;
    this.typeMerger = typeMerger;
    this.visitor = visitor;
    this.thrownExceptionSetMap = new HashMap<BasicBlock, CachedExceptionSet>();
    this.lookupFailureCallback = lookupFailureCallback;
    this.exceptionSetFactory = exceptionSetFactory;
    this.instanceOfCheckMap = new HashMap<BasicBlock, InstanceOfCheck>();
    if (DEBUG) {
        System.out.println("\n\nAnalyzing " + methodGen);
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:46,代码来源:TypeAnalysis.java


示例6: writeMainHTML

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
private void writeMainHTML( AttributeHTML attribute_html ) throws IOException {
    PrintWriter file = new PrintWriter(new FileOutputStream(dir + class_name + ".html"));
    Attribute[] attributes = java_class.getAttributes();
    file.println("<HTML>\n" + "<HEAD><TITLE>Documentation for " + class_name + "</TITLE>"
            + "</HEAD>\n" + "<FRAMESET BORDER=1 cols=\"30%,*\">\n"
            + "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + "<FRAME NAME=\"ConstantPool\" SRC=\""
            + class_name + "_cp.html" + "\"\n MARGINWIDTH=\"0\" "
            + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n"
            + "<FRAME NAME=\"Attributes\" SRC=\"" + class_name + "_attributes.html"
            + "\"\n MARGINWIDTH=\"0\" "
            + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + "</FRAMESET>\n"
            + "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + "<FRAME NAME=\"Code\" SRC=\""
            + class_name + "_code.html\"\n MARGINWIDTH=0 "
            + "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n"
            + "<FRAME NAME=\"Methods\" SRC=\"" + class_name
            + "_methods.html\"\n MARGINWIDTH=0 "
            + "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n"
            + "</FRAMESET></FRAMESET></HTML>");
    file.close();
    for (int i = 0; i < attributes.length; i++) {
        attribute_html.writeAttribute(attributes[i], "class" + i);
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:24,代码来源:Class2HTML.java


示例7: writeField

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
/**
 * Print field of class.
 *
 * @param field field to print
 * @exception java.io.IOException
 */
private void writeField( Field field ) throws IOException {
    String type = Utility.signatureToString(field.getSignature());
    String name = field.getName();
    String access = Utility.accessToString(field.getAccessFlags());
    Attribute[] attributes;
    access = Utility.replace(access, " ", "&nbsp;");
    file.print("<TR><TD><FONT COLOR=\"#FF0000\">" + access + "</FONT></TD>\n<TD>"
            + Class2HTML.referenceType(type) + "</TD><TD><A NAME=\"field" + name + "\">" + name
            + "</A></TD>");
    attributes = field.getAttributes();
    // Write them to the Attributes.html file with anchor "<name>[<i>]"
    for (int i = 0; i < attributes.length; i++) {
        attribute_html.writeAttribute(attributes[i], name + "@" + i);
    }
    for (int i = 0; i < attributes.length; i++) {
        if (attributes[i].getTag() == ATTR_CONSTANT_VALUE) { // Default value
            String str = ((ConstantValue) attributes[i]).toString();
            // Reference attribute in _attributes.html
            file.print("<TD>= <A HREF=\"" + class_name + "_attributes.html#" + name + "@" + i
                    + "\" TARGET=\"Attributes\">" + str + "</TD>\n");
            break;
        }
    }
    file.println("</TR>");
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:32,代码来源:MethodHTML.java


示例8: printEndMethod

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
/**
 * Unfortunately Jasmin expects ".end method" after each method. Thus we've to check
 * for every of the method's attributes if it's the last one and print ".end method"
 * then.
 */
private final void printEndMethod(Attribute attr) {
  Attribute[] attributes = method.getAttributes();

  if(attr == attributes[attributes.length - 1])
    out.println(".end method");
}
 
开发者ID:diana-hep,项目名称:root4j,代码行数:12,代码来源:JasminVisitor.java


示例9: visitMethod

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
public void visitMethod(Method method) {
  out.println("\n.method " + Utility.accessToString(method.getAccessFlags()) +
" " + method.getName() + method.getSignature());

  this.method = method; // Remember for use in subsequent visitXXX calls

  Attribute[] attributes = method.getAttributes();
  if((attributes == null) || (attributes.length == 0))
    out.println(".end method");
}
 
开发者ID:diana-hep,项目名称:root4j,代码行数:11,代码来源:JasminVisitor.java


示例10: removeLocalTypeTables

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
static void removeLocalTypeTables(MethodGen mg) {
    ConstantPoolGen cpg = mg.getConstantPool();
    Attribute[] a = mg.getCodeAttributes();
    for (int i = 0; i < a.length; i++) {
        String attribName = ((ConstantUtf8) cpg.getConstant(a[i]
            .getNameIndex())).getBytes();
        if (attribName.equals("LocalVariableTypeTable")) {
            mg.removeCodeAttribute(a[i]);
        }
    }
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:12,代码来源:Cashmerec.java


示例11: getSignature

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
/**
 * 获得范型中的类型
 * 
 * @param obj
 * @return
 */
public static String getSignature(FieldOrMethod obj) {
	for (Attribute attribute : obj.getAttributes()) {
		if (attribute instanceof Signature) {
			return ((Signature) attribute).getSignature();
		}
	}
	return obj.getSignature();
}
 
开发者ID:jdepend,项目名称:cooper,代码行数:15,代码来源:SignatureUtil.java


示例12: visitCode

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
@Override
public void visitCode(Code obj) {
    code = obj;
    super.visitCode(obj);
    CodeException[] exceptions = obj.getExceptionTable();
    for (CodeException exception : exceptions)
        exception.accept(this);
    Attribute[] attributes = obj.getAttributes();
    for (Attribute attribute : attributes)
        attribute.accept(this);
    visitAfter(obj);
    code = null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:14,代码来源:PreorderVisitor.java


示例13: visit

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
@Override
public void visit(JavaClass obj) {
    String superclassName = obj.getSuperclassName();
    isSynthetic = superclassName.equals("java.rmi.server.RemoteStub");
    Attribute[] attributes = obj.getAttributes();
    if (attributes != null) {
        for (Attribute a : attributes) {
            if (a instanceof Synthetic) {
                isSynthetic = true;
            }
        }
    }

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:15,代码来源:DumbMethods.java


示例14: isSynthetic

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
boolean isSynthetic(FieldOrMethod obj) {
    Attribute[] a = obj.getAttributes();
    for (Attribute aA : a)
        if (aA instanceof Synthetic)
            return true;
    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:8,代码来源:SerializableIdiom.java


示例15: classHasParameter

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
public static boolean classHasParameter(JavaClass obj) {
    for (Attribute a : obj.getAttributes())
        if (a instanceof Signature) {
            String sig = ((Signature) a).getSignature();
            return sig.charAt(0) == '<';
        }
    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:9,代码来源:UnreadFields.java


示例16: isSynthetic

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
/**
 * Methods marked with the "Synthetic" attribute do not appear in the source
 * code
 */
private boolean isSynthetic(Method m) {
    if ((m.getAccessFlags() & Constants.ACC_SYNTHETIC) != 0)
        return true;
    Attribute[] attrs = m.getAttributes();
    for (Attribute attr : attrs) {
        if (attr instanceof Synthetic)
            return true;
    }
    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:15,代码来源:FindUnrelatedTypesInGenericContainer.java


示例17: visitCode

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
@Override
public void visitCode(Code obj) {
    try {
        String methodName = getMethodName();

        if (!methodName.equals("<init>") && !methodName.equals("clone")
                && ((getMethod().getAccessFlags() & (Constants.ACC_STATIC | Constants.ACC_SYNTHETIC)) == 0)) {

            /*
             * for some reason, access flags doesn't return Synthetic, so do
             * this hocus pocus
             */
            Attribute[] atts = getMethod().getAttributes();
            for (Attribute att : atts) {
                if (att.getClass().equals(Synthetic.class))
                    return;
            }

            byte[] codeBytes = obj.getCode();
            if ((codeBytes.length == 0) || (codeBytes[0] != ALOAD_0))
                return;

            state = State.SEEN_NOTHING;
            invokePC = 0;
            super.visitCode(obj);
            if ((state == State.SEEN_RETURN) && (invokePC != 0)) {
                // Do this check late, as it is potentially expensive
                Method superMethod = findSuperclassMethod(superclassName, getMethod());
                if ((superMethod == null) || accessModifiersAreDifferent(getMethod(), superMethod))
                    return;

                bugReporter.reportBug(new BugInstance(this, "USM_USELESS_SUBCLASS_METHOD", LOW_PRIORITY).addClassAndMethod(
                        this).addSourceLine(this, invokePC));
            }
        }
    } catch (ClassNotFoundException cnfe) {
        bugReporter.reportMissingClass(cnfe);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:40,代码来源:UselessSubclassMethod.java


示例18: isSynthetic

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
private boolean isSynthetic(Method m) {
    if (m.isSynthetic())
        return true;
    Attribute[] attrs = m.getAttributes();
    for (Attribute attr : attrs) {
        if (attr instanceof Synthetic)
            return true;
    }
    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:11,代码来源:FindBadCast2.java


示例19: getGenericSignatureIterator

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
/**
 * @param target
 *            the method whose signature is to be parsed
 * @return an iterator over the parameters of the generic signature of
 *         method. Returns null if the generic signature cannot be parsed
 */
public static @CheckForNull
Iterator<String> getGenericSignatureIterator(Method target) {
    try {
        GenericSignatureParser parser = null;
        String genericSignature = null;
        for (Attribute a : target.getAttributes()) {
            if (a instanceof Signature) {

                Signature sig = (Signature) a;
                if (genericSignature != null) {
                    if (!genericSignature.equals(sig.getSignature())) {
                        if (false) {
                            System.out.println("Inconsistent signatures: ");
                            System.out.println(genericSignature);
                            System.out.println(sig.getSignature());
                        }
                        return null; // we've seen two inconsistent
                                     // signatures
                    }
                    continue;
                }

                genericSignature = sig.getSignature();
                if (compareSignatures(target.getSignature(), genericSignature))
                    parser = new GenericSignatureParser(genericSignature);
            }
        }
        Iterator<String> iter = parser == null ? null : parser.parameterSignatureIterator();
        return iter;
    } catch (RuntimeException e) {
    } // degrade gracefully
    return null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:40,代码来源:GenericSignatureParser.java


示例20: isSynthetic

import org.apache.bcel.classfile.Attribute; //导入依赖的package包/类
public static boolean isSynthetic(FieldOrMethod m) {
    if (m.isSynthetic())
        return true;

    for(Attribute a : m.getAttributes())
        if (a instanceof Synthetic)
            return true;
    return false;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:10,代码来源:BCELUtil.java



注:本文中的org.apache.bcel.classfile.Attribute类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocalQuickFixAndIntentionActionOnPsiElement类代码示例发布时间:2022-05-22
下一篇:
Java Polyline类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap