Note that this is somewhat-improperly used from Verify.java as well.
341637
private static String format(String template, @javax.annotation.Nullable Object... args) {
    // If no arguments return the template.
    if (args == null) {
      return template;
    }

    // start substituting the arguments into the '%s' placeholders
    StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
    int templateStart = 0;
    int i = 0;
    while (i < args.length) {
      int placeholderStart = template.indexOf("%s", templateStart);
      if (placeholderStart == -1) {
        break;
      }
      builder.append(template, templateStart, placeholderStart);
      builder.append(args[i++]);
      templateStart = placeholderStart + 2;
    }
    builder.append(template, templateStart, template.length());

    // if we run out of placeholders, append the extra args in square braces
    if (i < args.length) {
      builder.append(" [");
      builder.append(args[i++]);
      while (i < args.length) {
        builder.append(", ");
        builder.append(args[i++]);
      }
      builder.append(']');
    }

    return builder.toString();
  }
196878
private static String[] verifyImplicitOption(String[] args)
        throws ProblemException {

        boolean foundImplicit = false;
        for (String a : args) {
            if (a.startsWith("-implicit:")) {
                foundImplicit = true;
                if (!a.equals("-implicit:none")) {
                    throw new ProblemException("The only allowed setting for sjavac is -implicit:none, it is also the default.");
                }
            }
        }
        if (foundImplicit) {
            return args;
        }
        // -implicit:none not found lets add it.
        String[] newargs = new String[args.length+1];
        System.arraycopy(args,0, newargs, 0, args.length);
        newargs[args.length] = "-implicit:none";
        return newargs;
    }
1181343
protected void checkConsecutiveAlpha() {

        Pattern symbolsPatter = Pattern.compile(REGEX_ALPHA_UC + "+");
        Matcher matcher = symbolsPatter.matcher(this.password);
        int met = 0;
        while (matcher.find()) {
            int start = matcher.start();
            int end = matcher.end();
            if (start == end) {
                continue;
            }
            int diff = end - start;
            if (diff >= 3) {
                met += diff;
            }

        }

        this.result.negative(met * CONSECUTIVE_ALPHA_WEIGHT);

        // alpha lower case

        symbolsPatter = Pattern.compile(REGEX_ALPHA_LC + "+");
        matcher = symbolsPatter.matcher(this.password);
        met = 0;
        while (matcher.find()) {
            int start = matcher.start();
            int end = matcher.end();
            if (start == end) {
                continue;
            }
            int diff = end - start;
            if (diff >= 3) {
                met += diff;
            }

        }

        this.result.negative(met * CONSECUTIVE_ALPHA_WEIGHT);
    }
291238
private void verify() {
        Utils.require(!Utils.isEmpty(m_name), "Field name is required");
        Utils.require(m_type != null, "Field type is required");
        
        // If an 'inverse' or 'table' was specified, type must be LINK or XLINK.
        Utils.require(m_linkInverse == null || m_type.isLinkType(),
                      "'inverse' not allowed for this field type: " + m_name);
        Utils.require(m_linkExtent == null || m_type.isLinkType(),
                      "'table' not allowed for this field type: " + m_name);
        
        // LINK and XLINK require an 'inverse'.
        Utils.require(!m_type.isLinkType() || m_linkInverse != null,
                      "Missing 'inverse' option: " + m_name);
        
        // XLINK requires a junction field: default is "_ID".
        if (!Utils.isEmpty(m_junctionField)) {
            Utils.require(m_type == FieldType.XLINK, "'junction' is only allowed for xlinks");
        } else if (m_type == FieldType.XLINK) {
            m_junctionField = "_ID";
        }
        
        // If collection was not explicitly set, set to true for links and false for scalars
        if (!m_bIsCollection && m_type.isLinkType()) {
            m_bIsCollection = true;
        }
        
        // 'analyzer' can only be set for scalar field types, but don't verify value here.
        Utils.require(m_analyzerName == null || m_type.isScalarType(),
                      "'analyzer' can only be specified for scalar field types: " + m_analyzerName);
        
        // If this is a binary field, ensure "encoding" is set.
        if (m_encoding != null) {
            Utils.require(m_type == FieldType.BINARY, "'encoding' is only valid for binary fields");
        } else if (m_type == FieldType.BINARY) {
            m_encoding = EncodingType.getDefaultEncoding();
        }
        
        // Binary fields cannot be collections.
        Utils.require(m_type != FieldType.BINARY || !m_bIsCollection,
                      "Binary fields cannot be collections (multi-valued)");
    }
808905
private void verifyArguments(JmxExecRequest request, OperationAndParamType pTypes, int pNrParams, List<Object> pArgs) {
        if ( (pNrParams > 0 && pArgs == null) || (pArgs != null && pArgs.size() != pNrParams)) {
            throw new IllegalArgumentException("Invalid number of operation arguments. Operation " +
                    request.getOperation() + " on " + request.getObjectName() + " requires " + pTypes.paramClasses.length +
                    " parameters, not " + (pArgs == null ? 0 : pArgs.size()) + " as given");
        }
    }
562140
public void verify(PublicKey key, Provider sigProvider)
            throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
        unwrap().verify(key, sigProvider);
    }
710443
public void verifyStatus() {
    if (sequential) {
      boolean unopenedIterator = responseIterator == null && !responses.isEmpty();
      if (unopenedIterator || responseIterator.hasNext()) {
        throw new VerificationAssertionError("More executions were expected");
      }
    }
  }
152421
def verify
      (0...size)
        .map { |i| [i, @data[i]] }
        .reject { |_i, val| yield(val) }
        .to_h
    end
366747
@Deprecated
    public C verifyBetween(int minAllowedStatements, int maxAllowedStatements) throws WrongNumberOfQueriesError {
        return verify(SqlQueries.queriesBetween(minAllowedStatements, maxAllowedStatements));
    }
1326168
public void checkValid() {
        final StringBuilder b = new StringBuilder();
        if (precisionForFxRate < 2) {
            b.append("Precision for FX should be >=2");
        }
        if (precisionForInverseFxRate < 2) {
            if (b.length() > 0) {
                b.append(",");
            }
            b.append("Precision for 1/FX should be >=2");
        }
        if (ratesSnapshot.isEmpty() && baseFxRateProvider == null) {
            if (b.length() > 0) {
                b.append(",");
            }
            b.append("You must provide Base Rates Snapshots OR a BaseFxRateProvider");
        }

        if (b.length() > 0) {
            throw new IllegalArgumentException(b.toString());
        }
    }
151314
public CodeSigner[] verify(Hashtable<String, CodeSigner[]> verifiedSigners,
                Hashtable<String, CodeSigner[]> sigFileSigners)
        throws JarException
    {
        if (skip) {
            return null;
        }

        if (signers != null)
            return signers;

        for (int i=0; i < digests.size(); i++) {

            MessageDigest digest  = digests.get(i);
            byte [] manHash = manifestHashes.get(i);
            byte [] theHash = digest.digest();

            if (debug != null) {
                debug.println("Manifest Entry: " +
                                   name + " digest=" + digest.getAlgorithm());
                debug.println("  manifest " + toHex(manHash));
                debug.println("  computed " + toHex(theHash));
                debug.println();
            }

            if (!MessageDigest.isEqual(theHash, manHash))
                throw new SecurityException(digest.getAlgorithm()+
                                            " digest error for "+name);
        }

        // take it out of sigFileSigners and put it in verifiedSigners...
        signers = sigFileSigners.remove(name);
        if (signers != null) {
            verifiedSigners.put(name, signers);
        }
        return signers;
    }
40702
private boolean verifyDefine(NodeTraversal t, Node parent, Node methodName, Node args) {
    // Calls to goog.define must be in the global hoist scope.  This is copied from
    // validate(Un)aliasablePrimitiveCall.
    // TODO(sdh): loosen this restriction if the results are assigned?
    if (!compiler.getOptions().shouldPreserveGoogModule() && !t.inGlobalHoistScope()) {
      compiler.report(JSError.make(methodName.getParent(), INVALID_CLOSURE_CALL_SCOPE_ERROR));
      return false;
    }

    // It is an error for goog.define to show up anywhere except on its own or immediately after =.
    if (parent.isAssign() && parent.getParent().isExprResult()) {
      parent = parent.getParent();
    } else if (parent.isName() && NodeUtil.isNameDeclaration(parent.getParent())) {
      parent = parent.getParent();
    } else if (!parent.isExprResult()) {
      compiler.report(JSError.make(methodName.getParent(), INVALID_CLOSURE_CALL_SCOPE_ERROR));
      return false;
    }

    // Verify first arg
    Node arg = args;
    if (!verifyNotNull(methodName, arg) || !verifyOfType(methodName, arg, Token.STRING)) {
      return false;
    }

    // Verify second arg
    arg = arg.getNext();
    if (!args.isFromExterns()
        && (!verifyNotNull(methodName, arg) || !verifyIsLast(methodName, arg))) {
      return false;
    }

    String name = args.getString();
    if (!NodeUtil.isValidQualifiedName(
        compiler.getOptions().getLanguageIn().toFeatureSet(), name)) {
      compiler.report(JSError.make(args, INVALID_DEFINE_NAME_ERROR, name));
      return false;
    }

    JSDocInfo info = (parent.isExprResult() ? parent.getFirstChild() : parent).getJSDocInfo();
    if (info == null || !info.isDefine()) {
      compiler.report(JSError.make(parent, MISSING_DEFINE_ANNOTATION));
      return false;
    }
    return true;
  }
1168298
@Deprecated
    public C verify(int allowedStatements, Query query) throws WrongNumberOfQueriesError {
        return verify(SqlQueries.exactQueries(allowedStatements).type(adapter(query)));
    }
26114
private static boolean verifyFile(Configuration conf,
      FileSystem srcFs, FileSystem parityFs,
      FileStatus stat, Path parityPath, Codec codec,
      long blockOffset, Progressable reporter) 
    throws IOException, InterruptedException {
    Path srcPath = stat.getPath();
    LOG.info("Verify file: " + srcPath + " at offset: " + blockOffset);
    int limit = (int) Math.min(stat.getBlockSize(), DEFAULT_VERIFY_LEN);
    if (reporter == null) {
      reporter = RaidUtils.NULL_PROGRESSABLE;
    }
    
    // try to decode.
    Decoder decoder = new Decoder(conf, codec);
    if (codec.isDirRaid) {
      decoder.connectToStore(srcPath);
    }
    
    List<Long> errorOffsets = new ArrayList<Long>();
    // first limit bytes
    errorOffsets.add(blockOffset);
    long left = Math.min(stat.getBlockSize(), stat.getLen() - blockOffset);
    if (left > limit) {
      // last limit bytes
      errorOffsets.add(blockOffset + left - limit);
      // random limit bytes.
      errorOffsets.add(blockOffset + 
          rand.nextInt((int)(left - limit)));
    }
 
    byte[] buffer = new byte[limit];
    FSDataInputStream is = srcFs.open(srcPath);
    try {
      for (long errorOffset : errorOffsets) {
        is.seek(errorOffset);
        is.read(buffer);
        // calculate the oldCRC.
        CRC32 oldCrc = new CRC32();
        oldCrc.update(buffer);
        
        CRC32 newCrc = new CRC32();
        DecoderInputStream stream = decoder.new DecoderInputStream(
            RaidUtils.NULL_PROGRESSABLE, limit, stat.getBlockSize(), errorOffset, 
            srcFs, srcPath, parityFs, parityPath, null, null, false);
        try {
          stream.read(buffer);
          newCrc.update(buffer);
          if (oldCrc.getValue() != newCrc.getValue()) {
            LogUtils.logFileCheckMetrics(LOGRESULTS.FAILURE, codec, srcPath, 
                srcFs, errorOffset, limit, null, reporter);
            LOG.error("mismatch crc, old " + oldCrc.getValue() + 
                ", new " + newCrc.getValue() + ", for file: " + srcPath
                + " at offset " + errorOffset + ", read limit " + limit);
            return false;
          }
        } finally {
          reporter.progress();
          if (stream != null) {
            stream.close();
          }
        }
      }
      return true;
    } finally {
      is.close();
    }
  }
527962
public boolean verify(byte[] message, byte[] signature) {
		try {
			// this way signatureInstance should be thread safe
			final Signature signatureInstance = ((provider == null) || (provider.length() == 0)) ? Signature
					.getInstance(algorithm) : Signature.getInstance(algorithm, provider);
			signatureInstance.initVerify(publicKey);
			signatureInstance.update(message);
			return signatureInstance.verify(signature);
		} catch (java.security.SignatureException e) {
			return false;
		} catch (Exception e) {
			throw new SignatureException("error verifying signature", e);
		}
	}
1026208
static void checkMethodIdentifier(int version, final String name,
            final String msg) {
        if (name == null || name.length() == 0) {
            throw new IllegalArgumentException("Invalid " + msg
                    + " (must not be null or empty)");
        }
        if ((version & 0xFFFF) >= Opcodes.V1_5) {
            for (int i = 0; i < name.length(); ++i) {
                if (".;[/<>".indexOf(name.charAt(i)) != -1) {
                    throw new IllegalArgumentException("Invalid " + msg
                            + " (must be a valid unqualified name): " + name);
                }
            }
            return;
        }
        if (!Character.isJavaIdentifierStart(name.charAt(0))) {
            throw new IllegalArgumentException(
                    "Invalid "
                            + msg
                            + " (must be a '<init>', '<clinit>' or a valid Java identifier): "
                            + name);
        }
        for (int i = 1; i < name.length(); ++i) {
            if (!Character.isJavaIdentifierPart(name.charAt(i))) {
                throw new IllegalArgumentException(
                        "Invalid "
                                + msg
                                + " (must be '<init>' or '<clinit>' or a valid Java identifier): "
                                + name);
            }
        }
    }
849983
@Override
    public String verifyJarAndPrepareProcRunners(byte[] catalogBytes, String diffCommands,
            byte[] catalogBytesHash, byte[] deploymentBytes) {
        ImmutableMap.Builder<String, Class<?>> classesMap = ImmutableMap.<String, Class<?>>builder();
        InMemoryJarfile newCatalogJar;
        JarLoader jarLoader;
        String errorMsg;
        try {
            newCatalogJar = new InMemoryJarfile(catalogBytes);
            jarLoader = newCatalogJar.getLoader();
            for (String classname : jarLoader.getClassNames()) {
                try {
                    Class<?> procCls = CatalogContext.classForProcedureOrUDF(classname, jarLoader);
                    classesMap.put(classname, procCls);
                }
                // LinkageError catches most of the various class loading errors we'd
                // care about here.
                catch (UnsupportedClassVersionError e) {
                    errorMsg = "Cannot load classes compiled with a higher version of Java than currently" +
                                 " in use. Class " + classname + " was compiled with ";

                    Integer major = 0;
                    // update the matcher pattern for various jdk
                    Pattern pattern = Pattern.compile("version\\s(\\d+).(\\d+)");
                    Matcher matcher = pattern.matcher(e.getMessage());
                    if (matcher.find()) {
                        major = Integer.parseInt(matcher.group(1));
                    } else {
                        hostLog.info("Unable to parse compile version number from UnsupportedClassVersionError.");
                    }

                    if (VerifyCatalogAndWriteJar.SupportedJavaVersionMap.containsKey(major)) {
                        errorMsg = errorMsg.concat(VerifyCatalogAndWriteJar.SupportedJavaVersionMap.get(major) + ", current runtime version is " +
                                         System.getProperty("java.version") + ".");
                    } else {
                        errorMsg = errorMsg.concat("an incompatible Java version.");
                    }
                    hostLog.info(errorMsg);
                    return errorMsg;
                }
                catch (LinkageError | ClassNotFoundException e) {
                    String cause = e.getMessage();
                    if (cause == null && e.getCause() != null) {
                        cause = e.getCause().getMessage();
                    }
                    errorMsg = "Error loading class \'" + classname + "\': " +
                        e.getClass().getCanonicalName() + " for " + cause;
                    hostLog.info(errorMsg);
                    return errorMsg;
                }
            }
        } catch (Exception e) {
            // catch all exceptions, anything may fail now can be safely rolled back
            return e.getMessage();
        }

        CatalogContext ctx = VoltDB.instance().getCatalogContext();
        Catalog newCatalog = ctx.getNewCatalog(diffCommands);

        Database db = newCatalog.getClusters().get("cluster").getDatabases().get("database");
        CatalogMap<Procedure> catalogProcedures = db.getProcedures();

        int siteCount = m_nodeSettings.getLocalSitesCount() + 1; // + MPI site

        ctx.m_preparedCatalogInfo = new CatalogContext.CatalogInfo(catalogBytes, catalogBytesHash, deploymentBytes);
        ctx.m_preparedCatalogInfo.m_catalog = newCatalog;
        ctx.m_preparedCatalogInfo.m_preparedProcRunners = new ConcurrentLinkedQueue<>();

        for (long i = 0; i < siteCount; i++) {
            try {
                ImmutableMap<String, ProcedureRunner> userProcRunner =
                    LoadedProcedureSet.loadUserProcedureRunners(catalogProcedures, null,
                                                                classesMap.build(), null);

                ctx.m_preparedCatalogInfo.m_preparedProcRunners.offer(userProcRunner);
            } catch (Exception e) {
                String msg = "error setting up user procedure runners using NT-procedure pattern: "
                            + e.getMessage();
                hostLog.info(msg);
                return msg;
            }
        }

        return null;
    }