@Test public void testListInnerClasses() throws IOException { InputStream classFileInputStream = URLClassLoader.getSystemResourceAsStream( EXAMPLE_CLASS_FILE); ClassParser parser = new ClassParser(classFileInputStream, EXAMPLE_CLASS_FILE); JavaClass javaClass = parser.parse(); Set<String> innerClassNames = ClassDumper.listInnerClassNames(javaClass); Truth.assertThat(innerClassNames).containsExactly( "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreFutureStub", "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreMethodDescriptorSupplier", "com.google.firestore.v1beta1.FirestoreGrpc$1", "com.google.firestore.v1beta1.FirestoreGrpc$MethodHandlers", "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreStub", "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreBaseDescriptorSupplier", "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreBlockingStub", "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreImplBase", "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreFileDescriptorSupplier" ); }
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) { 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; } } String normalInnerClassName = innerClassName.replace('/', '.'); innerClassNames.add(normalInnerClassName); } } } return innerClassNames.build(); }
ClassDumper { 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) { 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; } } String normalInnerClassName = innerClassName.replace('/', '.'); innerClassNames.add(normalInnerClassName); } } } return innerClassNames.build(); } }
ClassDumper { 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) { 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; } } String normalInnerClassName = innerClassName.replace('/', '.'); innerClassNames.add(normalInnerClassName); } } } return innerClassNames.build(); } private  ClassDumper(
      List<ClassPathEntry> inputClassPath,
      ClassLoader extensionClassLoader,
      Map<String, ClassPathEntry> fileNameToClassPathEntry); }
ClassDumper { 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) { 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; } } String normalInnerClassName = innerClassName.replace('/', '.'); innerClassNames.add(normalInnerClassName); } } } return innerClassNames.build(); } private  ClassDumper(
      List<ClassPathEntry> inputClassPath,
      ClassLoader extensionClassLoader,
      Map<String, ClassPathEntry> fileNameToClassPathEntry);  }
ClassDumper { 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) { 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; } } String normalInnerClassName = innerClassName.replace('/', '.'); innerClassNames.add(normalInnerClassName); } } } return innerClassNames.build(); } private  ClassDumper(
      List<ClassPathEntry> inputClassPath,
      ClassLoader extensionClassLoader,
      Map<String, ClassPathEntry> fileNameToClassPathEntry);   }