《深入理解Java虚拟机》第一章 OpenJDK12环境搭建-MacOS26版
《深入理解 Java 虚拟机》第一章 OpenJDK 12 环境搭建 - MacOS 26 版一、环境准备OpenJDK 12 源码下载安装 JDK 11编译时作为 Boot JDK安装 Xcode 和 Command Line Tools安装 Homebrew安装依赖库二、开始编译 JDK三、逐项修复问题 1SDK does not contain libarclite at the path问题 2redeclaration of C built-in type bool问题 3too many arguments to function call,问题 4too many arguments to function call问题 5gif_lib.h - redeclaration of C built-in type bool问题 6fp.h file not found一、环境准备编译环境JDK 12 源码 macOS 26Darwin 26.5.2 新版 Xcode 26.4/clangOpenJDK 12 源码下载浏览器打开地址https://hg.openjdk.org/jdk/jdk12/ macOS 下载 gz 格式安装 JDK 11编译时作为 Boot JDK官网地址https://www.oracle.com/java/technologies/downloads/#java11安装 Xcode 和 Command Line ToolsmacOS 26 无法安装低版本 Xcode。官网地址https://developer.apple.com/download/all/?qxcode安装验证192 JDK12% xcode-select--installxcode-select: note: Command line tools are already installed. UseSoftware UpdateinSystem Settings or the softwareupdatecommandline interface toinstallupdates提示已安装证明安装成功。在终端中执行gcc -v命令查看是否安装成功192 JDK12% gcc-vApple clang version21.0.0(clang-2100.0.123.102)Target: x86_64-apple-darwin25.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin安装 Homebrew官网https://brew.sh//bin/bash-c$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)终端运行如下命令可查看安装的版本信息~192 JDK12% brew-vHomebrew6.0.13安装依赖库打开终端执行如下命令brewinstallccache brewinstallfreetype brewinstallautoconf至此编译环境就准备好了。二、开始编译 JDK首先终端先切到下载的 JDK 目录中下面的命令可以查看编译参数bashconfigure--help好了开始编译编译命令注意 JDK 要换成自己的地址bashconfigure\--enable-debug\--with-jvm-variantsserver\--with-sysroot/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk\--with-boot-jdk/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home\--disable-warnings-as-errors\--with-extra-cflags-Wno-incompatible-function-pointer-types -Wno-cast-function-type-mismatch -F/Library/Frameworks\--with-extra-cxxflags-stdgnu11 -F/Library/Frameworks输出下面的内容证明这一步没问题。电脑配置显示的不完全一样Tools summary: * Boot JDK:javaversion11.0.322026-07-21 LTS Java(TM)SE Runtime Environment18.9(build11.0.327-LTS-196)Java HotSpot(TM)64-Bit Server VM18.9(build11.0.327-LTS-196, mixed mode)(at /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home)* Toolchain: clang(clang/LLVM from Xcode26.4)* C Compiler: Version21.0.0(at /usr/bin/clang-stdgnu23)* C Compiler: Version21.0.0(at /usr/bin/clang)Build performance summary: * Cores to use:16* Memory limit:65536MB然后执行编译命令makeimages编译报错可以参考一下第三章。编译遇到问题排查思路根据提示看构建目录底下的报错去修复问题。build/macosx-x86_64-server-fastdebug/make-support/failure-logs然后每次重新编译要注意清理上一次编译的脏数据依次执行makeclean然后执行makedist-clean看到下面的命令就证明编译成功了Finished building targetimagesinconfigurationmacosx-x86_64-server-fastdebug三、逐项修复核心矛盾JDK 12 代码基于 C99 时代写法新版 clang 默认启用 C23 标准bool 变为内置关键字、() 无原型声明被移除导致一系列编译错误。问题 1SDK does not contain ‘libarclite’ at the pathGitHub 上下载对应的依赖https://github.com/chenZai90/ios-Rescorce 把 arc 文件放到你提示的目录底下即可问题 2redeclaration of C built-in type ‘bool’Infileincluded from.../src/jdk.hotspot.agent/macosx/native/libsaproc/MacosxDebuggerLocal.m:45: Infileincluded from.../src/jdk.hotspot.agent/macosx/native/libsaproc/libproc_impl.h:30:.../src/jdk.hotspot.agent/macosx/native/libsaproc/libproc.h:47:13: error: redeclaration of C built-intypebool47|typedef int bool;|^1error generated.文件src/jdk.hotspot.agent/macosx/native/libsaproc/libproc.h原因C23 下 bool 是内置类型非宏#ifndef bool/#ifdef bool均无法拦截Objective-C 模式下 bool 同样是内置关键字。修复删除 macOS 分支的 bool 定义添加stdbool.h当前文件最终状态#ifdef__APPLE__#includestdbool.htypedefenumps_err_e{PS_OK,PS_ERR,PS_BADPID,PS_BADLID,PS_BADADDR,PS_NOSYM,PS_NOFREGS}ps_err_e;#ifndefpsaddr_t#definepsaddr_tuintptr_t#endif/* 删除以下整个块 #ifndef __cplusplus #ifndef bool typedef int bool; #define true 1 #define false 0 #endif // bool #endif // __cplusplus */#ifndeflwpid_t#definelwpid_tuintptr_t#endif#includemach/thread_status.h问题 3too many arguments to function call,.../awt_ImagingLib.c:430:44: error: too many arguments tofunctioncall, expected0, have6430|if((*sMlibFns[MLIB_CONVKERNCVT].fptr)(kdata,scale,dkern,w,h,|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~431|mlib_ImageGetType(src))!MLIB_SUCCESS){|~~~~~~~~~~~~~~~~~~~~~~.../awt_ImagingLib.c:458:45: error: too many arguments tofunctioncall, expected0, have10458|status(*sMlibFns[MLIB_CONVMxN].fptr)(dst, src, kdata, w, h,|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~...8errors generated.原因mlibFnS_t.fptr 声明为旧式 mlib_status (*fptr)()C23 将其视为严格零参数原型 (void)。修复改为变参函数指针 (…)C17/C23/C 均合法共 3 个文件① src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.h 第 35 行// 修改前mlib_status(*fptr)();// 修改后mlib_status(*fptr)(...);② src/java.desktop/unix/native/libawt/awt/awt_Mlib.c// 第 53 行// 修改前mlib_status(*fPtr)();// 修改后mlib_status(*fPtr)(...);// 第 126 行// 修改前fPtr(mlib_status(*)())dlsym(handle,mptr[i].fname);// 修改后fPtr(mlib_status(*)(...))dlsym(handle,mptr[i].fname);③ src/java.desktop/windows/native/libawt/windows/awt_Mlib.cpp// 第 84 行// 修改前mlib_status(*fPtr)();// 修改后mlib_status(*fPtr)(...);// 第 88-89 行// 修改前fPtr(mlib_status(*)())::GetProcAddress(hDLL,pMlibFns[i].fname);// 修改后fPtr(mlib_status(*)(...))::GetProcAddress(hDLL,pMlibFns[i].fname);原则类型声明 / 强转中的 () → (…)调用处如 (*sMlibFns[…].fptr)(参数)不用动。问题 4too many arguments to function call.../CPrinterJob.m:69:21: error: conflicting typesforcreateDefaultNSPrintInfo69|static NSPrintInfo* createDefaultNSPrintInfo(JNIEnv* env, jstring printer)|^.../CPrinterJob.m:47:21: note: previous declaration is here47|static NSPrintInfo* createDefaultNSPrintInfo();|^.../CPrinterJob.m:453:55: error: too many arguments tofunctioncall, expected0, have2453|NSPrintInfo* printInfocreateDefaultNSPrintInfo(env, NULL);|~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~.../CPrinterJob.m:47:21: note:createDefaultNSPrintInfodeclared here47|static NSPrintInfo* createDefaultNSPrintInfo();|^...(rest of output omitted)文件src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m原因第 47 行前向声明 static NSPrintInfo* createDefaultNSPrintInfo(); 与第 69 行带参定义冲突C23 下 () (void)。修复第 47 行补全参数与定义一致// 修改前staticNSPrintInfo*createDefaultNSPrintInfo();// 修改后staticNSPrintInfo*createDefaultNSPrintInfo(JNIEnv*env,jstring printer);问题 5gif_lib.h - redeclaration of C built-in type ‘bool’* For target support_native_java.desktop_libsplashscreen_dgif_lib.o: Infileincluded from.../giflib/dgif_lib.c:48:.../giflib/gif_lib.h:50:13: error: redeclaration of C built-intypebool50|typedef int bool;|^1error generated. * For target support_native_java.desktop_libsplashscreen_gif_err.o: Infileincluded from.../giflib/gif_err.c:33:.../giflib/gif_lib.h:50:13: error: redeclaration of C built-intypebool文件src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h原因giflib 主动 #undef bool 后 typedef int bool;C23 下 bool 是内置关键字。修复加条件保护——仅非 C 且 C 标准低于 C23 时定义保留旧环境行为#includestddef.h#if!defined(__cplusplus)(!defined(__STDC_VERSION__)||__STDC_VERSION__202311L)#ifdefbool#undefbool#endiftypedefintbool;#definefalse0#definetrue1#endif问题 6fp.h’ file not found* For target support_native_java.desktop_libsplashscreen_pngerror.o: Infileincluded from.../libpng/pngerror.c:47:.../libpng/pngpriv.h:551:16: fatal error:fp.hfilenot found551|# include fp.h|^~~~~~1error generated. * For target support_native_java.desktop_libsplashscreen_pngget.o: Infileincluded from.../libpng/pngget.c:43:.../libpng/pngpriv.h:551:16: fatal error:fp.hfilenot found551|# include fp.h|^~~~~~1error generated. * For target support_native_java.desktop_libsplashscreen_pngmem.o: Infileincluded from.../libpng/pngmem.c:48:.../libpng/pngpriv.h:551:16: fatal error:fp.hfilenot found551|# include fp.h文件src/java.desktop/share/native/libsplashscreen/libpng/pngpriv.h第 544-555 行原因libpng 用 defined(TARGET_OS_MAC) 判断老式 Mac 环境但该宏在现代 macOS SDK 中恒为 1误入包含 Solaris/老 Mac 专属 fp.h 的分支。修复加APPLE分流现代苹果系统直接走 math.h#ifdefined(__APPLE__)#includemath.h#elif(defined(__MWERKS__)defined(macintosh))||defined(applec)||\defined(THINK_C)||defined(__SC__)||defined(TARGET_OS_MAC)/* We need to check that math.h hasnt already been included earlier * as it seems it doesnt agree with fp.h, yet we should really use * fp.h if possible. */#if!defined(__MATH_H__)!defined(__MATH_H)!defined(__cmath__)#includefp.h#endif#else#includemath.h#endif

相关新闻

逆向工程中编码与加密算法的识别、分析与实战应用

逆向工程中编码与加密算法的识别、分析与实战应用

1. 从“菜鸡”到入门:为什么逆向工程绕不开编码与加密 刚接触逆向工程的朋友,常常会卡在一个看似基础,实则至关重要的环节:面对程序里一堆“乱码”或者经过变换的数据,完全无从下手。你兴致勃勃地打开调试器&#xff0…

2026/11/5 15:26:00 阅读更多 →
PCB板材选型全解析:从FR-4到高频材料,工程师必备实战指南

PCB板材选型全解析:从FR-4到高频材料,工程师必备实战指南

1. 从一块“板子”说起:PCB板材为何是设计的基石当你拿到一块电路板,第一眼看到的可能是上面密密麻麻的线路和元器件。但支撑这一切、决定其性能上限和可靠性的,却是那块看似平平无奇的基板——PCB板材。我接触过太多项目,从消费电…

2026/11/3 10:03:36 阅读更多 →
如何彻底解决多语言字体显示问题:Noto字体完整使用指南

如何彻底解决多语言字体显示问题:Noto字体完整使用指南

如何彻底解决多语言字体显示问题:Noto字体完整使用指南 【免费下载链接】noto-fonts Noto fonts, except for CJK and emoji 项目地址: https://gitcode.com/gh_mirrors/no/noto-fonts 您是否曾在网页或应用中看到一堆小方块代替了文字?这就是令…

2026/11/5 10:17:12 阅读更多 →

最新新闻

Electron桌面应用开发实战:从环境搭建到打包发布全流程

Electron桌面应用开发实战:从环境搭建到打包发布全流程

做前端这些年,我大部分时间都在跟浏览器标签页打交道,直到第一次把桌面应用跑起来,才发现原来自己一直被限制在地址栏和刷新按钮围起来的框框里。Electron这个词,最开始是在某段时间频繁出现在同事的讨论里,一个用HTML…

2026/11/5 12:28:00 阅读更多 →
滑盖智能锁T109深度解析:结构原理、安装调试与故障排查

滑盖智能锁T109深度解析:结构原理、安装调试与故障排查

简介:亚太天能T109滑盖智能锁产品说明书是一份PDF格式的官方技术文档,主要面向智能锁安装人员、终端用户及售后维护者,帮助快速掌握产品安装、配置与常见故障处理。全包仅1个PDF文件,大小4.37MB,内容结构清晰&#xff…

2026/11/5 1:08:50 阅读更多 →
PMSM弱磁控制原理与Simulink建模:高速AGV驱动系统设计指南

PMSM弱磁控制原理与Simulink建模:高速AGV驱动系统设计指南

上个月我在调试一台高速AGV的驱动系统,整车要求空载跑到8m/s,电机转速已经拉到额定点,驱动器的输出电压也顶到了母线电压极限附近。再往上踩速度指令,转速纹丝不动,三相电流反而开始震荡。那会儿我的第一反应就是&…

2026/11/5 12:28:01 阅读更多 →
C++核心知识点:从内存管理到STL的实战指南

C++核心知识点:从内存管理到STL的实战指南

C 这门语言我前前后后折腾了十几年,用它写过嵌入式驱动、做过游戏服务端,也搭过基础组件库。每次看到新人一头扎进"C 核心知识点"这个搜索词,我其实挺感慨的——这门语言的难点从来不是语法多,而是知识点之间的耦合太深…

2026/11/5 12:28:02 阅读更多 →
T109滑盖智能锁怎么装?安装调试与故障排查全攻略

T109滑盖智能锁怎么装?安装调试与故障排查全攻略

简介:亚太天能T109滑盖智能锁产品说明书以PDF格式发布,适合智能锁用户、安装人员与售后维修人员阅读。内容围绕T109系列指纹密码刷卡锁展开,先介绍前面板、后面板、锁体、机械钥匙、电池盒盖等部件名称与功能,再给出完整安装步骤&…

2026/11/5 0:54:28 阅读更多 →
LLM知识降熵:从信息垄断到理解权下放

LLM知识降熵:从信息垄断到理解权下放

你有没有过这种经历:翻开源码注释、论文摘要或者一份专业报告,每个字都认识,连在一起却像天书。想找人聊聊,身边要么没人懂,要么懂的懒得跟你解释。后来我试着把同一段内容丢给一个大语言模型,几秒钟之后&a…

2026/11/5 19:38:59 阅读更多 →

日新闻

周新闻

月新闻