Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8359593

JFR: Instrumentation of java.lang.String corrupts recording

XMLWordPrintable

    • jfr
    • b03

        When Java events, such as ActiveRecording, write the name of the recording, it fails if java.lang.String has been used as filter. Reason is that EventWriter uses java.lang.String::charAt() while writing the event.

        private void putStringValue(String s) {
                int length = s.length();
                if (isValidForSize(1 + 5 + 3 * length)) {
                    putUncheckedByte(StringParser.Encoding.CHAR_ARRAY.byteValue()); // 1 byte
                    putUncheckedInt(length); // max 5 bytes
                    for (int i = 0; i < length; i++) {
                        putUncheckedChar(s.charAt(i)); // max 3 bytes
                    }
                }
            }

        java.lang.String::length() is also a problem and any indirect call, such as java.lang.String::coder(), java.lang.StringLatin1::charAt(..), and java.lang.StringUTF16::charAt()

              egahlin Erik Gahlin
              egahlin Erik Gahlin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: