Ensures that generate-table-info is set to false if generate-repository-info is set to false.

@param classDef   The class descriptor
@param checkLevel The current check level (this constraint is checked in all levels)
334845
private void ensureNoTableInfoIfNoRepositoryInfo(ClassDescriptorDef classDef, String checkLevel)
    {
        if (!classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_REPOSITORY_INFO, true))
        {
            classDef.setProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, "false");
        }
    }
861084
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity", "checkstyle:nestedifdepth"})
	protected void checkSuperConstructor(
			XtendTypeDeclaration container,
			EStructuralFeature feature,
			Collection<ActionParameterTypes> defaultSignatures) {
		final JvmDeclaredType jvmElement = this.associations.getInferredType(container);
		if (jvmElement != null) {
			final Map<ActionParameterTypes, JvmConstructor> superConstructors =
					CollectionLiterals.newTreeMap((Comparator<ActionParameterTypes>) null);
			final JvmTypeReference typeRef = jvmElement.getExtendedClass();
			final JvmType supertype = (typeRef == null) ? null : typeRef.getType();
			if (supertype instanceof JvmGenericType) {
				final JvmGenericType jvmSuperElement = (JvmGenericType) supertype;
				for (final JvmConstructor superConstructor : jvmSuperElement.getDeclaredConstructors()) {
					final ActionParameterTypes sig = this.sarlActionSignatures.createParameterTypesFromJvmModel(
							superConstructor.isVarArgs(), superConstructor.getParameters());
					superConstructors.put(sig, superConstructor);
				}
			}

			final ActionParameterTypes voidKey = this.sarlActionSignatures.createParameterTypesForVoid();
			//boolean hasDeclaredConstructor = false;

			for (final XtendMember member : container.getMembers()) {
				if (member instanceof SarlConstructor) {
					final SarlConstructor constructor = (SarlConstructor) member;
					//hasDeclaredConstructor = true;
					boolean invokeDefaultConstructor = true;
					final XExpression body = constructor.getExpression();
					if (body instanceof XBlockExpression) {
						final XBlockExpression block = (XBlockExpression) body;
						if (!block.getExpressions().isEmpty()) {
							final XExpression firstStatement = block.getExpressions().get(0);
							if (firstStatement instanceof XConstructorCall || isDelegateConstructorCall(firstStatement)) {
								invokeDefaultConstructor = false;
							}
						}
					} else if (body instanceof XConstructorCall || isDelegateConstructorCall(body)) {
						invokeDefaultConstructor = false;
					}
					if (invokeDefaultConstructor && !superConstructors.containsKey(voidKey)) {
						final List<String> issueData = new ArrayList<>();
						for (final ActionParameterTypes defaultSignature : defaultSignatures) {
							issueData.add(defaultSignature.toString());
						}
						error(Messages.SARLValidator_33,
								member,
								null,
								ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
								MUST_INVOKE_SUPER_CONSTRUCTOR,
								toArray(issueData, String.class));
					}
				}
			}

			// The following code is no more needed because of the constructor inheritance mechanism which
			// is implemented into the JVM model inferrer.
			/*if (!hasDeclaredConstructor) {
				for (final ActionParameterTypes defaultSignature : defaultSignatures) {
					if (!superConstructors.containsKey(defaultSignature)) {
						final List<String> issueData = new ArrayList<>();
						for (final JvmConstructor superConstructor : superConstructors.values()) {
							issueData.add(EcoreUtil.getURI(superConstructor).toString());
							issueData.add(doGetReadableSignature(container.getName(), superConstructor.getParameters()));
						}
						error(Messages.SARLValidator_33,
								container, feature, MISSING_CONSTRUCTOR, toArray(issueData, String.class));
					}
				}
			}*/
		}
	}
35832
@Override
    public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {
        IAnalysisCache analysisCache = Global.getAnalysisCache();

        JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, classDescriptor);
        classContext = analysisCache.getClassAnalysis(ClassContext.class, classDescriptor);

        for (Method m : classContext.getMethodsInCallOrder()) {
            if (m.getCode() == null) {
                continue;
            }
            method = m;

            MethodDescriptor methodDescriptor = BCELUtil.getMethodDescriptor(jclass, method);

            // Try to get MethodGen. If we can't get one,
            // then this method should be skipped.
            MethodGen methodGen = analysisCache.getMethodAnalysis(MethodGen.class, methodDescriptor);
            if (methodGen == null) {
                continue;
            }

            CFG cfg = analysisCache.getMethodAnalysis(CFG.class, methodDescriptor);
            visitMethodCFG(methodDescriptor, cfg);
        }
    }
834262
private void checkModifications(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
    {
        if (CHECKLEVEL_NONE.equals(checkLevel))
        {
            return;
        }

        HashMap              features = new HashMap();
        FeatureDescriptorDef def;

        for (Iterator it = classDef.getFields(); it.hasNext();)
        {
            def = (FeatureDescriptorDef)it.next();
            features.put(def.getName(), def);
        }
        for (Iterator it = classDef.getReferences(); it.hasNext();)
        {
            def = (FeatureDescriptorDef)it.next();
            features.put(def.getName(), def);
        }
        for (Iterator it = classDef.getCollections(); it.hasNext();)
        {
            def = (FeatureDescriptorDef)it.next();
            features.put(def.getName(), def);
        }

        // now checking the modifications
        Properties mods;
        String     modName;
        String     propName;

        for (Iterator it = classDef.getModificationNames(); it.hasNext();)
        {
            modName = (String)it.next();
            if (!features.containsKey(modName))
            {
                throw new ConstraintException("Class "+classDef.getName()+" contains a modification for an unknown feature "+modName);
            }
            def = (FeatureDescriptorDef)features.get(modName);
            if (def.getOriginal() == null)
            {
                throw new ConstraintException("Class "+classDef.getName()+" contains a modification for a feature "+modName+" that is not inherited but defined in the same class");
            }
            // checking modification
            mods = classDef.getModification(modName);
            for (Iterator propIt = mods.keySet().iterator(); propIt.hasNext();)
            {
                propName = (String)propIt.next();
                if (!PropertyHelper.isPropertyAllowed(def.getClass(), propName))
                {
                    throw new ConstraintException("The modification of attribute "+propName+" in class "+classDef.getName()+" is not applicable to the feature "+modName);
                }
            }
        }
    }
1352030
protected void beanDefinitionCheck() {
        for (int i = 0; i < beanDefinitions.size(); i++) {
            for (int j = i + 1; j < beanDefinitions.size(); j++) {
                BeanDefinition b1 = beanDefinitions.get(i);
                BeanDefinition b2 = beanDefinitions.get(j);

                // Two components' id are equal
                if (VerifyUtils.isNotEmpty(b1.getId())
                        && VerifyUtils.isNotEmpty(b2.getId())
                        && b1.getId().equals(b2.getId())) {
                    error("Duplicated bean ID of " + b1.getClassName() + " and " + b2.getClassName());
                }

                if (b1.getClassName().equals(b2.getClassName())) {
                    // Two components' class name are equal, but one of them does not set id.
                    if (VerifyUtils.isEmpty(b1.getId()) || VerifyUtils.isEmpty(b2.getId())) {
                        error("Duplicated class definition. Please set a ID for " + b1.getClassName());
                    } else {
                        // Their id are different, save them to memo.
                        // When the component is injecting by type, throw an exception.
                        errorMemo.add(b1.getClassName());
                    }
                }

                for (String iname1 : b1.getInterfaceNames()) {
                    for (String iname2 : b2.getInterfaceNames()) {
                        if (iname1.equals(iname2)) {
                            // Two components' interface name are equal, but one of them does not set id.
                            if (VerifyUtils.isEmpty(b1.getId()) || VerifyUtils.isEmpty(b2.getId())) {
                                error("Duplicated class definition. Please set a ID for " + b1.getClassName());
                            } else {
                                // Their id are different, save them to memo.
                                // When the component is injecting by type, throw an exception.
                                errorMemo.add(iname1);
                            }
                        }
                    }
                }

            }
        }
    }
206812
@Check(CheckType.NORMAL)
	@Override
	@SuppressWarnings("checkstyle:npathcomplexity")
	public void checkClassPath(XtendFile sarlScript) {
		final TypeReferences typeReferences = getServices().getTypeReferences();

		if (!Utils.isCompatibleJREVersion()) {
			error(
					MessageFormat.format(
							Messages.SARLValidator_3,
							System.getProperty("java.specification.version"), //$NON-NLS-1$
							SARLVersion.MINIMAL_JDK_VERSION,
							SARLVersion.MAXIMAL_JDK_VERSION),
					sarlScript,
					XtendPackage.Literals.XTEND_FILE__PACKAGE,
					JDK_NOT_ON_CLASSPATH);
		} else {
			final GeneratorConfig generatorConfiguration = getGeneratorConfig(sarlScript);
			final JavaVersion generatorVersion = generatorConfiguration.getJavaSourceVersion();
			if (generatorVersion == null
					|| !Utils.isCompatibleJREVersion(generatorVersion.getQualifier())) {
				error(
						MessageFormat.format(
								Messages.SARLValidator_4,
								generatorVersion,
								SARLVersion.MINIMAL_JDK_VERSION,
								SARLVersion.MAXIMAL_JDK_VERSION),
						sarlScript,
						XtendPackage.Literals.XTEND_FILE__PACKAGE,
						JDK_NOT_ON_CLASSPATH);
			}
		}

		if (!Utils.isCompatibleXtextVersion()) {
			error(
					MessageFormat.format(
							Messages.SARLValidator_5,
							XtextVersion.getCurrent(),
							SARLVersion.MINIMAL_XTEXT_VERSION),
					sarlScript,
					XtendPackage.Literals.XTEND_FILE__PACKAGE,
					XBASE_LIB_NOT_ON_CLASSPATH);
		} else {
			final JvmType type = typeReferences.findDeclaredType(ToStringBuilder.class.getName(), sarlScript);
			if (type == null) {
				error(
						MessageFormat.format(
								Messages.SARLValidator_6,
								SARLVersion.MINIMAL_XTEXT_VERSION),
						sarlScript,
						XtendPackage.Literals.XTEND_FILE__PACKAGE,
						XBASE_LIB_NOT_ON_CLASSPATH);
			}
		}

		final OutParameter<String> sarlLibraryVersion = new OutParameter<>();
		final SarlLibraryErrorCode errorCode = Utils.getSARLLibraryVersionOnClasspath(typeReferences, sarlScript, sarlLibraryVersion);
		if (errorCode != SarlLibraryErrorCode.SARL_FOUND) {
			final ResourceSet resourceSet = EcoreUtil2.getResourceSet(sarlScript);
			final StringBuilder classPath = new StringBuilder();
			for (final Resource resource : resourceSet.getResources()) {
				classPath.append(resource.getURI().toString());
				classPath.append("\n"); //$NON-NLS-1$
			}
			final StringBuilder fields = new StringBuilder();
			try {
				final JvmDeclaredType type = (JvmDeclaredType) typeReferences.findDeclaredType(SARLVersion.class, sarlScript);
				for (final JvmField field : type.getDeclaredFields()) {
					fields.append(field.getIdentifier());
					fields.append(" / "); //$NON-NLS-1$
					fields.append(field.getSimpleName());
					fields.append("\n"); //$NON-NLS-1$
				}
			} catch (Exception e) {
				//
			}
			if (fields.length() == 0) {
				for (final Field field : SARLVersion.class.getDeclaredFields()) {
					fields.append(field.getName());
					fields.append("\n"); //$NON-NLS-1$
				}
			}
			error(
					MessageFormat.format(Messages.SARLValidator_7, errorCode.name(), classPath.toString(), fields.toString()),
					sarlScript,
					XtendPackage.Literals.XTEND_FILE__PACKAGE,
					SARL_LIB_NOT_ON_CLASSPATH);
		} else if (!Utils.isCompatibleSARLLibraryVersion(sarlLibraryVersion.get())) {
			error(
					MessageFormat.format(Messages.SARLValidator_8,
							sarlLibraryVersion.get(), SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING),
					sarlScript,
					XtendPackage.Literals.XTEND_FILE__PACKAGE,
					INVALID_SARL_LIB_ON_CLASSPATH);
		}
	}
817212
public void check(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
    {
        ensureNoTableInfoIfNoRepositoryInfo(classDef, checkLevel);
        checkModifications(classDef, checkLevel);
        checkExtents(classDef, checkLevel);
        ensureTableIfNecessary(classDef, checkLevel);
        checkFactoryClassAndMethod(classDef, checkLevel);
        checkInitializationMethod(classDef, checkLevel);
        checkPrimaryKey(classDef, checkLevel);
        checkProxyPrefetchingLimit(classDef, checkLevel);
        checkRowReader(classDef, checkLevel);
        checkObjectCache(classDef, checkLevel);
        checkProcedures(classDef, checkLevel);
    }
496313
private void checkPrimaryKey(ClassDescriptorDef classDef, String checkLevel) throws ConstraintException
    {
        if (CHECKLEVEL_NONE.equals(checkLevel))
        {
            return;
        }

        if (classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_TABLE_INFO, true) &&
            classDef.getPrimaryKeys().isEmpty())
        {
            LogHelper.warn(true,
                           getClass(),
                           "checkPrimaryKey",
                           "The class "+classDef.getName()+" has no primary key");
        }
    }
1247870
@Override
    public void visitClassDef(JCClassDecl tree) {
        if (tree.sym.owner.kind == PCK) {
            //analyze class
            tree = analyzer.analyzeAndPreprocessClass(tree);
        }
        KlassInfo prevKlassInfo = kInfo;
        try {
            kInfo = new KlassInfo(tree);
            super.visitClassDef(tree);
            if (!kInfo.deserializeCases.isEmpty()) {
                int prevPos = make.pos;
                try {
                    make.at(tree);
                    kInfo.addMethod(makeDeserializeMethod(tree.sym));
                } finally {
                    make.at(prevPos);
                }
            }
            //add all translated instance methods here
            List<JCTree> newMethods = kInfo.appendedMethodList.toList();
            tree.defs = tree.defs.appendList(newMethods);
            for (JCTree lambda : newMethods) {
                tree.sym.members().enter(((JCMethodDecl)lambda).sym);
            }
            result = tree;
        } finally {
            kInfo = prevKlassInfo;
        }
    }
211154
private void verify() {
        // Copy table defs to avoid ConcurrentModificationException if we add a table.
        List<TableDefinition> definedTables = new ArrayList<>(m_tableMap.values());
        for (TableDefinition tableDef : definedTables) {
            // Copy field defs for same reason
            List<FieldDefinition> definedFields = new ArrayList<>(tableDef.getFieldDefinitions());
            for (FieldDefinition fieldDef : definedFields) {
                if (fieldDef.isLinkType()) {
                    verifyLink(tableDef, fieldDef);
                }
            }
        }
    }
778369
public void check(ModelDef modelDef, String checkLevel) throws ConstraintException
    {
        ensureReferencedKeys(modelDef, checkLevel);
        checkReferenceForeignkeys(modelDef, checkLevel);
        checkCollectionForeignkeys(modelDef, checkLevel);
        checkKeyModifications(modelDef, checkLevel);
    }
306426
static String generateCheckInitializer(
            final String className,
            final String checkName,
            final String fieldName,
            final String annotationTypeName) {
        return checkName + ".configure(\n"
                + className + ".class.getDeclaredField(\"" + fieldName + "\")\n"
                + ".getDeclaredAnnotation(" + annotationTypeName + ".class));\n";
    }
1165195
private void checkAllTables() throws SQLException {
		logger.entering(CLASSNAME, "checkAllTables");

		createIfNotExists(CHECKPOINTDATA_TABLE, CREATE_TAB_CHECKPOINTDATA);
		executeStatement(CREATE_CHECKPOINTDATA_INDEX);
		createIfNotExists(JOBINSTANCEDATA_TABLE, CREATE_TAB_JOBINSTANCEDATA);

		createIfNotExists(EXECUTIONINSTANCEDATA_TABLE,
				CREATE_TAB_EXECUTIONINSTANCEDATA);
		createIfNotExists(STEPEXECUTIONINSTANCEDATA_TABLE,
				CREATE_TAB_STEPEXECUTIONINSTANCEDATA);

		createIfNotExists(JOBSTATUS_TABLE, CREATE_TAB_JOBSTATUS);
		createIfNotExists(STEPSTATUS_TABLE, CREATE_TAB_STEPSTATUS);	

		logger.exiting(CLASSNAME, "checkAllTables");
	}
523829
public void check()
    {
        //
        // Find the nearest @ControlInterface, which is where the relevant control checker
        // annotation will be found.
        //

        AptControlInterface mostDerived = (AptControlInterface) getMostDerivedInterface();
        if ( mostDerived == null )
            return;

        InterfaceDeclaration intfDecl = mostDerived._intfDecl;

        if ( intfDecl == null )
            return;

        AnnotationMirror controlMirror = null;

        for (AnnotationMirror annot : intfDecl.getAnnotationMirrors())
        {
            if (annot.getAnnotationType().getDeclaration().getQualifiedName().equals(
                    "org.apache.beehive.controls.api.bean.ControlInterface"))
            {
                controlMirror = annot;
                break;
            }
        }

        assert ( controlMirror != null ) : "Found a control interface that isn't annotated properly: " + intfDecl;

        AptAnnotationHelper controlAnnot = new AptAnnotationHelper(controlMirror);

        //
        // Read the name of the checker class from the @ControlInterface annotation,
        // dynamically load and run it.
        //

        DeclaredType checkerMirror = (DeclaredType)controlAnnot.getObjectValue("checker");
        if ( checkerMirror == null )
        {
            // try the deprecated 'checkerClass' attribute
            checkerMirror = (DeclaredType)controlAnnot.getObjectValue("checkerClass");
        }

        if ( checkerMirror != null && checkerMirror.getDeclaration() != null )
        {
            // TODO: optimize to not invoke default checker?
            String checkerName = checkerMirror.toString();

            try
            {
                ClassLoader loader = getExternalClassLoader();

                Class checkerClass = loader.loadClass( checkerName );
                if ( !ControlChecker.class.isAssignableFrom(checkerClass) )
                {
                    _ap.printError( intfDecl, "control.interface.illegal.checker", intfDecl.getSimpleName(), checkerName );
                }
                else
                {

                    Constructor ctor = checkerClass.getConstructor();

                    ControlChecker checker = (ControlChecker) ctor.newInstance();
                    CheckerAnnotationProcessorEnvironmentImpl ape =
                            new CheckerAnnotationProcessorEnvironmentImpl(_ap);
                    checker.check( _intfDecl, ape );
                }
            }
            catch ( Exception e ) {
                _ap.printError( intfDecl, "control.interface.checker.load.failed", intfDecl.getSimpleName(), checkerName );
            }
        }
    }
602686
public void checkDataBase(boolean autoRepair)
   {
      SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);

      Connection jdbcConn = null;
      try
      {
         jdbcConn = jdbcDataContainer.getConnectionFactory().getJdbcConnection();

         for (InspectionQuery query : itemsInspectionQuery)
         {
            PreparedStatement st = null;
            ResultSet resultSet = null;
            try
            {
               st = jdbcConn.prepareStatement(query.getStatement());

               resultSet = st.executeQuery();
               if (resultSet.next())
               {
                  logDescription(query.getDescription());

                  do
                  {
                     logBrokenObjectAndSetInconsistency(getBrokenObject(resultSet, query.getFieldNames()));
                     if (autoRepair)
                     {
                        try
                        {
                           query.getRepair().doRepair(resultSet);
                           logComment("Inconsistency has been fixed");
                        }
                        catch (SQLException e)
                        {
                           logExceptionAndSetInconsistency("Inconsistency can not been fixed", e);
                        }
                     }
                  }
                  while (resultSet.next());
               }
            }
            finally
            {
               JDBCUtils.freeResources(resultSet, st, null);
            }
         }
      }
      catch (SQLException e)
      {
         logExceptionAndSetInconsistency("Unexpected exception during DB checking.", e);
      }
      catch (RepositoryException e)
      {
         logExceptionAndSetInconsistency("Unexpected exception during DB checking.", e);
      }
      finally
      {
         JDBCUtils.freeResources(null, null, jdbcConn);
      }
   }
919461
private static boolean mightInheritFromException(ClassDescriptor d) {
        while (d != null) {
            try {
                if ("java.lang.Exception".equals(d.getDottedClassName())) {
                    return true;
                }
                XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, d);
                d = classNameAndInfo.getSuperclassDescriptor();
            } catch (CheckedAnalysisException e) {
                return true; // don't know
            }
        }
        return false;
    }
292277
static void checkMethodDesc(final String desc) {
        if (desc == null || desc.length() == 0) {
            throw new IllegalArgumentException(
                    "Invalid method descriptor (must not be null or empty)");
        }
        if (desc.charAt(0) != '(' || desc.length() < 3) {
            throw new IllegalArgumentException("Invalid descriptor: " + desc);
        }
        int start = 1;
        if (desc.charAt(start) != ')') {
            do {
                if (desc.charAt(start) == 'V') {
                    throw new IllegalArgumentException("Invalid descriptor: "
                            + desc);
                }
                start = checkDesc(desc, start, false);
            } while (start < desc.length() && desc.charAt(start) != ')');
        }
        start = checkDesc(desc, start + 1, true);
        if (start != desc.length()) {
            throw new IllegalArgumentException("Invalid descriptor: " + desc);
        }
    }