Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
参考 issue #2164 中的说明,首先需要升级 one.profiler。
首先分析此包本身的差异,实质性的改动有:修改了
getInstance
方法,添加了extractEmbeddedLib
和getPlatformTag
方法,其中getPlatformTag
仅被extractEmbeddedLib
调用,extractEmbeddedLib
仅被getInstance
调用。getInstance
此方法在 one.profiler 内部仅被同名无参重载方法调用。
在 ProfilerCommand 类中,此方法仅被
profilerInstance
调用(L249/271),且同名无参重载方法未被调用。此方法内部,实际上仅改动了
libPath == null
情况的对应逻辑。L51 表示如果 jvm 进程启动时已经加载 lib,就直接返回。否则,L53~59 尝试从类路径中获取对应平台的 lib.so,复制到一个临时文件用于加载,加载后 L58 删除临时文件。如果类路径中未事先按规则准备这些 lib 文件,那么extractEmbeddedLib
方法将返回 null,此时将与旧代码行为一致,直接从操作系统库搜索路径中查找加载 lib(若未找到则抛出错误,不会返回 profiler 实例)。总而言之,这是对已有行为的扩展而不是修改。profilerInstance
在 ProfilerCommand.profilerInstance 方法中,在 L271 处的调用不可能传入 null 参数,因此前述改动对此无任何影响。在 L249 处的调用只有
profiler load
命令不加额外参数时才会向getInstance
传入 null,而前述改动不会引入破坏性。