connector/src/main/java/org/jboss/as/connector/util/Injection.java
protected Field findField(Class<?> clz, String fieldName, String fieldType) {
        while (!clz.equals(Object.class)) {
            List<Field> hits = null;
            Field[] fields = SecurityActions.getDeclaredFields(clz);
            for (int i = 0; i < fields.length; i++) {
                final Field field = fields[i];
                if (fieldName.equals(field.getName())) {
                    if (fieldType == null || argumentMatches(fieldType, field.getType().getName())) {
                        if (hits == null)
                            hits = new ArrayList<Field>(1);

                        SecurityActions.setAccessible(field);

                        hits.add(field);
                    }
                }
            }

            if (hits != null) {
                if (hits.size() == 1) {
                    return hits.get(0);
                } else {
                    Collections.sort(hits, new FieldSorter());
                    if (fieldType != null) {
                        for (Field f : hits) {
                            if (fieldType.equals(f.getType().getName()))
                                return f;
                        }
                    }

                    return hits.get(0);
                }
            }

            clz = clz.getSuperclass();
        }

        return null;
    }
protected Field findField(Class<?> clz, String fieldName, String fieldType) {
        while (!clz.equals(Object.class)) {
            List<Field> hits = null;
            Field[] fields = SecurityActions.getDeclaredFields(clz);
            for (int i = 0; i < fields.length; i++) {
                final Field field = fields[i];
                if (fieldName.equals(field.getName())) {
                    if (fieldType == null || argumentMatches(fieldType, field.getType().getName())) {
                        if (hits == null)
                            hits = new ArrayList<Field>(1);

                        SecurityActions.setAccessible(field);

                        hits.add(field);
                    }
                }
            }

            if (hits != null) {
                if (hits.size() == 1) {
                    return hits.get(0);
                } else {
                    Collections.sort(hits, new FieldSorter());
                    if (fieldType != null) {
                        for (Field f : hits) {
                            if (fieldType.equals(f.getType().getName()))
                                return f;
                        }
                    }

                    return hits.get(0);
                }
            }

            clz = clz.getSuperclass();
        }

        return null;
    }
protected Field findField ( Class < ? > clz , String fieldName , String fieldType ) { while ( ! clz . equals ( Object . class ) ) { List < Field > hits = null ; Field [ ] fields = SecurityActions . getDeclaredFields ( clz ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { final Field field = fields [ i ] ; if ( fieldName . equals ( field . getName ( ) ) ) { if ( fieldType == null || argumentMatches ( fieldType , field . getType ( ) . getName ( ) ) ) { if ( hits == null ) hits = new ArrayList < Field > ( 1 ) ; SecurityActions . setAccessible ( field ) ; hits . add ( field ) ; } } } if ( hits != null ) { if ( hits . size ( ) == 1 ) { return hits . get ( 0 ) ; } else { Collections . sort ( hits , new FieldSorter ( ) ) ; if ( fieldType != null ) { for ( Field f : hits ) { if ( fieldType . equals ( f . getType ( ) . getName ( ) ) ) return f ; } } return hits . get ( 0 ) ; } } clz = clz . getSuperclass ( ) ; } return null ; }
Find a field

@param clz       The class
@param fieldName The field name
@param fieldType The field type; can be <code>null</code>
@return The field; <code>null</code> if not found
Find a field