org.apache.bcel.classfile.InnerClass Java Examples
The following examples show how to use
org.apache.bcel.classfile.InnerClass.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Util.java From spotbugs with GNU Lesser General Public License v2.1 | 7 votes |
/** * 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; }
Example #2
Source File: ClassDumper.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
static ImmutableSet<String> listInnerClassNames(JavaClass javaClass) { ImmutableSet.Builder<String> innerClassNames = ImmutableSet.builder(); String topLevelClassName = javaClass.getClassName(); ConstantPool constantPool = javaClass.getConstantPool(); for (Attribute attribute : javaClass.getAttributes()) { if (attribute.getTag() == Const.ATTR_INNER_CLASSES) { // This innerClasses variable does not include double-nested inner classes InnerClasses innerClasses = (InnerClasses) attribute; for (InnerClass innerClass : innerClasses.getInnerClasses()) { int classIndex = innerClass.getInnerClassIndex(); String innerClassName = constantPool.getConstantString(classIndex, Const.CONSTANT_Class); int outerClassIndex = innerClass.getOuterClassIndex(); if (outerClassIndex > 0) { String outerClassName = constantPool.getConstantString(outerClassIndex, Const.CONSTANT_Class); String normalOuterClassName = outerClassName.replace('/', '.'); if (!normalOuterClassName.equals(topLevelClassName)) { continue; } } // Class names stored in constant pool have '/' as separator. We want '.' (as binary name) String normalInnerClassName = innerClassName.replace('/', '.'); innerClassNames.add(normalInnerClassName); } } } return innerClassNames.build(); }
Example #3
Source File: PreorderVisitor.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void visitInnerClasses(InnerClasses obj) { super.visitInnerClasses(obj); InnerClass[] inner_classes = obj.getInnerClasses(); for (InnerClass inner_class : inner_classes) { inner_class.accept(this); } }
Example #4
Source File: Pass2Verifier.java From commons-bcel with Apache License 2.0 | 5 votes |
@Override public void visitInnerClasses(final 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); final 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+"'."); } final InnerClass[] ics = obj.getInnerClasses(); for (final InnerClass ic : ics) { checkIndex(obj, ic.getInnerClassIndex(), CONST_Class); final int outer_idx = ic.getOuterClassIndex(); if (outer_idx != 0) { checkIndex(obj, outer_idx, CONST_Class); } final int innername_idx = ic.getInnerNameIndex(); if (innername_idx != 0) { checkIndex(obj, innername_idx, CONST_Utf8); } int acc = ic.getInnerAccessFlags(); acc = acc & (~ (Const.ACC_PUBLIC | Const.ACC_PRIVATE | Const.ACC_PROTECTED | Const.ACC_STATIC | Const.ACC_FINAL | Const.ACC_INTERFACE | Const.ACC_ABSTRACT)); if (acc != 0) { addMessage( "Unknown access flag for inner class '"+tostring(ic)+"' set (InnerClasses attribute '"+tostring(obj)+"')."); } } // Semantical consistency is not yet checked by Sun, see vmspec2 4.7.5. // [marked TODO in JustIce] }
Example #5
Source File: BetterVisitor.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
public void visit(InnerClass obj) { }
Example #6
Source File: BetterVisitor.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void visitInnerClass(InnerClass obj) { visit(obj); }
Example #7
Source File: Pass2Verifier.java From commons-bcel with Apache License 2.0 | 4 votes |
@Override public void visitInnerClass(final InnerClass obj) { // This does not represent an Attribute but is only // related to internal BCEL data representation. }
Example #8
Source File: StringRepresentation.java From commons-bcel with Apache License 2.0 | 4 votes |
@Override public void visitInnerClass(final InnerClass obj) { tostring = toString(obj); }
Example #9
Source File: CounterVisitor.java From commons-bcel with Apache License 2.0 | 4 votes |
@Override public void visitInnerClass(final InnerClass obj) { innerClassCount++; }