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
- readme
- SOLID
- kotlin
- markdown
- 더티비트
- design pattern
- 깃허브
- spring
- LiveData
- test
- Compose
- 운영체제
- OS
- Di
- coroutine flow
- Class.class
- 다단계 큐
- Spring Boot
- Android
- JUnit
- O.S
- Constraint Layout
- Data Binding
- github
- 데드락
- JetPack
- 마크다운
- 리드미
- git
- android study jam
Archives
- Today
- Total
차지
[Java] Reflection 본문
리플렉션
- 객체를 통해 클래스의 정보를 분석하는 기법입니다.
Class.class
Instances of the class Class represent classes and interfaces
in a running Java application. Every array also belongs to a class that is
reflected as a Class object that is shared by all arrays with
the same element type and number of dimensions.
- ⇒ Class 클래스의 객체는 자바 프로그램에서 사용되는 클래스들과 인터페이스들을 나타낸다.
- 사용 가능한 클래스의 인스턴스가 없을 때 .class를 사용하곤 합니다.
- 인스턴스가 있다면 getClass() 메서드로 얻을 수 있습니다.
- 코드 리플렉션에 사용됩니다.
- 정규화 된 클래스 이름, 상수 목록, 공용 필드 목록 등과 같은 클래스의 메타 데이터를 수집 할 수 있습니다.
실사용
Method[] methods = testClass.getMethods();
//getMethod("메서드", 파라미터);
Method method = testClass.getMethod("testMethod");
Method method = testClass.getMethod("testMethod", null);
Method method = testClass.getMethod("testMethod", String.class);
Method method = testClass.getMethod("testMethod", new Class[]{String.class, Integer.class});
- 리플렉션을 사용하면 외부에서 클래스의 private 메서드도 꺼내볼 수 있습니다.
References
'Android > Android' 카테고리의 다른 글
| [Android] LiveData -> Coroutine Flow (0) | 2022.05.24 |
|---|---|
| [Kotlin] inline function (0) | 2022.02.23 |
| [Android] Single Live Event & Event wrapper (0) | 2022.01.25 |
| [Android] Two - way Data Binding (0) | 2022.01.19 |
| [DI] Android에서의 DI 첫걸음 (0) | 2022.01.07 |