Checks for definition errors associated with a given {@link InjectionPoint}
12076
public void validateInjectionPointForDefinitionErrors(InjectionPoint ij, Bean<?> bean, BeanManagerImpl beanManager) {
        if (ij.getAnnotated().getAnnotation(New.class) != null && ij.getQualifiers().size() > 1) {
            throw ValidatorLogger.LOG.newWithQualifiers(ij, Formats.formatAsStackTraceElement(ij));
        }
        if (ij.getType() instanceof TypeVariable<?>) {
            throw ValidatorLogger.LOG.injectionPointWithTypeVariable(ij, Formats.formatAsStackTraceElement(ij));
        }

        // WELD-1739
        if (ij.getMember() instanceof Executable && ij.getAnnotated().isAnnotationPresent(Named.class)
                && ij.getAnnotated().getAnnotation(Named.class).value().equals("")) {

            Executable executable = (Executable) ij.getMember();
            AnnotatedParameter<?> annotatedParameter = (AnnotatedParameter<?>) ij.getAnnotated();

            if (!executable.getParameters()[annotatedParameter.getPosition()].isNamePresent()) {
                // No parameters info available
                throw ValidatorLogger.LOG.nonFieldInjectionPointCannotUseNamed(ij, Formats.formatAsStackTraceElement(ij));
            }
        }

        if (ij.getAnnotated().isAnnotationPresent(Produces.class)) {
            if (bean != null) {
                throw BeanLogger.LOG.injectedFieldCannotBeProducer(ij.getAnnotated(), bean);
            } else {
                throw BeanLogger.LOG.injectedFieldCannotBeProducer(ij.getAnnotated(), Reflections.<AnnotatedField<?>>cast(ij.getAnnotated()).getDeclaringType());
            }
        }
        boolean newBean = (bean instanceof NewBean);
        if (!newBean) {
            checkScopeAnnotations(ij, beanManager.getServices().get(MetaAnnotationStore.class));
        }
        checkFacadeInjectionPoint(ij, Instance.class);
        checkFacadeInjectionPoint(ij, Event.class);

        if (InterceptionFactory.class.equals(Reflections.getRawType(ij.getType())) && !(bean instanceof ProducerMethod<?, ?>)) {
            throw ValidatorLogger.LOG.invalidInterceptionFactoryInjectionPoint(ij, Formats.formatAsStackTraceElement(ij));
        }

        for (PlugableValidator validator : plugableValidators) {
            validator.validateInjectionPointForDefinitionErrors(ij, bean, beanManager);
        }
    }
1313050
private static void validateUIProviderDef(final ProviderDef pluginDef) throws PluginException {
        if (null == pluginDef.getName() || "".equals(pluginDef.getName())) {
            throw new PluginException("UI plugin missing name");
        }
        if (null == pluginDef.getService() || "".equals(pluginDef.getService())) {
            throw new PluginException("UI plugin missing service");
        }
        if (null == pluginDef.getPluginData() || null == pluginDef.getPluginData().get("ui")) {
            throw new PluginException("UI plugin missing ui: definition");
        }

    }
674786
private static void checkValidObject(Path path, AbstractConfigObject reference,
            AbstractConfigObject value,
            List<ConfigException.ValidationProblem> accumulator) {
        for (Map.Entry<String, ConfigValue> entry : reference.entrySet()) {
            String key = entry.getKey();

            Path childPath;
            if (path != null)
                childPath = Path.newKey(key).prepend(path);
            else
                childPath = Path.newKey(key);

            AbstractConfigValue v = value.get(key);
            if (v == null) {
                addMissing(accumulator, entry.getValue(), childPath, value.origin());
            } else {
                checkValid(childPath, entry.getValue(), v, accumulator);
            }
        }
    }
728467
@SuppressWarnings("unchecked")
    private boolean isMethodAlreadyInjectedAnnotationPresent(MethodNode methodNode) {
        AnnotationNode injectedTraceAnnotation = getAnnotation(INJECTED_TRACE_TYPE.getDescriptor(), methodNode.visibleAnnotations);
        AnnotationNode manualTraceAnnotation = getAnnotation(MANUAL_TRACE_TYPE.getDescriptor(), methodNode.visibleAnnotations);
        if (manualTraceAnnotation != null)
            return true;

        if (injectedTraceAnnotation != null) {
            InjectedTraceAnnotationVisitor itav = new InjectedTraceAnnotationVisitor();
            injectedTraceAnnotation.accept(itav);
            List<String> methodAdapters = itav.getMethodAdapters();
            if (methodAdapters.contains(LibertyTracingMethodAdapter.class.getName())) {
                return true;
            }
            if (methodAdapters.contains(WebSphereTrTracingMethodAdapter.class.getName())) {
                return true;
            }
            if (methodAdapters.contains(JSR47TracingMethodAdapter.class.getName())) {
                return true;
            }
        }
        return false;
    }
1350310
static void checkValid(Path path, ConfigValueType referenceType, AbstractConfigValue value,
            List<ConfigException.ValidationProblem> accumulator) {
        if (haveCompatibleTypes(referenceType, value)) {
            if (referenceType == ConfigValueType.LIST && value instanceof SimpleConfigObject) {
                // attempt conversion of indexed object to list
                AbstractConfigValue listValue = DefaultTransformer.transform(value,
                        ConfigValueType.LIST);
                if (!(listValue instanceof SimpleConfigList))
                    addWrongType(accumulator, referenceType, value, path);
            }
        } else {
            addWrongType(accumulator, referenceType, value, path);
        }
    }
75035
protected T checkReturnValue(T instance) {
        if (instance == null && !isDependent()) {
            throw BeanLogger.LOG.nullNotAllowedFromProducer(getProducer(), Formats.formatAsStackTraceElement(getAnnotated().getJavaMember()));
        }
        if (instance == null) {
            InjectionPoint injectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class).peek();
            if (injectionPoint != null) {
                Class<?> injectionPointRawType = Reflections.getRawType(injectionPoint.getType());
                if (injectionPointRawType.isPrimitive()) {
                    return cast(Defaults.getJlsDefaultValue(injectionPointRawType));
                }
            }
        }
        if (instance != null && !(instance instanceof Serializable)) {
            if (beanManager.isPassivatingScope(getScope())) {
                throw BeanLogger.LOG.nonSerializableProductError(getProducer(), Formats.formatAsStackTraceElement(getAnnotated().getJavaMember()));
            }
            InjectionPoint injectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class).peek();
            if (injectionPoint != null && injectionPoint.getBean() != null && Beans.isPassivatingScope(injectionPoint.getBean(), beanManager)) {
                // Transient field is passivation capable injection point
                if (!(injectionPoint.getMember() instanceof Field) || !injectionPoint.isTransient()) {
                    throw BeanLogger.LOG.unserializableProductInjectionError(this, Formats.formatAsStackTraceElement(getAnnotated().getJavaMember()),
                            injectionPoint, Formats.formatAsStackTraceElement(injectionPoint.getMember()));
                }
            }
        }
        return instance;
    }
477752
private void checkCallConventions(NodeTraversal t, Node n) {
    SubclassRelationship relationship =
        compiler.getCodingConvention().getClassesDefinedByCall(n);
    TypedScope scope = t.getTypedScope();
    if (relationship != null) {
      ObjectType superClass =
          TypeValidator.getInstanceOfCtor(
              scope.lookupQualifiedName(QualifiedName.of(relationship.superclassName)));
      ObjectType subClass =
          TypeValidator.getInstanceOfCtor(
              scope.lookupQualifiedName(QualifiedName.of(relationship.subclassName)));
      if (relationship.type == SubclassType.INHERITS
          && superClass != null
          && !superClass.isEmptyType()
          && subClass != null
          && !subClass.isEmptyType()) {
        validator.expectSuperType(n, superClass, subClass);
      }
    }
  }
654912
static void validateExceptions(
      Binder binder,
      Iterable<TypeLiteral<?>> actualExceptionTypes,
      Iterable<Class<? extends Throwable>> expectedExceptionTypes,
      Class<? extends CheckedProvider> checkedProvider) {
    // Validate the exceptions in the method match the exceptions
    // in the CheckedProvider.
    for (TypeLiteral<?> exType : actualExceptionTypes) {
      Class<?> exActual = exType.getRawType();
      // Ignore runtime exceptions & errors.
      if (RuntimeException.class.isAssignableFrom(exActual)
          || Error.class.isAssignableFrom(exActual)) {
        continue;
      }

      boolean notAssignable = true;
      for (Class<? extends Throwable> exExpected : expectedExceptionTypes) {
        if (exExpected.isAssignableFrom(exActual)) {
          notAssignable = false;
          break;
        }
      }
      if (notAssignable) {
        binder.addError(
            "%s is not compatible with the exceptions (%s) declared in "
                + "the CheckedProvider interface (%s)",
            exActual, expectedExceptionTypes, checkedProvider);
      }
    }
  }
44644
private void validateInput() {
        // Check for null values first.
        if (url == null) {
            throw new NullPointerException("URL should not be null");
        }
        if (!url.getProtocol().matches("^https?$")) {
            throw new IllegalArgumentException(
                    "URL protocol should be HTTP or HTTPS");
        }
        if (url.getRef() != null) {
            throw new IllegalArgumentException(
                    "URL should contain no reference");
        }
        if (url.getQuery() != null) {
            throw new IllegalArgumentException(
                    "URL should contain no query string");
        }
        if (handler == null) {
            throw new NullPointerException(
                    "Callback handler should not be null");
        }
    }
1083980
private void validateImplicitCast(Node n, JSDocInfo info) {
    if (!inExterns && info != null && info.isImplicitCast()) {
      report(n, TypeCheck.ILLEGAL_IMPLICIT_CAST);
    }
  }
690896
function validateKeyword(definition, throwError) {
  validateKeyword.errors = null;
  var v = this._validateKeyword = this._validateKeyword
                                  || this.compile(definitionSchema, true);

  if (v(definition)) return true;
  validateKeyword.errors = v.errors;
  if (throwError)
    throw new Error('custom keyword definition is invalid: '  + this.errorsText(v.errors));
  else
    return false;
}
759305
private static void validateScriptProviderDef(final ProviderDef pluginDef) throws PluginException {
        if (null == pluginDef.getName() || "".equals(pluginDef.getName())) {
            throw new PluginException("Script plugin missing name");
        }
        if (null == pluginDef.getService() || "".equals(pluginDef.getService())) {
            throw new PluginException("Script plugin missing service");
        }
        if (null == pluginDef.getScriptFile() || "".equals(pluginDef.getScriptFile())) {
            throw new PluginException("Script plugin missing script-file");
        }

        //make sure service is pluggable service and is script pluggable
        /* final FrameworkSupportService service = framework.getService(pluginDef.getService());
        if (!(service instanceof PluggableService)) {
            throw new PluginException(
                "Service '" + pluginDef.getService() + "' specified for script plugin '" + pluginDef.getName()
                + "' is not valid: unsupported");
        }
        final PluggableService pservice = (PluggableService) service;
        if (!pservice.isScriptPluggable()) {
            throw new PluginException(
                "Service '" + pluginDef.getService() + "' specified for script plugin '" + pluginDef.getName()
                + "' is not valid: unsupported");
        }*/
    }
441635
protected <S extends Serializable> void validateDomainObject(S domainObject, Set<ATError> errors) {
		Set<ConstraintViolation<S>> constraintViolations = validator.validate( domainObject );
		if (CollectionUtils.isEmpty(constraintViolations)) {
			return;
		}
		for ( ConstraintViolation<S> violation : constraintViolations ) {
			String type = violation.getConstraintDescriptor().getAnnotation().annotationType().getSimpleName();
			String attrPath = violation.getPropertyPath().toString();
			String msgKey = attrPath + "." + type;
			if (null != violation.getMessage() && violation.getMessage().startsWith(MSG_KEY_PREFIX)) {
				msgKey = violation.getMessage();
			}
			errors.add(new ATError((attrPath + "." + type), getMessage(msgKey, new Object[]{attrPath}, violation.getMessage()), attrPath));
		}
	}
810938
private void validateEndpoint(String endpoint) {
        try {
            new URL(endpoint);
        } catch (MalformedURLException e) {
            throw new InvalidParameterException(Messages.i18n.format("OrganizationResourceImpl.InvalidEndpointURL")); //$NON-NLS-1$
        }
    }
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());
        }
    }
1031644
public Violation checkInstantiation(
      Collection<TypeVariableSymbol> typeParameters, Collection<Type> typeArguments) {
    return Streams.zip(
            typeParameters.stream(),
            typeArguments.stream(),
            (sym, type) -> {
              if (!hasThreadSafeTypeParameterAnnotation(sym)) {
                return Violation.absent();
              }
              Violation info =
                  isThreadSafeType(
                      /* allowContainerTypeParameters= */ true,
                      /* containerTypeParameters= */ ImmutableSet.of(),
                      type);
              if (!info.isPresent()) {
                return Violation.absent();
              }
              return info.plus(
                  String.format(
                      "instantiation of '%s' is %s", sym, purpose.mutableOrNotThreadSafe()));
            })
        .filter(Violation::isPresent)
        .findFirst()
        .orElse(Violation.absent());
  }
551736
private void validateArgumentValues()  {
        namedArgumentDefinitions = validatePluginArgumentValues(); // trim the list of plugin-derived argument definitions before validation
        for (final NamedArgumentDefinition argumentDefinition : namedArgumentDefinitions) {
            argumentDefinition.validateValues(this);
        }
        if (positionalArgumentDefinition != null) {
            positionalArgumentDefinition.validateValues(this);
        }
    }