Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

JNI-based calling method for JAVA function in C++

A function call and function technology, applied in the field of cross-language function call, can solve the problems of increased workload and code maintenance, increased error probability, etc., and achieve the effect of saving labor costs

Active Publication Date: 2018-03-23
SNAIL GAMES
View PDF4 Cites 4 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

As the number of functions increases, the workload and code maintenance will increase significantly, and the probability of errors will also increase greatly

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0017] The objects, advantages and features of the present invention will be explained by the following non-limiting description of preferred embodiments. These embodiments are only typical examples of applying the technical solutions of the present invention, and all technical solutions formed by adopting equivalent replacements or equivalent transformations fall within the protection scope of the present invention.

[0018] The JAVA function calling method in the JNI-based C++ of the present invention is described in detail below,

[0019] First, in step ①. Realize the compile-time string value literal object through the C++ variable parameter template feature. In this step, a C++ template is used to realize template recursion and specialization, and a string literal value object storing a JNI data type signature is generated.

[0020] In step ②. Specialize the mapping relationship and conversion function from C++ data types to JNI data through C++ template metaprogramming....

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a C++ and JAVA function mutual calling method. The method comprises the steps that a C++ variable parameter template and template specialization are used to obtain a string value literal object of a JNI data type signature in a compiling period, the data type signature supported by a JNI is preset, and the JNI is established; after a JAVA function is called, the C++ variable parameter template and template specialization are used to realize direct data type conversion between C++ and the JNI and generate a function signature; and a function execution result is convertedfrom a JNI data type to a C++ data type, and finally the result is returned. By the adoption of the method, C++ and JAVA seamless calling is realized, a calling process of the JNI is hidden, a developer can complete C++ and JAVA interaction without the need for learning JNI development or writing a long JNI function calling signature, therefore, the workload is greatly reduced, maintainability and stability of programs are improved, and labor cost is saved.

Description

technical field [0001] The invention relates to a method for calling a cross-language function, in particular to a method for calling a JAVA function in C++ based on JNI (Java Native Interface). Background technique [0002] In cross-platform development, in order to achieve a high degree of code reuse, C++ is often used to develop core functions, and then the native language of each platform is used to realize the interaction between core functions and platforms, such as android game development, the core game logic uses C++ Development, the platform part is developed using Java. Because the game runs on the platform, the game logic and the platform will definitely interact. At present, the mainstream interaction method between C++ and JAVA is to use JNI to call JAVA functions, but to actually implement calls, developers must be clear about C++ data Types, JNI data types, JAVA data types and also need to understand how these types correspond and convert, and also need to c...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F8/40
CPCG06F8/40
Inventor 李波
Owner SNAIL GAMES
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products