Java Code Examples for org.apache.bcel.classfile.Attribute#getTag()
The following examples show how to use
org.apache.bcel.classfile.Attribute#getTag() .
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: 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(); }