Android/Android Native
[Android] JNI method signature에 대한 고찰
2024. 8. 9. 00:09반응형
JNI method signature에 대한 예시 몇개를 보자
Java Method | JNI method signature | 설명 |
void onSpeedUp(int spped, String carName, byte[] byteData) | (ILjava/lang/String;[B)V | Return type: void -> V Parameter type: int -> I String -> Ljava/lang/String; byte[] -> [B |
int size(byte[] arr) | (I[B)I | Return type: int → I Parameter type: byte[] → [B |
byte[] covertToString(String s) | ([Ljava/lang/String;)[B | Return type: byte[] → [B Parameter type: String → Ljava/lang/String; |
int[] covertToint(String s) | ([Ljava/lang/String;)[I | Return type: int[] → [I Parameter type: String → Ljava/lang/String; |
boolean isConnected() | ()Z | Return type: boolean → Z Parameter type: none (no parameters) |
AAA returnAAA(BBB b) | (LBBB;)LAAA; | Return Type: AAA is a class, so its type in JNI is L<class name>; Therefore, AAA → LAAA; Parameter Type: BBB is also a class, so its type in JNI is L<class name>; Therefore, BBB → LBBB; |
※ 주의할점
String은 Ljava/lang/String이 아니라 Ljava/lang/String;
즉 세미콜론까지 함께 붙여주어야 한다.
아래를 참고하면 특정 Java method에 대한 JNI method signature를 쉽게 이해할 수 있다.
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html
반응형
'Android > Android Native' 카테고리의 다른 글
[Android Native][JNI] CMakeLists.txt에 원하는 CPP파일 추가하기 (0) | 2024.08.09 |
---|---|
[Android Native] Abort message: 'JNI DETECTED ERROR IN APPLICATION: JNI ERROR (app bug): jclass is an invalid local reference: XXXX (0) | 2024.08.09 |
[Android][JNI] 멀티쓰레드 관련 Stack overflow 정리 (0) | 2024.08.05 |
[Android][JNI] JNI 메소드 만들기 (Main) (0) | 2024.07.04 |
[Android][JNI] Native code에 로그 찍기 및 Logcat에 출력하게 하기 (0) | 2024.05.30 |