From 42ea174ed9fbacf8e82f415dcf8fe7004729a8f6 Mon Sep 17 00:00:00 2001 From: "Jeffrey H. Lei" <295482300@qq.com> Date: Tue, 16 Aug 2022 17:40:47 +0800 Subject: [PATCH] Force the injected high-priority classes in order to avoid NoClassDefFoundError. (#292) Co-authored-by: leihuazhe --- CHANGES.md | 1 + .../agent/core/plugin/bootstrap/BootstrapInstrumentBoost.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3a3a60388..b8c8d86bd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ Release Notes. * Upgrade gson to 2.8.9. * Upgrade netty-codec-http2 to 4.1.79.Final. * Fix race condition causing agent to not reconnect after network error +* Force the injected high-priority classes in order to avoid NoClassDefFoundError. #### Documentation diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/bootstrap/BootstrapInstrumentBoost.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/bootstrap/BootstrapInstrumentBoost.java index caf5a10b2..523340a40 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/bootstrap/BootstrapInstrumentBoost.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/bootstrap/BootstrapInstrumentBoost.java @@ -22,7 +22,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.lang.instrument.Instrumentation; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -86,7 +86,7 @@ public class BootstrapInstrumentBoost { public static AgentBuilder inject(PluginFinder pluginFinder, Instrumentation instrumentation, AgentBuilder agentBuilder, JDK9ModuleExporter.EdgeClasses edgeClasses) throws PluginException { - Map classesTypeMap = new HashMap<>(); + Map classesTypeMap = new LinkedHashMap<>(); if (!prepareJREInstrumentation(pluginFinder, classesTypeMap)) { return agentBuilder;