java - "AWT widgets written in Java which delegated to peer classes that were written in C"是什么意思?

标签 java c swing java-native-interface native

我不明白

的意思

The original Java AWT was implemented by having widgets written in Java which delegated to peer classes that were written in C

“用 C 编写的对等类” 部分:

这意味着 Java 类包含 native 代码?

最佳答案

Hotspot Java 有相当一部分运行时系统是用 C/C++ 编写的。有一次,这包括 AWT 对等类。 (而且它仍然可以......)

native 代码不在 Java 中。相反,Java 通常具有 native 方法声明,这些方法声明通常在加载相应的 native 库时绑定(bind)到 native 实现。

(但不要将此视为绿灯,在您的代码中做同样的事情。与 native 代码交互是棘手的,如果您弄错了,您可能会触发严重的 JVM 崩溃......痛……)

关于java - "AWT widgets written in Java which delegated to peer classes that were written in C"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13171908/

相关文章:

Java:日期操作

java - 添加滚动条和图像大小调整问题

java - 在 PaintComponent 之外使用 Graphics

java - 复合 Material 的关键听众?

java - 无法使用 java 11 在 Spring Boot 中加载日志记录资源文件

c++ - STL 与 struct 的速度问题

.net - System.IO.Compression.DeflateStream 的数据格式

c - GCC 链接函数时没有错误

java - 从按下的 JMenuItem 获取文本?

java - 如何正确实现 ListIterator 的中间模型?