zbo2018
5/9/2019 - 6:30 AM

反射

反射获得protected、private变量
public class EsService {
    private static List spellList = new ArrayList();
}

EsService service = new EsService();
Field spellListField = service.getClass().getDeclaredField("spellList");
spellListField.setAccessible(true);
List spellList = (List) spellListField.get(service);