arthas 源码构建

arthas 源码构建

git下载代码

git clone https://github.com/alibaba/arthas.git

若github被墙,可以在gitee搜索下载

maven clean

可以在项目目录执行 mvn clean , ide可以执行界面执行

在这里插入图片描述

maven package

可以在项目目录执行mvn package

在这里插入图片描述

问题记录

javah 命令不存在

pom文件位于/arthas/arthas-vmtool/pom.xml,属于arthas-vmtool模块,这个模块中有c代码,编译后需要java native使用,所以需要使用javah 命令,但是在高版本的jdk中已经使用javac -h进行代替,所以在java环境的bin目录中已经不存在javah 命令(初始版本使用jdk11编译会报错)。

[ERROR] Failed to execute goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-11:javah (javah) on project arthas-vmtool: Error running javah command: Error executing command line: Error while executing process. Cannot run program "javah" (in directory "/home/dark/IdeaProjects/arthas/arthas-vmtool"): error=2, 没有那个文件或目录 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

为了解决没有javah 命令,我切换为jdk8,并检查bin目录下的确存在javah,则问题得以解决。但是其他模块却需要更高版本的java,所以查阅文档后,发现native-maven-plugin可以配置参数javahPath指定javah命令的位置,所以我在使用jdk11时,指定了jdk8的javah命令,在pom.xml中如下改造:

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>native-maven-plugin</artifactId>
                <version>1.0-alpha-11</version>
                <extensions>true</extensions>
                <configuration>
                    <!--<javahPath>${java.home}/../bin/javah</javahPath>-->
                    <!-- 指定你的javah 命令的位置 -->
                    <javahPath>/home/dark/.jdks/jdk1.8.0_202/bin/javah</javahPath>
                    <javahIncludes>
                        <javahInclude>
                            <className>arthas.VmTool</className>
                        </javahInclude>
                    </javahIncludes>
                    <jdkIncludePath>${project.basedir}/src/main/native/head</jdkIncludePath>
                    <javahOS>${os_name}</javahOS>
                    <sources>
                        <source>
                            <directory>src/main/native/src</directory>
                            <fileNames>
                                <fileName>jni-library.cpp</fileName>
                            </fileNames>
                 javahPath       </source>
                    </sources>

                    <compilerProvider>generic-classic</compilerProvider>
                    <compilerExecutable>g++</compilerExecutable>
                    <compilerStartOptions>
                        <compilerStartOption>${os_arch_option}</compilerStartOption>
                        <compilerStartOption>-fpic</compilerStartOption>
                        <compilerStartOption>-shared</compilerStartOption>
                        <compilerStartOption>-o</compilerStartOption>
                    </compilerStartOptions>

                    <linkerOutputDirectory>target</linkerOutputDirectory>
                    <linkerExecutable>g++</linkerExecutable>
                    <linkerStartOptions>
                        <linkerStartOption>${os_arch_option}</linkerStartOption>
                        <linkerStartOption>-fpic</linkerStartOption>
                        <linkerStartOption>-shared</linkerStartOption>
                        <!-- <linkerStartOption>-o</linkerStartOption> -->
                    </linkerStartOptions>
                    <linkerEndOptions>
                        <linkerEndOption>-o ${project.build.directory}/${lib_name}</linkerEndOption>
                    </linkerEndOptions>
                </configuration>
                <executions>
                    <execution>
                        <id>javah</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>javah</goal>
                            <goal>initialize</goal>
                            <goal>compile</goal>
                            <goal>link</goal>
                        </goals>
                    </execution>arthas源码构建
                </executions>
            </plugin>

jfr包找不到

jfr是jdk下的包,但是低版本(jdk 8)中许多类不存在,导致许多类不存在报错,在构建arthas-core模块会失败。

在这里插入图片描述

所以要设置jdk环境为jdk 11,如下图:

在这里插入图片描述

PS

若有一个直接可用的jdk版本麻烦通知一下,折腾起来也挺麻烦。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值