当前位置:网站首页>06 local method interface
06 local method interface
2022-06-25 18:22:00 【Name is too tangled】

What is a local approach ?
- Simply speak ,
One Native Method It's a Java Call not Java Interface of code. One Native Method It's such a Java Method : The implementation of this method consists of Java Language implementation , such as C. This feature is not Java Unique to , Many other programming languages have this mechanism , For example C++ in , You can use it. extern "C" inform C++ The compiler calls a C Function of . - “A native method is a Java method whose implementation is provided by non-java code.”( The local method is a Java Methods , Its concrete realization is right and wrong Java Code implementation )
- Defining a native method when , Does not provide an implementer ( It's like defining a Java interface), Because its realization is caused by non java Language is realized on the outside .
- The function of the local interface is to integrate different programming languages into Java used , Its original intention is to integrate C/C++ Program .
give an example
identifier native Can be compared with other java Identifiers are used together , however abstract With the exception of
public class IHaveNatives {
public native void Native1(int x);
public native static long Native2();
private native synchronized float Native3(Object o);
native void Native4(int[] ary) throws Exception;
}
Why use Native Method?
Java It is very convenient to use , However, some levels of tasks use Java It's not easy to implement , Or when we care about the efficiency of the program , Here's the problem .
- And Java Environmental diplomacy is mutual :
Sometimes Java Applications need to be associated with Java The outside environment interacts , This is the main reason for the existence of local methods .- You can think about Java Need to work with some underlying systems , In some cases, such as the exchange of hardware or operating system information .
- The local approach is just such a communication mechanism : It provides us with a very simple interface , And we don't have to understand Java Trivial details beyond the application .
- Interaction with the operating system :
- JVM Supporting Java The language itself and the runtime library , It is Java The platform on which programs live , It has an interpreter ( Interpret bytecode ) And some libraries linked to local code .
- But anyway , It's not a complete system after all , It often relies on the support of an underlying system . These underlying systems are often powerful operating systems .
By using local methods , We can use Java Realized jre Interaction with the underlying system , even to the extent that JVM Part of it is to use C Written .- also , If we're going to use some Java When the language itself does not provide encapsulated features of the operating system , We also need to use local methods .
- Sun’s Java
Sun The interpreter of C Realized , This makes it look like something ordinary C Interact with the outside as well .jre Mostly with Java Realized , It also interacts with the outside world through some local methods .- for example : class java.lang.Thread Of setPriority( ) The method is to use Java Realized , But it calls the local methods in the class setPriority0( ). This method is local C Realized , And implanted JVM Inside Windows 95 On the platform , This local method will eventually call Win32 setpriority( ) API.
- This is a concrete implementation of a local method by JVM Provide directly , More often than not, local methods are made up of external DLL (external dynamic link library) Provide , Then be JVM call .
present situation
At present, this method is used less and less , Except for hardware related applications , Such as through Java Program driven printer or Java System management production equipment , It is rare in enterprise applications . Because now the communication between heterogeneous fields is very developed , You can use Socket signal communication , You can also use Web Service wait , No more introductions .
边栏推荐
- 将Graph Explorer搬上JupyterLab:使用GES4Jupyter连接GES并进行图探索
- [in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc
- Android物联网应用程序开发(智慧园区)—— 图片预览界面
- Qi v1.2.4协议 之 定频调压方案
- Wechat applet reports an error: request:fail URL not in domain list
- Dell R530内置热备盘状态变化说明
- [deeply understand tcapulusdb technology] cluster management operation
- C# asp,net core框架传值方式和session使用
- Slam visuel Leçon 14 leçon 9 filtre Kalman
- Interrupt operation: abortcontroller learning notes
猜你喜欢

Centos7 installing redis 7.0.2

【深入理解TcaplusDB技术】TcaplusDB运维

【深入理解TcaplusDB技术】TcaplusDB机型

. Net worker service adding a serial log record
![[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc

Boiled peanuts

揭秘GES超大规模图计算引擎HyG:图切分
![[in depth understanding of tcapulusdb technology] new models of tcapulusdb](/img/10/f94a5e1ebeaa803c754dd77351950f.png)
[in depth understanding of tcapulusdb technology] new models of tcapulusdb

Chapter 4:win10 installing mingw64

解析数仓lazyagg查询重写优化
随机推荐
RMAN backup database_ Use RMAN for split mirror backup
[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance
[in depth understanding of tcapulusdb technology] tcapulusdb construction data
RMAN backup database_ Manage backup window
IVX sailing
[in depth understanding of tcapulusdb technology] tcapulusdb business data backup
Meaning of% in C language
[deeply understand tcapulusdb technology] cluster management operation
哈希竞猜游戏系统开发如何开发?哈希竞猜游戏系统开发应用详情案例及源码
【深入理解TcaplusDB技术】 Tmonitor模块架构
Deep learning network model
Skills to master in advanced development
SQL Server实时备份库要求
【深入理解TcaplusDB技术】TcaplusDB机型
How to open a stock account is it safe to open an account
jvm问题复盘
JVM understanding
Move graph explorer to jupyterab: use ges4jupyter to connect ges and explore graphs
1、对范数的理解
Anaconda download Tsinghua source