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

Java InnerClasses类代码示例

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

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



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

示例1: getOuterClass

import org.apache.bcel.classfile.InnerClasses; //导入依赖的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: getOuterClass

import org.apache.bcel.classfile.InnerClasses; //导入依赖的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


示例3: visitInnerClasses

import org.apache.bcel.classfile.InnerClasses; //导入依赖的package包/类
@Override
public void visitInnerClasses(InnerClasses obj) {
    super.visitInnerClasses(obj);
    InnerClass[] inner_classes = obj.getInnerClasses();
    for (InnerClass inner_class : inner_classes)
        inner_class.accept(this);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:8,代码来源:PreorderVisitor.java


示例4: visitInnerClasses

import org.apache.bcel.classfile.InnerClasses; //导入依赖的package包/类
public void visitInnerClasses(InnerClasses obj){//vmspec2 4.7.5

			// exactly one InnerClasses attr per ClassFile if some inner class is refernced: see visitJavaClass()

			checkIndex(obj, obj.getNameIndex(), CONST_Utf8);

			String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
			if (! name.equals("InnerClasses")){
				throw new ClassConstraintException("The InnerClasses attribute '"+tostring(obj)+"' is not correctly named 'InnerClasses' but '"+name+"'.");
			}

			InnerClass[] ics = obj.getInnerClasses();

			for (int i=0; i<ics.length; i++){
				checkIndex(obj, ics[i].getInnerClassIndex(), CONST_Class);
				int outer_idx = ics[i].getOuterClassIndex();
				if (outer_idx != 0){
					checkIndex(obj, outer_idx, CONST_Class);
				}
				int innername_idx = ics[i].getInnerNameIndex();
				if (innername_idx != 0){
					checkIndex(obj, innername_idx, CONST_Utf8);
				}
				int acc = ics[i].getInnerAccessFlags();
				acc = acc & (~ (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED | ACC_STATIC | ACC_FINAL | ACC_INTERFACE | ACC_ABSTRACT));
				if (acc != 0){
					addMessage("Unknown access flag for inner class '"+tostring(ics[i])+"' set (InnerClasses attribute '"+tostring(obj)+"').");
				}
			}
			// Semantical consistency is not yet checked by Sun, see vmspec2 4.7.5.
			// [marked TODO in JustIce]
		}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:33,代码来源:Pass2Verifier.java


示例5: Clazz

import org.apache.bcel.classfile.InnerClasses; //导入依赖的package包/类
/**
 * Constructs a <code>Clazz</code> object.
 * 
 * @param classProvider - a helper that provides the class information.
 * @param className - a fully qualified name of a class.
 * @param verbose - true, if output should be verbose. Otherwise false.
 */
public Clazz(ClassProvider classProvider, String className, boolean verbose) 
        throws ClassNotFoundException {
    wrappedClass = classProvider.getJavaClass(className);
    constPool = wrappedClass.getConstantPool();
    this.verbose = verbose;

    // Assign an empty array by default.
    Vector foundInners = new Vector();
    // Get the class attributes.
    Attribute attrs[] = wrappedClass.getAttributes();
    for (int i = 0; i < attrs.length; i++) {
        // Find the InnerClasses attribute, if any.
        if (attrs[i] instanceof InnerClasses) {
            // The InnerClasses attribute is found.
            innerClasses = (InnerClasses) attrs[i];

            // Get an array of the inner classes.
            InnerClass inners[] = innerClasses.getInnerClasses();
            for (int j = 0; j < inners.length; j++) {

                // Get the inner class name from a constant pool.
                String innerClassName = Utility.compactClassName(
                        innerClasses.getConstantPool().getConstantString(
                                inners[j].getInnerClassIndex(), 
                                Constants.CONSTANT_Class),
                        false);

                // The inner class has the InnerClasses attribute as well
                // as its outer class. So, we should ignore such an inner 
                // class.
                if (!innerClassName.equals(className)) {
                    foundInners.addElement(innerClassName);
                }
            }
            break;
        }
    }
    // Fill in the inner class array with the found inner classes.
    innerClassNames = new String[foundInners.size()];
    foundInners.toArray(innerClassNames);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:49,代码来源:Clazz.java


示例6: Clazz

import org.apache.bcel.classfile.InnerClasses; //导入依赖的package包/类
/**
 * Constructs a <code>Clazz</code> object.
 * 
 * @param classProvider - a helper that provides the class information.
 * @param className - a fully qualified name of a class.
 */
public Clazz(ClassProvider classProvider, String className) 
        throws ClassNotFoundException {
    wrappedClass = classProvider.getJavaClass(className);

    // Assign an empty array by default.
    Vector foundInners = new Vector();
    // Get the class attributes.
    Attribute attrs[] = wrappedClass.getAttributes();
    for (int i = 0; i < attrs.length; i++) {
        // Find the InnerClasses attribute, if any.
        if (attrs[i] instanceof InnerClasses) {
            // The InnerClasses attribute is found.
            InnerClasses innerAttr = (InnerClasses) attrs[i];

            // Get an array of the inner classes.
            InnerClass inners[] = innerAttr.getInnerClasses();
            for (int j = 0; j < inners.length; j++) {

                // Get the inner class name from a constant pool.
                String innerClassName = Utility.compactClassName(
                        innerAttr.getConstantPool().getConstantString(
                                inners[j].getInnerClassIndex(), 
                                Constants.CONSTANT_Class),
                        false);

                // The inner class has the InnerClasses attribute as well
                // as its outer class. So, we should ignore such an inner 
                // class.
                if (!innerClassName.equals(className)) {
                    foundInners.addElement(innerClassName);
                }
            }
            break;
        }
    }
    // Fill in the inner class array with the found inner classes.
    innerClassNames = new String[foundInners.size()];
    foundInners.toArray(innerClassNames);

    // Collect up fields of the given class and all its ancestors.
    fields = new Vector();
    JavaClass clss = wrappedClass;
    while (true) {
        searchForFields(clss);
        String superClassName = clss.getSuperclassName();
        if (clss.getClassName().equals(superClassName)) {
            break;
        }
        // Retrieve the next super class.
        clss = classProvider.getJavaClass(superClassName);
    }

    // Collect up methods.
    methods = new Vector();
    searchForMethods(wrappedClass);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:63,代码来源:Clazz.java


示例7: visit

import org.apache.bcel.classfile.InnerClasses; //导入依赖的package包/类
public void visit(InnerClasses obj) {
    visit((Attribute) obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java


示例8: visitInnerClasses

import org.apache.bcel.classfile.InnerClasses; //导入依赖的package包/类
public void visitInnerClasses(InnerClasses obj) {
    visit(obj);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java


示例9: visitJavaClass

import org.apache.bcel.classfile.InnerClasses; //导入依赖的package包/类
public void visitJavaClass(JavaClass obj){
	Attribute[] atts = obj.getAttributes();
	boolean foundSourceFile = false;
	boolean foundInnerClasses = false;

	// Is there an InnerClass referenced?
	// This is a costly check; existing verifiers don't do it!
	boolean hasInnerClass = new InnerClassDetector(jc).innerClassReferenced();

	for (int i=0; i<atts.length; i++){
		if ((! (atts[i] instanceof SourceFile)) &&
		    (! (atts[i] instanceof Deprecated))     &&
		    (! (atts[i] instanceof InnerClasses)) &&
		    (! (atts[i] instanceof Synthetic))){
			addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of the ClassFile structure '"+tostring(obj)+"' is unknown and will therefore be ignored.");
		}

		if (atts[i] instanceof SourceFile){
			if (foundSourceFile == false) {
                      foundSourceFile = true;
                  } else {
                      throw new ClassConstraintException("A ClassFile structure (like '"+tostring(obj)+"') may have no more than one SourceFile attribute."); //vmspec2 4.7.7
                  }
		}

		if (atts[i] instanceof InnerClasses){
			if (foundInnerClasses == false) {
                      foundInnerClasses = true;
                  } else{
				if (hasInnerClass){
					throw new ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). More than one InnerClasses attribute was found.");
				}
			}
			if (!hasInnerClass){
				addMessage("No referenced Inner Class found, but InnerClasses attribute '"+tostring(atts[i])+"' found. Strongly suggest removal of that attribute.");
			}
		}

	}
	if (hasInnerClass && !foundInnerClasses){
		//throw new ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). No InnerClasses attribute was found.");
		//vmspec2, page 125 says it would be a constraint: but existing verifiers
		//don't check it and javac doesn't satisfy it when it comes to anonymous
		//inner classes
		addMessage("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). No InnerClasses attribute was found.");
	}
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:48,代码来源:Pass2Verifier.java


示例10: visitInnerClasses

import org.apache.bcel.classfile.InnerClasses; //导入依赖的package包/类
public void visitInnerClasses(InnerClasses obj) {
    tostring = toString(obj);
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:4,代码来源:StringRepresentation.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java TelegramBot类代码示例发布时间:2022-05-22
下一篇:
Java GenerateMembersUtil类代码示例发布时间: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