当前位置: 首页>>代码示例>>Java>>正文


Java Attribute类代码示例

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


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


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