diff --git a/class-match/src/main/java/datadog/instrument/classmatch/ClassFile.java b/class-match/src/main/java/datadog/instrument/classmatch/ClassFile.java index e1e3a33..1a9904a 100644 --- a/class-match/src/main/java/datadog/instrument/classmatch/ClassFile.java +++ b/class-match/src/main/java/datadog/instrument/classmatch/ClassFile.java @@ -6,6 +6,7 @@ package datadog.instrument.classmatch; +import static java.nio.charset.StandardCharsets.ISO_8859_1; import static java.nio.charset.StandardCharsets.US_ASCII; import java.util.Arrays; @@ -353,8 +354,10 @@ private static String utf(byte[] bytecode, int utfOffset) { } if (chars == null) { - // fast-path for ASCII-only, avoids intermediate char array - return new String(bytecode, utfStart, utfLen, US_ASCII); + // fast-path for ASCII-only: use ISO_8859_1 because on Java 9+ the JVM + // can adopt the byte array directly as the compact string encoding, + // avoiding a byte-by-byte transcoding step that US_ASCII requires + return new String(bytecode, utfStart, utfLen, ISO_8859_1); } int charLen = 0;