250x250
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
- DP
- 모드코드
- 음악작곡기초
- code tree
- 마법사상어와 블리자드
- 삼성SW Expert Academy
- 코드트리
- 드럼Tab악보
- 음정이론
- 취준
- 삼성전자
- 화음분석
- 코드차용
- 음계구조
- 공대생 자소서
- 코딩테스트
- 코테
- 모달진행
- 무료 악보 프로그램
- 스케일분석
- mode chord
- SW 직군
- ableton live 12
- 삼성기출
- 화성학응용
- Java
- syncroom
- 대중음악화성
- 평행조
- 알고리즘
Archives
- Today
- Total
Code Beat
[JAVA] Reflection 본문
728x90
: 객체를 통해 클래스의 정보를 분석해 내는 프로그램 기법
Object.getClass()를 통해 클래스 정보를 로드
예시 코드
Class c = "foo".getClass();
System.out.println(c); // 출력 : class java.lang.String
byte[] b = new byte[1024];
System.out.println(b.getClass()); // 출력 : class [B
int a = 1;
System.out.println(a.getClass()); // 에러 발생
Integer d = 1;
System.out.println(d.getClass()); // 에러 발생
System.out.println(Integer.TYPE); // 출력 : int
Method를 활용한 클래스 반환
- Class.getSuperClass()
- Class.getClass()
- Class.getDeclaredClass()
- Class.getDeclaringClass()
- …
예시 코드
Class c = Double.TYPE;
System.out.println(c.getDeclaredClasses()); // 출력 : [Ljava.lang.Class;@2a139a55
특징
- 확장성
- 클래스 브라우저 및 시각적 개발 환경 제공
- 디버거 및 테스트 도구
사용 시 유의할 점
- Peformance 오버헤드
- Reflection 작업 시 성능이 떨어질 수 있음
- 보안 제한 사항
- java 보안 제약 조건 위반을 허용
- 캡슐화 저해
- 가독성 저하
참고 링크 : https://docs.oracle.com/javase/tutorial/reflect/
728x90
'Code > 코딩 끄적' 카테고리의 다른 글
JPA (0) | 2024.03.24 |
---|---|
strictfp (Strict Floating Point) (0) | 2024.03.03 |
stompCORS (0) | 2024.03.03 |