本文整理汇总了Java中org.apache.bcel.classfile.InnerClass类的典型用法代码示例。如果您正苦于以下问题:Java InnerClass类的具体用法?Java InnerClass怎么用?Java InnerClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InnerClass类属于org.apache.bcel.classfile包,在下文中一共展示了InnerClass类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOuterClass
import org.apache.bcel.classfile.InnerClass; //导入依赖的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;
}
示例2: getOuterClass
import org.apache.bcel.classfile.InnerClass; //导入依赖的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;
}
示例3: visitInnerClasses
import org.apache.bcel.classfile.InnerClass; //导入依赖的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);
}
示例4: visitInnerClasses
import org.apache.bcel.classfile.InnerClass; //导入依赖的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]
}
示例5: Clazz
import org.apache.bcel.classfile.InnerClass; //导入依赖的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);
}
示例6: Clazz
import org.apache.bcel.classfile.InnerClass; //导入依赖的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);
}
示例7: visit
import org.apache.bcel.classfile.InnerClass; //导入依赖的package包/类
public void visit(InnerClass obj) {
}
示例8: visitInnerClass
import org.apache.bcel.classfile.InnerClass; //导入依赖的package包/类
public void visitInnerClass(InnerClass obj) {
visit(obj);
}
示例9: visitInnerClass
import org.apache.bcel.classfile.InnerClass; //导入依赖的package包/类
public void visitInnerClass(InnerClass obj){
// This does not represent an Attribute but is only
// related to internal BCEL data representation.
}
示例10: visitInnerClass
import org.apache.bcel.classfile.InnerClass; //导入依赖的package包/类
public void visitInnerClass(InnerClass obj) {
tostring = toString(obj);
}