public ReflectionLuceneSerializer(Class<? extends Object> clazz, String[] indexedFields) { Set<String> fieldSet = new HashSet<String>(); fieldSet.addAll(Arrays.asList(indexedFields)); // Iterate through all declared fields and save them // in a list if they are an indexed field and have the correct // type. ArrayList<Field> foundFields = new ArrayList<Field>(); while (clazz != Object.class) { for (Field field : clazz.getDeclaredFields()) { Class<?> type = field.getType(); if (fieldSet.contains(field.getName()) && SerializerUtil.isSupported(type)) { field.setAccessible(true); foundFields.add(field); } } clazz = clazz.getSuperclass(); } this.fields = foundFields.toArray(new Field[foundFields.size()]); }