Journal of Computer Applications ›› 2024, Vol. 44 ›› Issue (7): 2151-2159.DOI: 10.11772/j.issn.1001-9081.2023070968
• Computer software technology • Previous Articles Next Articles
Shuo SUN1, Wei ZHANG1,2,3, Wendi FENG1(), Yuwei ZHANG4
Received:
2023-07-19
Revised:
2023-09-25
Accepted:
2023-09-25
Online:
2023-10-26
Published:
2024-07-10
Contact:
Wendi FENG
About author:
SUN Shuo, born in 1999, M. S. candidate. His research interests include operating system kernels, computer networks.Supported by:
通讯作者:
冯温迪
作者简介:
孙蒴(1999—),男,河北任丘人,硕士研究生,主要研究方向:操作系统内核、计算机网络;基金资助:
CLC Number:
Shuo SUN, Wei ZHANG, Wendi FENG, Yuwei ZHANG. Automatic foreign function interface generation method based on source code analysis[J]. Journal of Computer Applications, 2024, 44(7): 2151-2159.
孙蒴, 张伟, 冯温迪, 张俞炜. 基于源码分析的自动化外部函数接口生成方法[J]. 《计算机应用》唯一官方网站, 2024, 44(7): 2151-2159.
Add to citation manager EndNote|Ris|BibTeX
URL: https://www.joca.cn/EN/10.11772/j.issn.1001-9081.2023070968
方法 | 接口分析 | 分析对象 | 自动化完成 | ||
---|---|---|---|---|---|
编码 | 封装 | 测试 | |||
SWIG[ | × | 单个 | ○ | × | △ |
JACAW[ | △ | 单个 | △ | × | × |
ctypesgen[ | △ | 单个 | △ | × | × |
AFIG | ○ | 多个 | ○ | ○ | △ |
Tab. 1 Comparison between AFIG and existing methods
方法 | 接口分析 | 分析对象 | 自动化完成 | ||
---|---|---|---|---|---|
编码 | 封装 | 测试 | |||
SWIG[ | × | 单个 | ○ | × | △ |
JACAW[ | △ | 单个 | △ | × | × |
ctypesgen[ | △ | 单个 | △ | × | × |
AFIG | ○ | 多个 | ○ | ○ | △ |
统一表示 | JNA | Ctypes | cgo |
---|---|---|---|
int | int | c_int | C.int |
char | byte | c_wchar | C.char |
short | short | c_short | C.short |
long | long | c_long | C.long |
long long | long | c_longlong | C.longlong |
unsigned char | char | c_ubyte | C.uchar |
unsigned short | short | c_ushort | C.ushort |
unsigned int | int | c_uint | C.uint |
unsigned long | long | c_ulong | C.ulong |
int* | Pointer | c_int_p | *C.int |
char* | String/byte[] | c_char_p | *C.char |
void* | Pointer | c_void_p | unsafe.Poniter |
Tab. 2 Mapping relationships of basic variable types in FFI rule set
统一表示 | JNA | Ctypes | cgo |
---|---|---|---|
int | int | c_int | C.int |
char | byte | c_wchar | C.char |
short | short | c_short | C.short |
long | long | c_long | C.long |
long long | long | c_longlong | C.longlong |
unsigned char | char | c_ubyte | C.uchar |
unsigned short | short | c_ushort | C.ushort |
unsigned int | int | c_uint | C.uint |
unsigned long | long | c_ulong | C.ulong |
int* | Pointer | c_int_p | *C.int |
char* | String/byte[] | c_char_p | *C.char |
void* | Pointer | c_void_p | unsafe.Poniter |
外部接口 | 结构体数 | 宏与用户定义类型行数 | 函数量 |
---|---|---|---|
SDF | 8 | 106 | 50 |
Tesseract | 10 | 169 | 114 |
Tab. 3 Dataset information statistics
外部接口 | 结构体数 | 宏与用户定义类型行数 | 函数量 |
---|---|---|---|
SDF | 8 | 106 | 50 |
Tesseract | 10 | 169 | 114 |
外部接口 | 开发完成度近似值 | 测试完成度近似值 | |||
---|---|---|---|---|---|
SWIG | AFIG | 人工 | SWIG | AFIG | |
Tesseract | 16.97 | 96.39 | 57.98 | 0 | 40.78 |
SDF | 27.31 | 98.14 | 68.52 | 0 | 41.95 |
Tab. 4 Code completion comparison among different development methods
外部接口 | 开发完成度近似值 | 测试完成度近似值 | |||
---|---|---|---|---|---|
SWIG | AFIG | 人工 | SWIG | AFIG | |
Tesseract | 16.97 | 96.39 | 57.98 | 0 | 40.78 |
SDF | 27.31 | 98.14 | 68.52 | 0 | 41.95 |
项目名称 | 覆盖率 | |||
---|---|---|---|---|
路径 | 语句 | 分支 | 函数 | |
Tess4J(人工编写) | 42.4 | 72.58 | 43.75 | 73.17 |
Tess4J(AFIG生成) | 35.6 | 65.23 | 42.42 | 100.00 |
Tab. 5 Test coverage statistics
项目名称 | 覆盖率 | |||
---|---|---|---|---|
路径 | 语句 | 分支 | 函数 | |
Tess4J(人工编写) | 42.4 | 72.58 | 43.75 | 73.17 |
Tess4J(AFIG生成) | 35.6 | 65.23 | 42.42 | 100.00 |
1 | WYNN D C, ECKERT C M. Perspectives on iteration in design and development [J]. Research in Engineering Design, 2017, 28(2): 153-184. |
2 | FOWLER M. Refactoring: Improving the Design of Existing Code [M]. [S.l.]: Addison-Wesley Professional, 2018: 328-332. |
3 | YALLOP J, SHEETS D, MADHAVAPEDDY A. A modular foreign function interface [J]. Science of Computer Programming, 2018, 164: 82-97. |
4 | YAN Y, GROSSMAN M, SARKAR V. JCUDA: a programmer-friendly interface for accelerating Java programs with CUDA [C]// Proceedings of the 15th International Euro-Par Conference on Parallel Processing. Berlin: Springer, 2009: 887-899. |
5 | AMATO G, SCOZZARI F. JGMP: Java bindings and wrappers for the GMP library [J]. SoftwareX, 2023, 23: 101428. |
6 | PARK J, LEE S, HONG J, et al. Static analysis of JNI programs via binary decompilation [J]. IEEE Transactions on Software Engineering, 2023, 49(5): 3089-3105. |
7 | HWANG S, LEE S, KIM J, et al. JustGen: effective test generation for unspecified JNI behaviors on JVMs [C]// Proceedings of the 2021 IEEE/ACM 43rd International Conference on Software Engineering. Piscataway: IEEE, 2021: 1708-1718. |
8 | HANSEN L T. FFIGEN Manifesto and overview [EB/OL]. (1996-02-06) [2023-08-26]. . |
9 | BEAZLEY D M. Simplified wrapper and interface generator [EB/OL]. (1996-02-26) [2023-08-26]. . |
10 | WILLIAM S F, BETTS O, NADLINGER D, et al. SWIG (Simplified Wrapper and Interface Generator) [CP/OL]. (2023-08-18) [2023-08-25]. . |
11 | ROBERTSON A. Python wrapper generator for ctypes [CP/OL]. (2022-10-19) [2023-04-19]. . |
12 | 聂鹏,耿技,秦志光.软件测试用例自动生成算法综述[J].计算机应用研究, 2012, 29(2): 401-405. |
NIE P, GENG J, QIN Z G. Survey on automatic test case generation algorithms for software testing [J]. Application Research of Computers, 2012, 29(2): 401-405. | |
13 | 顾荣,罗义力,仇伶玮,等.跨语言用户态文件系统框架读写性能优化[J].电子学报, 2023, 51(6): 1590-1606. |
GU R, LUO Y L, QIU L W, et al. Reading and writing performance optimization of cross-language FUSE framework [J]. Acta Electronica Sinica, 2023, 51(6): 1590-1606. | |
14 | DOUBROVKINE D, WALL T, GREEN A, et al. Java native library: jna [CP/OL]. (2023-03-02) [2023-04-19]. . |
15 | HELLER T. ctypeslib — useful additions to the ctypes FFI library [CP/OL]. (2021-12-17) [2023-04-19]. . |
16 | LU H, JIN C J, HELU X H, et al. AutoD: intelligent blockchain application unpacking based on JNI layer deception call [J]. IEEE Network, 2021, 35(2): 215-221. |
17 | GRICHI M, ABIDI M, JAAFAR F, et al. On the impact of inter-language dependencies in multilanguage systems empirical case study on Java Native Interface applications (JNI) [J]. IEEE Transactions on Reliability, 2021, 70(1): 428-440. |
18 | ABIDI M, RAHMAN M S, OPENJA M, et al. Are multi-language design smells fault-prone? an empirical study [J]. ACM Transactions on Software Engineering and Methodology, 2021, 30(3): No. 29. |
19 | LEE S, LEE H, RYU S. Broadening horizons of multilingual static analysis: semantic summary extraction from C code for JNI program analysis [C]// Proceedings of the 2020 35th IEEE/ACM International Conference on Automated Software Engineering. Piscataway: IEEE, 2020: 127-137. |
20 | LEE S. JNI program analysis with automatically extracted C semantic summary [C]// Proceedings of the 28th ACM SIGSOFT International Symposium on Software Testing and Analysis. New York: ACM, 2019: 448-451. |
21 | KONDOH G, ONODERA T. Finding bugs in Java native interface programs [C]// Proceedings of the 2008 International Symposium on Software Testing and Analysis. New York: ACM, 2008: 109-118. |
22 | LI S, TAN G. JET: exception checking in the Java native interface [J]. ACM SIGPLAN Notices, 2011, 46(10): 345-358. |
23 | BEAZLEY D M. Automated scientific software scripting with SWIG [J]. Future Generation Computer Systems, 2003, 19(5): 599-609. |
24 | HUANG Y, WALKER D W. JACAW: a Java-C automatic wrapper [R]. Wales, UK: Cardiff University, Department of Computer Science, 2002: 1-9. |
25 | VAIRALE V S, HONWADKAR K N. Wrapper generator using Java Native interface [J]. International Journal of Computer Science and Information Technology, 2010, 2(2): 125-139. |
26 | 单锦辉,姜瑛,孙萍.软件测试研究进展[J].北京大学学报(自然科学版), 2005, 41(1): 134-145. |
SHAN J H, JIANG Y, SUN P. Research progress in software testing [J]. Acta Scientiarum Naturalium Universitatis Pekinensis, 2005, 41(1): 134-145. | |
27 | 张海藩,吕云翔.软件工程[M].北京:人民邮电出版社, 2013: 149-175. |
ZHANG H F, LYU Y X. Software Engineering [M]. Beijing: Posts & Telecom Press, 2013: 149-175. | |
28 | LI J, ZHANG Z, YANG H. A grid oriented approach to reusing legacy code in ICENI framework [C]// Proceedings of the 2005 IEEE International Conference on Information Reuse and Integration. Piscataway: IEEE, 2005: 464-469. |
29 | BUBAK M, KURZYNIEC D, LUSZCZEK P. Creating Java to native code interfaces with Janet [J]. Scientific Programming, 2001, 9(1): 39-50. |
30 | 国家市场监督管理总局. ,信息安全技术密码设备应用接口规范 [S].北京:中国国家标准化管理委员会, 2018: 1-44. |
State Administration for Market Regulation. , Information security technology: Cryptographic device application interface specifications [S]. Beijing: Standardization Administration of the People's Republic of China, 2018: 1-44. | |
31 | 宣兆新,马旭.商用密码模块接口统一调用技术研究[J].信息安全与通信保密, 2021(10): 75-81. |
XUAN Z X, MA X. Study on interface unification of commercial cryptographic modules [J]. Information Security and Communications Privacy, 2021(10): 75-81. | |
32 | HOFFMANN M R, JANICZAK B, MANDRIKOV E. JaCoCo Java code coverage library [CP/OL]. (2023-04-18) [2023-04-19]. . |
[1] | Jian SUN, Baoquan MA, Zhuiwei WU, Xiaohuan YANG, Tao WU, Pan CHEN. Joint optimization of UAV swarm path planning and task allocation balance in earthquake scenarios [J]. Journal of Computer Applications, 2024, 44(10): 3232-3239. |
[2] | LANG Dapeng, DING Wei, JIANG Haocheng, CHEN Zhiyuang. Malicious code classification algorithm based on multi-feature fusion [J]. Journal of Computer Applications, 2019, 39(8): 2333-2338. |
[3] | BU Tongtong, CAO Tianjie. Risk assessment method of Android application based on permission [J]. Journal of Computer Applications, 2019, 39(1): 131-135. |
[4] | ZHOU Min, ZHOU Anmin, LIU Liang, JIA Peng, TAN Cuijiang. Mining denial of service vulnerability in Android applications automatically [J]. Journal of Computer Applications, 2017, 37(11): 3288-3293. |
[5] | JIANG Jianchun, CHEN Huiling, DENG Lu, ZHAO Jianpeng. Configuration tool design based on control-oriented multi-core real-time operating system [J]. Journal of Computer Applications, 2016, 36(3): 765-769. |
[6] | TANG Yang, ZENG Fanping, WANG Jiankang, HUANG Xinyi. Android GUI traversal method based on static analysis [J]. Journal of Computer Applications, 2016, 36(10): 2811-2815. |
[7] | HU Zhengyu, SHEN Beijun. End-user programming language for mobile children educational game [J]. Journal of Computer Applications, 2015, 35(2): 540-544. |
[8] | HU Chi, YANG Geng, YANG Beisi, MIN Zhao'e. Parallel algorithm for homomoriphic encryption base on MapReduce [J]. Journal of Computer Applications, 2015, 35(12): 3408-3412. |
[9] | DU Shuangzhi WANG Yong TAO Xiaoling. Dual priority dynamic scheduling algorithm based on multi-FPGA [J]. Journal of Computer Applications, 2013, 33(03): 862-865. |
[10] | ZHANG Xue-feng XU Sheng-chao. RB-CRSP: Node role-based computing resources sharing platform over Internet [J]. Journal of Computer Applications, 2011, 31(03): 834-838. |
[11] | . Performance analysis and optimization of network server based on queuing network [J]. Journal of Computer Applications, 2010, 30(12): 3148-3150. |
[12] | Kui CAI Lei LU Shuai-qiang WANG Jian-cheng WAN. Complicated behaviors modeling and code generation based on Web UI design pattern [J]. Journal of Computer Applications, 2009, 29(4): 1139-1142. |
[13] | LI KENLI . Coherence parallel algorithm of seismic data processing based on CUDA [J]. Journal of Computer Applications, 2009, 29(3): 912-914. |
[14] | You-wen HUANG. Optimized pipelining scheme for AVS decoder [J]. Journal of Computer Applications, 2009, 29(11): 3135-3138. |
[15] | Hui Yu. PCP: P2P-based computing resource sharing and aggregation platform [J]. Journal of Computer Applications, 2009, 29(10): 2647-2651. |
Viewed | ||||||
Full text |
|
|||||
Abstract |
|
|||||