Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; import java.util.List; public class Main { private static void processAttachAllProperties(Class<? extends Object> clazz, List<Field> fields) { if (!isEffectiveClass(clazz)) { return; } Field[] declaredFields = clazz.getDeclaredFields(); for (Field field : declaredFields) { fields.add(field); } processAttachAllProperties(clazz.getSuperclass(), fields); } private static boolean isEffectiveClass(Class<? extends Object> clazz) { if (clazz == null) { return false; } if (clazz == Class.class) { return false; } if (clazz == Object.class) { return false; } return true; } }