Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- grep
- IntelliJ
- find
- JavaScript
- plugin
- 단축키
- port
- resource
- Mac
- profile
- lsof
- Source
- import
- netsh
- vscode
- VirtualBox
- maVen
- xargs
- Eclipse
- bash
- GIT
- Windows
- Windows 10
- 줄바꿈 문자
- Quartz
- web.xml
- tomcat
- 네트워크
- context
- ssh
Archives
- Today
- Total
develog
Reflection Test 본문
private void reflectionTest() {
try {
// get class
Class clazz = Class.forName("vo.UserVo");
// create instance
UserVo vo = (UserVo) clazz.newInstance();
// get field
Field field = clazz.getDeclaredField("privateField");
// set field value
field.setAccessible(true);
field.set(vo, "aaaaaa");
// get field value
String value = (String) field.get(vo);
System.out.println(value);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
'Dev > Java' 카테고리의 다른 글
Annotation 종류 (0) | 2012.11.06 |
---|---|
Reflection (0) | 2012.11.06 |
[Tomcat] jsp cache clear (0) | 2012.10.08 |
timestamp 출력 (0) | 2012.09.21 |
callback test (0) | 2012.08.06 |
Comments