class RateLimitedLogger {

    @VisibleForTesting
    static @Nullable Object[] newArgsWithCountSinceLastWarning(/*@Nullable*/ Object[] args,
            int countSinceLastWarning) {
        if (args.length == 0) {
            return new Object[] {countSinceLastWarning};
        }
        @Nullable
        Object[] argsPlus = new Object[args.length + 1];
        if (args[args.length - 1] instanceof Throwable) {
            System.arraycopy(args, 0, argsPlus, 0, args.length - 1);
            argsPlus[args.length - 1] = countSinceLastWarning;
            argsPlus[args.length] = args[args.length - 1];
            return argsPlus;
        } else {
            System.arraycopy(args, 0, argsPlus, 0, args.length);
            argsPlus[args.length] = countSinceLastWarning;
            return argsPlus;
        }
    }

    public  RateLimitedLogger(Class<?> clazz);

}