Class AgentSharedInstanceHooks

java.lang.Object
se.deversity.asynctest.AgentSharedInstanceHooks

public final class AgentSharedInstanceHooks extends Object
Hooks for JDK types that are not thread safe and carry no way to say so.

Why these three

SimpleDateFormat, Matcher and MessageDigest share a shape: each keeps mutable parsing or digest state inside the instance, each is documented as unsafe for concurrent use, and each is routinely cached in a static field because constructing one is expensive. That combination is one of the oldest concurrency bugs in Java, and until now this library could only see it if the test author called a record method by hand, which means seeing it only when they already suspected it.

The mechanism is the one AgentCollectionHooks documents: substituting the invocation with a static hook whose first parameter is the receiver hands the instance over without spilling arguments, so the operand stack shape is unchanged and no member is added.

Why the shared-instance family and not every stateful JDK type

Each entry costs a rewritten instruction in every woven method that calls it, so the table is not a place to be generous. These three earn it by being both common and unambiguous: unlike Random, none of them has a thread-safe subclass that a call site could be holding, so a substituted call cannot be recording an instance that was safe all along. ThreadLocalRandom is exactly that hazard, which is why Random is absent here.

Sharing is decided by the detector, not by this class. A hook fires on every call, and the detector reports only when it has seen more than one thread touch the same instance, so a confined formatter used a thousand times costs a map lookup and produces nothing.

Since:
1.10.0
  • Method Details

    • format

      public static String format(SimpleDateFormat receiver, Date date)
      Weaves SimpleDateFormat.format(Date).
      Parameters:
      receiver - the formatter
      date - the date to format
      Returns:
      the formatted text
    • parse

      public static Date parse(SimpleDateFormat receiver, String source) throws ParseException
      Weaves SimpleDateFormat.parse(String).
      Parameters:
      receiver - the formatter
      source - the text to parse
      Returns:
      the parsed date
      Throws:
      ParseException - if the text cannot be parsed
    • parse

      public static Date parse(SimpleDateFormat receiver, String source, ParsePosition position)
      Weaves SimpleDateFormat.parse(String, ParsePosition).

      The incremental parse, used when walking a string containing several dates. It advances the position object and drives the same internal calendar the other overload does, and it was not woven (#434).

      Parameters:
      receiver - the formatter
      source - the text to parse
      position - where to start, updated to where parsing stopped
      Returns:
      the parsed date, or null if the text did not match
    • format

      public static String format(DateFormat receiver, Date date)
      Weaves DateFormat.format(Date), recording only when the receiver is a SimpleDateFormat.

      Library code rarely holds the concrete type. Jackson builds SimpleDateFormat instances and keeps them in DateFormat fields, and the weaver matches a call only when its owner is the entry's type or a subtype, so none of those calls was substituted (#542). DateFormat has subclasses of every kind, including stateless ones, so the static type is not evidence and the runtime type is checked before recording.

      Parameters:
      receiver - the format
      date - the date to format
      Returns:
      the formatted text
      Since:
      1.12.1
    • parse

      public static Date parse(DateFormat receiver, String source) throws ParseException
      Weaves DateFormat.parse(String), recording only when the receiver is a SimpleDateFormat.
      Parameters:
      receiver - the format
      source - the text to parse
      Returns:
      the parsed date
      Throws:
      ParseException - if the text cannot be parsed
      Since:
      1.12.1
    • parse

      public static Date parse(DateFormat receiver, String source, ParsePosition position)
      Weaves DateFormat.parse(String, ParsePosition), recording only when the receiver is a SimpleDateFormat.

      Jackson's StdDateFormat parses RFC 1123 text through exactly this call, on a SimpleDateFormat it holds as a DateFormat.

      Parameters:
      receiver - the format
      source - the text to parse
      position - where to start, updated to where parsing stopped
      Returns:
      the parsed date, or null if the text did not match
      Since:
      1.12.1
    • find

      public static boolean find(Matcher receiver)
      Weaves Matcher.find().
      Parameters:
      receiver - the matcher
      Returns:
      whether a match was found
    • matches

      public static boolean matches(Matcher receiver)
      Weaves Matcher.matches().
      Parameters:
      receiver - the matcher
      Returns:
      whether the whole region matched
    • group

      public static String group(Matcher receiver)
      Weaves Matcher.group().
      Parameters:
      receiver - the matcher
      Returns:
      the matched subsequence
    • group

      public static String group(Matcher receiver, int group)
      Weaves Matcher.group(int).

      find() then group(1) is the standard idiom, and the group-taking overload was the one not woven - so the most common way of reading a shared matcher's result was unobserved while the zero-argument form was seen (#434).

      Parameters:
      receiver - the matcher
      group - the group index
      Returns:
      the matched subsequence
    • group

      public static String group(Matcher receiver, String name)
      Weaves Matcher.group(String), the named-group form of the overload above.
      Parameters:
      receiver - the matcher
      name - the group name
      Returns:
      the matched subsequence
    • find

      public static boolean find(Matcher receiver, int start)
      Weaves Matcher.find(int), which resets the matcher before searching.
      Parameters:
      receiver - the matcher
      start - the index to start from
      Returns:
      whether a match was found
    • update

      public static void update(MessageDigest receiver, byte[] input)
      Weaves MessageDigest.update(byte[]).
      Parameters:
      receiver - the digest
      input - the bytes to add
    • digest

      public static byte[] digest(MessageDigest receiver)
      Weaves MessageDigest.digest().
      Parameters:
      receiver - the digest
      Returns:
      the computed hash
    • digest

      public static byte[] digest(MessageDigest receiver, byte[] input)
      Weaves MessageDigest.digest(byte[]).
      Parameters:
      receiver - the digest
      input - the final bytes to add before computing
      Returns:
      the computed hash
    • update

      public static void update(MessageDigest receiver, byte input)
      Weaves MessageDigest.update(byte).
      Parameters:
      receiver - the digest
      input - the byte to accumulate
    • update

      public static void update(MessageDigest receiver, byte[] input, int offset, int length)
      Weaves MessageDigest.update(byte[], int, int), the ranged form.
      Parameters:
      receiver - the digest
      input - the buffer to accumulate from
      offset - where to start
      length - how many bytes
    • update

      public static void update(MessageDigest receiver, ByteBuffer input)
      Weaves MessageDigest.update(ByteBuffer).
      Parameters:
      receiver - the digest
      input - the buffer to accumulate from
    • digest

      public static int digest(MessageDigest receiver, byte[] output, int offset, int length) throws DigestException
      Weaves MessageDigest.digest(byte[], int, int).
      Parameters:
      receiver - the digest
      output - where to write the digest
      offset - where to start writing
      length - how much room there is
      Returns:
      the number of bytes written
      Throws:
      DigestException - if the output buffer is too small
    • get

      public static int get(Calendar receiver, int field)
      Weaves Calendar.get(int).
      Parameters:
      receiver - the calendar
      field - the field to read
      Returns:
      the field's value
    • set

      public static void set(Calendar receiver, int field, int value)
      Weaves Calendar.set(int, int).
      Parameters:
      receiver - the calendar
      field - the field to write
      value - the value to write
    • set

      public static void set(Calendar receiver, int year, int month, int date)
      Weaves Calendar.set(int, int, int).

      The three date-setting overloads below are how calendars are actually populated - set(field, value) one field at a time is the rarer shape - and none of them was woven (#434).

      Parameters:
      receiver - the calendar
      year - the calendar year, as Calendar.YEAR takes it
      month - the zero-based month, as Calendar.MONTH takes it
      date - the day of month
    • set

      public static void set(Calendar receiver, int year, int month, int date, int hour, int minute)
      Weaves Calendar.set(int, int, int, int, int).
      Parameters:
      receiver - the calendar
      year - the calendar year, as Calendar.YEAR takes it
      month - the zero-based month, as Calendar.MONTH takes it
      date - the day of month
      hour - the hour of day
      minute - the minutes past the hour
    • set

      public static void set(Calendar receiver, int year, int month, int date, int hour, int minute, int second)
      Weaves Calendar.set(int, int, int, int, int, int).
      Parameters:
      receiver - the calendar
      year - the calendar year, as Calendar.YEAR takes it
      month - the zero-based month, as Calendar.MONTH takes it
      date - the day of month
      hour - the hour of day
      minute - the minutes past the hour
      second - the seconds past the minute
    • add

      public static void add(Calendar receiver, int field, int amount)
      Weaves Calendar.add(int, int) (#820).

      Recorded with the field, so an add to a field below MONTH, which the JDK carries out as a setTimeInMillis, leaves the next get a read.

      Parameters:
      receiver - the calendar
      field - the field to add to
      amount - the amount to add
    • roll

      public static void roll(Calendar receiver, int field, int amount)
      Weaves Calendar.roll(int, int) (#820): recorded as an add that leaves the fields to recompute, except on a plain GregorianCalendar, where a roll by 0 changes nothing and a roll of HOUR or HOUR_OF_DAY keeps every field computed, as a setTime does.
      Parameters:
      receiver - the calendar
      field - the field to roll
      amount - the signed amount to roll by
    • roll

      public static void roll(Calendar receiver, int field, boolean up)
      Weaves Calendar.roll(int, boolean) (#820), recorded as roll(Calendar, int, int) is.
      Parameters:
      receiver - the calendar
      field - the field to roll
      up - whether to roll up rather than down
    • clear

      public static void clear(Calendar receiver)
      Weaves Calendar.clear() (#820): every field is left unset, so the next get recomputes them, as after a set.
      Parameters:
      receiver - the calendar
    • clear

      public static void clear(Calendar receiver, int field)
      Weaves Calendar.clear(int) (#820), recorded as clear(Calendar) is.
      Parameters:
      receiver - the calendar
      field - the field to clear
    • setTime

      public static void setTime(Calendar receiver, Date date)
      Weaves Calendar.setTime(Date) (#820): a write that computes every field at once, so the next get only reads.
      Parameters:
      receiver - the calendar
      date - the time to set
    • setTimeInMillis

      public static void setTimeInMillis(Calendar receiver, long millis)
      Weaves Calendar.setTimeInMillis(long) (#820), recorded as setTime(java.util.Calendar, java.util.Date) is.
      Parameters:
      receiver - the calendar
      millis - the time to set, in milliseconds since the epoch
    • setTimeZone

      public static void setTimeZone(Calendar receiver, TimeZone zone)
      Weaves Calendar.setTimeZone(TimeZone) (#820): the fields are left to recompute in the new zone, so the next get writes them, as after a set.
      Parameters:
      receiver - the calendar
      zone - the time zone to set
    • append

      public static StringBuilder append(StringBuilder receiver, String value)
      Weaves StringBuilder.append(String).
      Parameters:
      receiver - the builder
      value - the text to append
      Returns:
      the builder, so the call chain is unchanged
    • append

      public static StringBuilder append(StringBuilder receiver, int value)
      Weaves StringBuilder.append(int).
      Parameters:
      receiver - the builder
      value - the number to append
      Returns:
      the builder, so the call chain is unchanged
    • append

      public static StringBuilder append(StringBuilder receiver, char value)
      Weaves StringBuilder.append(char).

      The five overloads below carry no new argument about correctness. They exist because the weaver matches an exact descriptor, so a shared builder appended to with a char was invisible while the same builder appended to with a String was not - and append(char) reads count, writes the array and writes count back exactly as the others do. The gap was found by a corpus row that had to fire and did not (#434).

      Parameters:
      receiver - the builder
      value - the character to append
      Returns:
      the builder, so the call chain is unchanged
    • append

      public static StringBuilder append(StringBuilder receiver, long value)
      Weaves StringBuilder.append(long).
      Parameters:
      receiver - the builder
      value - the number to append
      Returns:
      the builder, so the call chain is unchanged
    • append

      public static StringBuilder append(StringBuilder receiver, double value)
      Weaves StringBuilder.append(double).
      Parameters:
      receiver - the builder
      value - the number to append
      Returns:
      the builder, so the call chain is unchanged
    • append

      public static StringBuilder append(StringBuilder receiver, boolean value)
      Weaves StringBuilder.append(boolean).
      Parameters:
      receiver - the builder
      value - the flag to append
      Returns:
      the builder, so the call chain is unchanged
    • append

      public static StringBuilder append(StringBuilder receiver, Object value)
      Weaves StringBuilder.append(Object).
      Parameters:
      receiver - the builder
      value - the value to append
      Returns:
      the builder, so the call chain is unchanged
    • append

      public static StringBuilder append(StringBuilder receiver, CharSequence value)
      Weaves StringBuilder.append(CharSequence).
      Parameters:
      receiver - the builder
      value - the sequence to append
      Returns:
      the builder, so the call chain is unchanged
    • joinerAdd

      public static StringJoiner joinerAdd(StringJoiner receiver, CharSequence element)
      Weaves StringJoiner.add(CharSequence): an append to the joiner's unsynchronised array, recorded on the STRING_BUILDER detector as a builder's is (#1309).
      Parameters:
      receiver - the joiner
      element - the element to add
      Returns:
      the joiner, so the call chain is unchanged
      Since:
      1.14.4
    • joinerMerge

      public static StringJoiner joinerMerge(StringJoiner receiver, StringJoiner other)
      Weaves StringJoiner.merge(StringJoiner): a write of the receiver and a read of the joiner merged in (#1309).
      Parameters:
      receiver - the joiner merged into
      other - the joiner whose contents are added
      Returns:
      the receiver, so the call chain is unchanged
      Since:
      1.14.4
    • joinerSetEmptyValue

      public static StringJoiner joinerSetEmptyValue(StringJoiner receiver, CharSequence emptyValue)
      Weaves StringJoiner.setEmptyValue(CharSequence), a write (#1309).
      Parameters:
      receiver - the joiner
      emptyValue - what an empty joiner reads as
      Returns:
      the joiner, so the call chain is unchanged
      Since:
      1.14.4
    • joinerToString

      public static String joinerToString(StringJoiner receiver)
      Weaves StringJoiner.toString(), a read (#1309).
      Parameters:
      receiver - the joiner
      Returns:
      the joined text
      Since:
      1.14.4
    • joinerLength

      public static int joinerLength(StringJoiner receiver)
      Weaves StringJoiner.length(), a read (#1309).
      Parameters:
      receiver - the joiner
      Returns:
      the length of the joined text
      Since:
      1.14.4
    • tokenizerHasMoreTokens

      public static boolean tokenizerHasMoreTokens(StringTokenizer receiver)
      Weaves StringTokenizer.hasMoreTokens(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the tokenizer
      Returns:
      what the original call returns
      Since:
      1.14.4
    • tokenizerNextToken

      public static String tokenizerNextToken(StringTokenizer receiver)
      Weaves StringTokenizer.nextToken(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the tokenizer
      Returns:
      what the original call returns
      Since:
      1.14.4
    • tokenizerNextToken

      public static String tokenizerNextToken(StringTokenizer receiver, String delimiters)
      Weaves StringTokenizer.nextToken(String): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the tokenizer
      delimiters - as the original call takes it
      Returns:
      what the original call returns
      Since:
      1.14.4
    • tokenizerHasMoreElements

      public static boolean tokenizerHasMoreElements(StringTokenizer receiver)
      Weaves StringTokenizer.hasMoreElements(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the tokenizer
      Returns:
      what the original call returns
      Since:
      1.14.4
    • tokenizerNextElement

      public static Object tokenizerNextElement(StringTokenizer receiver)
      Weaves StringTokenizer.nextElement(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the tokenizer
      Returns:
      what the original call returns
      Since:
      1.14.4
    • tokenizerCountTokens

      public static int tokenizerCountTokens(StringTokenizer receiver)
      Weaves StringTokenizer.countTokens(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the tokenizer
      Returns:
      what the original call returns
      Since:
      1.14.4
    • breakSetText

      public static void breakSetText(BreakIterator receiver, String text)
      Weaves BreakIterator.setText(String): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      text - as the original call takes it
      Since:
      1.14.4
    • breakSetText

      public static void breakSetText(BreakIterator receiver, CharacterIterator text)
      Weaves BreakIterator.setText(CharacterIterator): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      text - as the original call takes it
      Since:
      1.14.4
    • breakFirst

      public static int breakFirst(BreakIterator receiver)
      Weaves BreakIterator.first(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      Returns:
      what the original call returns
      Since:
      1.14.4
    • breakLast

      public static int breakLast(BreakIterator receiver)
      Weaves BreakIterator.last(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      Returns:
      what the original call returns
      Since:
      1.14.4
    • breakNext

      public static int breakNext(BreakIterator receiver)
      Weaves BreakIterator.next(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      Returns:
      what the original call returns
      Since:
      1.14.4
    • breakNext

      public static int breakNext(BreakIterator receiver, int n)
      Weaves BreakIterator.next(int): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      n - as the original call takes it
      Returns:
      what the original call returns
      Since:
      1.14.4
    • breakPrevious

      public static int breakPrevious(BreakIterator receiver)
      Weaves BreakIterator.previous(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      Returns:
      what the original call returns
      Since:
      1.14.4
    • breakFollowing

      public static int breakFollowing(BreakIterator receiver, int offset)
      Weaves BreakIterator.following(int): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      offset - as the original call takes it
      Returns:
      what the original call returns
      Since:
      1.14.4
    • breakPreceding

      public static int breakPreceding(BreakIterator receiver, int offset)
      Weaves BreakIterator.preceding(int): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      offset - as the original call takes it
      Returns:
      what the original call returns
      Since:
      1.14.4
    • breakCurrent

      public static int breakCurrent(BreakIterator receiver)
      Weaves BreakIterator.current(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      Returns:
      what the original call returns
      Since:
      1.14.4
    • breakIsBoundary

      public static boolean breakIsBoundary(BreakIterator receiver, int offset)
      Weaves BreakIterator.isBoundary(int): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      offset - as the original call takes it
      Returns:
      what the original call returns
      Since:
      1.14.4
    • breakGetText

      public static CharacterIterator breakGetText(BreakIterator receiver)
      Weaves BreakIterator.getText(): a step of the instance's cursor, recorded on the SHARED_ITERATOR detector before it runs (#1322).
      Parameters:
      receiver - the break iterator
      Returns:
      what the original call returns
      Since:
      1.14.4
    • append

      public static Appendable append(Appendable receiver, CharSequence value) throws IOException
      Weaves Appendable.append(CharSequence), recording only when the receiver is a StringBuilder.

      Library code appends through Appendable: Guava's Joiner.appendTo takes a StringBuilder and writes to it through that interface, so a builder shared across threads and handed to Guava was never observed (#542). Appendable is also StringBuffer, Writer and a dozen safe things, which is why the static type alone is not evidence and the runtime type is checked before recording.

      Parameters:
      receiver - the appendable
      value - the sequence to append
      Returns:
      the receiver, so the call chain is unchanged
      Throws:
      IOException - if the receiver's append throws
      Since:
      1.12.1
    • append

      public static Appendable append(Appendable receiver, char value) throws IOException
      Weaves Appendable.append(char), recording only when the receiver is a StringBuilder.
      Parameters:
      receiver - the appendable
      value - the character to append
      Returns:
      the receiver, so the call chain is unchanged
      Throws:
      IOException - if the receiver's append throws
      Since:
      1.12.1
    • append

      public static Appendable append(Appendable receiver, CharSequence value, int start, int end) throws IOException
      Weaves Appendable.append(CharSequence, int, int), recording only when the receiver is a StringBuilder.
      Parameters:
      receiver - the appendable
      value - the sequence to append from
      start - the first index to append
      end - the index after the last one to append
      Returns:
      the receiver, so the call chain is unchanged
      Throws:
      IOException - if the receiver's append throws
      Since:
      1.12.1
    • format

      public static String format(NumberFormat receiver, long value)
      Weaves NumberFormat.format(long).

      Formatting an integral value is at least as common as formatting a double, and only the double overload was woven (#434).

      Parameters:
      receiver - the format
      value - the number to format
      Returns:
      the formatted text
    • format

      public static String format(NumberFormat receiver, double value)
      Weaves NumberFormat.format(double), which covers DecimalFormat.
      Parameters:
      receiver - the format
      value - the number to format
      Returns:
      the formatted text
    • parse

      public static Number parse(NumberFormat receiver, String source) throws ParseException
      Weaves NumberFormat.parse(String).

      Parsing drives the same digit list and position state formatting does, and a caller that hands a shared format to a parsing utility (Spring's NumberUtils.parseNumber takes one) was invisible while only format was woven (#542). Every JDK NumberFormat is unsafe to share, so no runtime check is needed here.

      Parameters:
      receiver - the format
      source - the text to parse
      Returns:
      the parsed number
      Throws:
      ParseException - if the text cannot be parsed
      Since:
      1.12.1
    • parse

      public static Number parse(NumberFormat receiver, String source, ParsePosition position)
      Weaves NumberFormat.parse(String, ParsePosition).
      Parameters:
      receiver - the format
      source - the text to parse
      position - where to start, updated to where parsing stopped
      Returns:
      the parsed number, or null if the text did not match
      Since:
      1.12.1
    • format

      public static String format(Format receiver, Object value)
      Weaves Format.format(Object), the call every java.text format inherits.

      It is how a BigDecimal or a boxed number reaches a DecimalFormat and how a MessageFormat is used at all, and it was invisible while the typed overloads were woven (#1319). Format is also the immutable view of a DateTimeFormatter and any format an application wrote, so only a NumberFormat, a SimpleDateFormat or a MessageFormat receiver is recorded.

      Parameters:
      receiver - the format
      value - the object to format
      Returns:
      the formatted text
      Since:
      1.14.3
    • parseObject

      public static Object parseObject(Format receiver, String source) throws ParseException
      Weaves Format.parseObject(String); records what format(Format, Object) does.
      Parameters:
      receiver - the format
      source - the text to parse
      Returns:
      the parsed object
      Throws:
      ParseException - if the text cannot be parsed
      Since:
      1.14.3
    • parse

      public static Object[] parse(MessageFormat receiver, String source) throws ParseException
      Weaves MessageFormat.parse(String).
      Parameters:
      receiver - the format
      source - the text to parse
      Returns:
      the parsed arguments
      Throws:
      ParseException - if the text cannot be parsed
      Since:
      1.14.3
    • format

      public static Formatter format(Formatter receiver, String format, Object... args)
      Weaves java.util.Formatter.format(String, Object...).
      Parameters:
      receiver - the formatter
      format - the format string
      args - the format arguments
      Returns:
      the formatter, so the call chain is unchanged
    • format

      public static Formatter format(Formatter receiver, Locale locale, String format, Object... args)
      Weaves Formatter.format(Locale, String, Object...).

      The locale-taking overload is the one an internationalised codebase actually calls, and it was invisible while its two-argument sibling was woven. Same receiver, same interleaved output, different descriptor (#434).

      Parameters:
      receiver - the formatter
      locale - the locale to format with
      format - the format string
      args - the format arguments
      Returns:
      the formatter, so the call chain is unchanged
    • persistenceHandleUsed

      public static void persistenceHandleUsed(Object handle)
      Called before each call on a JPA EntityManager or Hibernate Session the agent weaves, with the handle: the call's thread uses it (#992). The detector checks the handle's type by interface name, since the library cannot depend on JPA.
      Parameters:
      handle - the call's receiver
      Since:
      1.13.2
    • persistenceHandleClosed

      public static void persistenceHandleClosed(Object handle)
      Called before a woven close() on a persistence handle: the thread lets it go, which is the per-transaction hand-off the detector excuses when no two threads held it at once (#992).
      Parameters:
      handle - the handle being closed
      Since:
      1.13.2
    • get

      public static byte get(ByteBuffer receiver)
    • get

      public static ByteBuffer get(ByteBuffer receiver, byte[] dst)
    • get

      public static ByteBuffer get(ByteBuffer receiver, byte[] dst, int offset, int length)
    • put

      public static ByteBuffer put(ByteBuffer receiver, byte b)
    • put

      public static ByteBuffer put(ByteBuffer receiver, byte[] src)
    • put

      public static ByteBuffer put(ByteBuffer receiver, byte[] src, int offset, int length)
    • put

      public static ByteBuffer put(ByteBuffer receiver, ByteBuffer src)
    • getInt

      public static int getInt(ByteBuffer receiver)
    • putInt

      public static ByteBuffer putInt(ByteBuffer receiver, int value)
    • getLong

      public static long getLong(ByteBuffer receiver)
    • putLong

      public static ByteBuffer putLong(ByteBuffer receiver, long value)
    • flip

      public static ByteBuffer flip(ByteBuffer receiver)
    • clear

      public static ByteBuffer clear(ByteBuffer receiver)
    • rewind

      public static ByteBuffer rewind(ByteBuffer receiver)
    • compact

      public static ByteBuffer compact(ByteBuffer receiver)
    • encode

      public static ByteBuffer encode(CharsetEncoder receiver, CharBuffer in) throws CharacterCodingException
      Throws:
      CharacterCodingException
    • encode

      public static CoderResult encode(CharsetEncoder receiver, CharBuffer in, ByteBuffer out, boolean endOfInput)
    • flush

      public static CoderResult flush(CharsetEncoder receiver, ByteBuffer out)
    • reset

      public static CharsetEncoder reset(CharsetEncoder receiver)
    • decode

      public static CharBuffer decode(CharsetDecoder receiver, ByteBuffer in) throws CharacterCodingException
      Throws:
      CharacterCodingException
    • decode

      public static CoderResult decode(CharsetDecoder receiver, ByteBuffer in, CharBuffer out, boolean endOfInput)
    • flush

      public static CoderResult flush(CharsetDecoder receiver, CharBuffer out)
    • reset

      public static CharsetDecoder reset(CharsetDecoder receiver)
    • update

      public static void update(Checksum receiver, int b)
    • update

      public static void update(Checksum receiver, byte[] b)
    • update

      public static void update(Checksum receiver, byte[] b, int off, int len)
    • update

      public static void update(Checksum receiver, ByteBuffer buffer)
    • getValue

      public static long getValue(Checksum receiver)
    • reset

      public static void reset(Checksum receiver)
    • setInput

      public static void setInput(Deflater receiver, byte[] input)
    • setInput

      public static void setInput(Deflater receiver, byte[] input, int off, int len)
    • setInput

      public static void setInput(Deflater receiver, ByteBuffer input)
    • deflate

      public static int deflate(Deflater receiver, byte[] output)
    • deflate

      public static int deflate(Deflater receiver, byte[] output, int off, int len)
    • deflate

      public static int deflate(Deflater receiver, byte[] output, int off, int len, int flush)
    • deflate

      public static int deflate(Deflater receiver, ByteBuffer output)
    • deflate

      public static int deflate(Deflater receiver, ByteBuffer output, int flush)
    • finish

      public static void finish(Deflater receiver)
    • reset

      public static void reset(Deflater receiver)
    • end

      public static void end(Deflater receiver)
    • setInput

      public static void setInput(Inflater receiver, byte[] input)
    • setInput

      public static void setInput(Inflater receiver, byte[] input, int off, int len)
    • setInput

      public static void setInput(Inflater receiver, ByteBuffer input)
    • inflate

      public static int inflate(Inflater receiver, byte[] output) throws DataFormatException
      Throws:
      DataFormatException
    • inflate

      public static int inflate(Inflater receiver, byte[] output, int off, int len) throws DataFormatException
      Throws:
      DataFormatException
    • inflate

      public static int inflate(Inflater receiver, ByteBuffer output) throws DataFormatException
      Throws:
      DataFormatException
    • reset

      public static void reset(Inflater receiver)
    • end

      public static void end(Inflater receiver)
    • nextInt

      public static int nextInt(SplittableRandom receiver)
    • nextInt

      public static int nextInt(SplittableRandom receiver, int bound)
    • nextInt

      public static int nextInt(SplittableRandom receiver, int origin, int bound)
    • nextLong

      public static long nextLong(SplittableRandom receiver)
    • nextLong

      public static long nextLong(SplittableRandom receiver, long bound)
    • nextLong

      public static long nextLong(SplittableRandom receiver, long origin, long bound)
    • nextDouble

      public static double nextDouble(SplittableRandom receiver)
    • nextDouble

      public static double nextDouble(SplittableRandom receiver, double bound)
    • nextDouble

      public static double nextDouble(SplittableRandom receiver, double origin, double bound)
    • nextBoolean

      public static boolean nextBoolean(SplittableRandom receiver)
    • nextBytes

      public static void nextBytes(SplittableRandom receiver, byte[] bytes)
    • split

      public static SplittableRandom split(SplittableRandom receiver)
    • split

    • update

      public static void update(Mac receiver, byte a0)
      Weaves Mac.update(byte).
      Parameters:
      receiver - the mac
      a0 - the call's byte argument, passed through
    • update

      public static void update(Mac receiver, byte[] a0)
      Weaves Mac.update(byte[]).
      Parameters:
      receiver - the mac
      a0 - the call's byte[] argument, passed through
    • update

      public static void update(Mac receiver, byte[] a0, int a1, int a2)
      Weaves Mac.update(byte[], int, int).
      Parameters:
      receiver - the mac
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
    • update

      public static void update(Mac receiver, ByteBuffer a0)
      Weaves Mac.update(ByteBuffer).
      Parameters:
      receiver - the mac
      a0 - the call's ByteBuffer argument, passed through
    • doFinal

      public static byte[] doFinal(Mac receiver)
      Weaves Mac.doFinal().
      Parameters:
      receiver - the mac
      Returns:
      what the mac returned
    • doFinal

      public static byte[] doFinal(Mac receiver, byte[] a0)
      Weaves Mac.doFinal(byte[]).
      Parameters:
      receiver - the mac
      a0 - the call's byte[] argument, passed through
      Returns:
      what the mac returned
    • doFinal

      public static void doFinal(Mac receiver, byte[] a0, int a1) throws ShortBufferException
      Weaves Mac.doFinal(byte[], int).
      Parameters:
      receiver - the mac
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      Throws:
      ShortBufferException - as the mac throws it
    • update

      public static void update(Signature receiver, byte a0) throws SignatureException
      Weaves Signature.update(byte).
      Parameters:
      receiver - the signature
      a0 - the call's byte argument, passed through
      Throws:
      SignatureException - as the signature throws it
    • update

      public static void update(Signature receiver, byte[] a0) throws SignatureException
      Weaves Signature.update(byte[]).
      Parameters:
      receiver - the signature
      a0 - the call's byte[] argument, passed through
      Throws:
      SignatureException - as the signature throws it
    • update

      public static void update(Signature receiver, byte[] a0, int a1, int a2) throws SignatureException
      Weaves Signature.update(byte[], int, int).
      Parameters:
      receiver - the signature
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
      Throws:
      SignatureException - as the signature throws it
    • update

      public static void update(Signature receiver, ByteBuffer a0) throws SignatureException
      Weaves Signature.update(ByteBuffer).
      Parameters:
      receiver - the signature
      a0 - the call's ByteBuffer argument, passed through
      Throws:
      SignatureException - as the signature throws it
    • sign

      public static byte[] sign(Signature receiver) throws SignatureException
      Weaves Signature.sign().
      Parameters:
      receiver - the signature
      Returns:
      what the signature returned
      Throws:
      SignatureException - as the signature throws it
    • sign

      public static int sign(Signature receiver, byte[] a0, int a1, int a2) throws SignatureException
      Weaves Signature.sign(byte[], int, int).
      Parameters:
      receiver - the signature
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
      Returns:
      what the signature returned
      Throws:
      SignatureException - as the signature throws it
    • verify

      public static boolean verify(Signature receiver, byte[] a0) throws SignatureException
      Weaves Signature.verify(byte[]).
      Parameters:
      receiver - the signature
      a0 - the call's byte[] argument, passed through
      Returns:
      what the signature returned
      Throws:
      SignatureException - as the signature throws it
    • verify

      public static boolean verify(Signature receiver, byte[] a0, int a1, int a2) throws SignatureException
      Weaves Signature.verify(byte[], int, int).
      Parameters:
      receiver - the signature
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
      Returns:
      what the signature returned
      Throws:
      SignatureException - as the signature throws it
    • update

      public static byte[] update(Cipher receiver, byte[] a0)
      Weaves Cipher.update(byte[]).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
      Returns:
      what the cipher returned
    • update

      public static byte[] update(Cipher receiver, byte[] a0, int a1, int a2)
      Weaves Cipher.update(byte[], int, int).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
      Returns:
      what the cipher returned
    • update

      public static int update(Cipher receiver, byte[] a0, int a1, int a2, byte[] a3) throws ShortBufferException
      Weaves Cipher.update(byte[], int, int, byte[]).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
      a3 - the call's byte[] argument, passed through
      Returns:
      what the cipher returned
      Throws:
      ShortBufferException - as the cipher throws it
    • update

      public static int update(Cipher receiver, byte[] a0, int a1, int a2, byte[] a3, int a4) throws ShortBufferException
      Weaves Cipher.update(byte[], int, int, byte[], int).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
      a3 - the call's byte[] argument, passed through
      a4 - the call's int argument, passed through
      Returns:
      what the cipher returned
      Throws:
      ShortBufferException - as the cipher throws it
    • update

      public static int update(Cipher receiver, ByteBuffer a0, ByteBuffer a1) throws ShortBufferException
      Weaves Cipher.update(ByteBuffer, ByteBuffer).
      Parameters:
      receiver - the cipher
      a0 - the call's ByteBuffer argument, passed through
      a1 - the call's ByteBuffer argument, passed through
      Returns:
      what the cipher returned
      Throws:
      ShortBufferException - as the cipher throws it
    • doFinal

      public static byte[] doFinal(Cipher receiver) throws IllegalBlockSizeException, BadPaddingException
      Weaves Cipher.doFinal().
      Parameters:
      receiver - the cipher
      Returns:
      what the cipher returned
      Throws:
      IllegalBlockSizeException - as the cipher throws it
      BadPaddingException - as the cipher throws it
    • doFinal

      public static int doFinal(Cipher receiver, byte[] a0, int a1) throws IllegalBlockSizeException, ShortBufferException, BadPaddingException
      Weaves Cipher.doFinal(byte[], int).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      Returns:
      what the cipher returned
      Throws:
      IllegalBlockSizeException - as the cipher throws it
      ShortBufferException - as the cipher throws it
      BadPaddingException - as the cipher throws it
    • doFinal

      public static byte[] doFinal(Cipher receiver, byte[] a0) throws IllegalBlockSizeException, BadPaddingException
      Weaves Cipher.doFinal(byte[]).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
      Returns:
      what the cipher returned
      Throws:
      IllegalBlockSizeException - as the cipher throws it
      BadPaddingException - as the cipher throws it
    • doFinal

      public static byte[] doFinal(Cipher receiver, byte[] a0, int a1, int a2) throws IllegalBlockSizeException, BadPaddingException
      Weaves Cipher.doFinal(byte[], int, int).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
      Returns:
      what the cipher returned
      Throws:
      IllegalBlockSizeException - as the cipher throws it
      BadPaddingException - as the cipher throws it
    • doFinal

      public static int doFinal(Cipher receiver, byte[] a0, int a1, int a2, byte[] a3) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
      Weaves Cipher.doFinal(byte[], int, int, byte[]).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
      a3 - the call's byte[] argument, passed through
      Returns:
      what the cipher returned
      Throws:
      ShortBufferException - as the cipher throws it
      IllegalBlockSizeException - as the cipher throws it
      BadPaddingException - as the cipher throws it
    • doFinal

      public static int doFinal(Cipher receiver, byte[] a0, int a1, int a2, byte[] a3, int a4) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
      Weaves Cipher.doFinal(byte[], int, int, byte[], int).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
      a3 - the call's byte[] argument, passed through
      a4 - the call's int argument, passed through
      Returns:
      what the cipher returned
      Throws:
      ShortBufferException - as the cipher throws it
      IllegalBlockSizeException - as the cipher throws it
      BadPaddingException - as the cipher throws it
    • doFinal

      public static int doFinal(Cipher receiver, ByteBuffer a0, ByteBuffer a1) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
      Weaves Cipher.doFinal(ByteBuffer, ByteBuffer).
      Parameters:
      receiver - the cipher
      a0 - the call's ByteBuffer argument, passed through
      a1 - the call's ByteBuffer argument, passed through
      Returns:
      what the cipher returned
      Throws:
      ShortBufferException - as the cipher throws it
      IllegalBlockSizeException - as the cipher throws it
      BadPaddingException - as the cipher throws it
    • updateAAD

      public static void updateAAD(Cipher receiver, byte[] a0)
      Weaves Cipher.updateAAD(byte[]).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
    • updateAAD

      public static void updateAAD(Cipher receiver, byte[] a0, int a1, int a2)
      Weaves Cipher.updateAAD(byte[], int, int).
      Parameters:
      receiver - the cipher
      a0 - the call's byte[] argument, passed through
      a1 - the call's int argument, passed through
      a2 - the call's int argument, passed through
    • updateAAD

      public static void updateAAD(Cipher receiver, ByteBuffer a0)
      Weaves Cipher.updateAAD(ByteBuffer).
      Parameters:
      receiver - the cipher
      a0 - the call's ByteBuffer argument, passed through
    • init

      public static void init(Mac receiver, Key key) throws InvalidKeyException
      Weaves Mac.init(Key).
      Parameters:
      receiver - the mac
      key - the call's Key argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      Since:
      1.14.4
    • init

      public static void init(Mac receiver, Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException
      Weaves Mac.init(Key, AlgorithmParameterSpec).
      Parameters:
      receiver - the mac
      key - the call's Key argument, passed through
      params - the call's AlgorithmParameterSpec argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      InvalidAlgorithmParameterException - as the original call does
      Since:
      1.14.4
    • reset

      public static void reset(Mac receiver)
      Weaves Mac.reset().
      Parameters:
      receiver - the mac
      Since:
      1.14.4
    • initSign

      public static void initSign(Signature receiver, PrivateKey privateKey) throws InvalidKeyException
      Weaves Signature.initSign(PrivateKey).
      Parameters:
      receiver - the signature
      privateKey - the call's PrivateKey argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      Since:
      1.14.4
    • initSign

      public static void initSign(Signature receiver, PrivateKey privateKey, SecureRandom random) throws InvalidKeyException
      Weaves Signature.initSign(PrivateKey, SecureRandom).
      Parameters:
      receiver - the signature
      privateKey - the call's PrivateKey argument, passed through
      random - the call's SecureRandom argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      Since:
      1.14.4
    • initVerify

      public static void initVerify(Signature receiver, PublicKey publicKey) throws InvalidKeyException
      Weaves Signature.initVerify(PublicKey).
      Parameters:
      receiver - the signature
      publicKey - the call's PublicKey argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      Since:
      1.14.4
    • initVerify

      public static void initVerify(Signature receiver, Certificate certificate) throws InvalidKeyException
      Weaves Signature.initVerify(Certificate).
      Parameters:
      receiver - the signature
      certificate - the call's Certificate argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      Since:
      1.14.4
    • init

      public static void init(Cipher receiver, int opmode, Key key) throws InvalidKeyException
      Weaves Cipher.init(int, Key).
      Parameters:
      receiver - the cipher
      opmode - the call's int argument, passed through
      key - the call's Key argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      Since:
      1.14.4
    • init

      public static void init(Cipher receiver, int opmode, Key key, SecureRandom random) throws InvalidKeyException
      Weaves Cipher.init(int, Key, SecureRandom).
      Parameters:
      receiver - the cipher
      opmode - the call's int argument, passed through
      key - the call's Key argument, passed through
      random - the call's SecureRandom argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      Since:
      1.14.4
    • init

      public static void init(Cipher receiver, int opmode, Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException
      Weaves Cipher.init(int, Key, AlgorithmParameterSpec).
      Parameters:
      receiver - the cipher
      opmode - the call's int argument, passed through
      key - the call's Key argument, passed through
      params - the call's AlgorithmParameterSpec argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      InvalidAlgorithmParameterException - as the original call does
      Since:
      1.14.4
    • init

      public static void init(Cipher receiver, int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
      Weaves Cipher.init(int, Key, AlgorithmParameterSpec, SecureRandom).
      Parameters:
      receiver - the cipher
      opmode - the call's int argument, passed through
      key - the call's Key argument, passed through
      params - the call's AlgorithmParameterSpec argument, passed through
      random - the call's SecureRandom argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      InvalidAlgorithmParameterException - as the original call does
      Since:
      1.14.4
    • init

      public static void init(Cipher receiver, int opmode, Key key, AlgorithmParameters params) throws InvalidKeyException, InvalidAlgorithmParameterException
      Weaves Cipher.init(int, Key, AlgorithmParameters).
      Parameters:
      receiver - the cipher
      opmode - the call's int argument, passed through
      key - the call's Key argument, passed through
      params - the call's AlgorithmParameters argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      InvalidAlgorithmParameterException - as the original call does
      Since:
      1.14.4
    • init

      public static void init(Cipher receiver, int opmode, Key key, AlgorithmParameters params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
      Weaves Cipher.init(int, Key, AlgorithmParameters, SecureRandom).
      Parameters:
      receiver - the cipher
      opmode - the call's int argument, passed through
      key - the call's Key argument, passed through
      params - the call's AlgorithmParameters argument, passed through
      random - the call's SecureRandom argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      InvalidAlgorithmParameterException - as the original call does
      Since:
      1.14.4
    • init

      public static void init(Cipher receiver, int opmode, Certificate certificate) throws InvalidKeyException
      Weaves Cipher.init(int, Certificate).
      Parameters:
      receiver - the cipher
      opmode - the call's int argument, passed through
      certificate - the call's Certificate argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      Since:
      1.14.4
    • init

      public static void init(Cipher receiver, int opmode, Certificate certificate, SecureRandom random) throws InvalidKeyException
      Weaves Cipher.init(int, Certificate, SecureRandom).
      Parameters:
      receiver - the cipher
      opmode - the call's int argument, passed through
      certificate - the call's Certificate argument, passed through
      random - the call's SecureRandom argument, passed through
      Throws:
      InvalidKeyException - as the original call does
      Since:
      1.14.4
    • wrap

      public static byte[] wrap(Cipher receiver, Key key) throws IllegalBlockSizeException, InvalidKeyException
      Weaves Cipher.wrap(Key).
      Parameters:
      receiver - the cipher
      key - the call's Key argument, passed through
      Returns:
      what the original call returns
      Throws:
      IllegalBlockSizeException - as the original call does
      InvalidKeyException - as the original call does
      Since:
      1.14.4
    • unwrap

      public static Key unwrap(Cipher receiver, byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException
      Weaves Cipher.unwrap(byte[], String, int).
      Parameters:
      receiver - the cipher
      wrappedKey - the call's byte[] argument, passed through
      wrappedKeyAlgorithm - the call's String argument, passed through
      wrappedKeyType - the call's int argument, passed through
      Returns:
      what the original call returns
      Throws:
      InvalidKeyException - as the original call does
      NoSuchAlgorithmException - as the original call does
      Since:
      1.14.4