private void processClassWithByteCode ( final Class < ? > clazz , final InputStream stream , final boolean includeFinalMethods ) throws IOException { final ClassReader reader = new ClassReader ( stream ) ; final ClassFieldVisitor visitor = new ClassFieldVisitor ( clazz , includeFinalMethods , this ) ; reader . accept ( visitor , 0 ) ; if ( clazz . getSuperclass ( ) != null ) { final String name = getResourcePath ( clazz . getSuperclass ( ) ) ; final InputStream parentStream = clazz . getResourceAsStream ( name ) ; if ( parentStream != null ) { try { processClassWithByteCode ( clazz . getSuperclass ( ) , parentStream , includeFinalMethods ) ; } finally { parentStream . close ( ) ; } } else { processClassWithoutByteCode ( clazz . getSuperclass ( ) , includeFinalMethods ) ; } } if ( clazz . isInterface ( ) ) { final Class < ? > [ ] interfaces = clazz . getInterfaces ( ) ; for ( Class < ? > anInterface : interfaces ) { final String name = getResourcePath ( anInterface ) ; final InputStream parentStream = clazz . getResourceAsStream ( name ) ; if ( parentStream != null ) { try { processClassWithByteCode ( anInterface , parentStream , includeFinalMethods ) ; } finally { parentStream . close ( ) ; } } else { processClassWithoutByteCode ( anInterface , includeFinalMethods ) ; } } } }
Walk up the inheritance hierarchy recursively reading in fields