Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7901059

Add the ability to load custom BCProcessor

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • TBD_Major
    • st4.0
    • tools

      Please add the ability to load custom BCProcessor class.
      Loading by checking System.getProperty() would be okay.

      Code sample:

          protected boolean prepareCheck(MultipleFileReader in, PrintWriter log) {
              if (isValueTracked == null) {
                  isValueTracked = Boolean.TRUE;
              }

              if (EXT_MODE.equals(mode)) {
                  Modifier.VOLATILE.setTracked(true);
              } else {
                  Modifier.VOLATILE.setTracked(false);
              }

              if (mode == null) {
                  mode = SOURCE_MODE;
              }
              MemberType.setMode(BINARY_MODE.equals(mode));

              isOneWayConstantChecking = isValueTracked.booleanValue() && BINARY_MODE.equals(mode) || !isStatic;

              if (SOURCE_MODE.equals(mode) || EXT_MODE.equals(mode)) {
                  isThrowsRemoved = false;
              }

              if (BINARY_MODE.equals(mode)) {
                  isThrowsRemoved = true;
              }
              MemberType.setMode(BINARY_MODE.equals(mode));

              if (isValueTracked.booleanValue() && !in.isFeatureSupported(FeaturesHolder.ConstInfo)) {
                  String errmsg = i18nSt.getString("SignatureTest.mesg.sigfile.noconst");
                  log.println(errmsg);
                  return failed(errmsg);
              }
              // If sigfile doesn't contain constant values, constant checking
              // is impossible
              if (!in.isFeatureSupported(FeaturesHolder.ConstInfo)) {
                  isValueTracked = Boolean.FALSE;
              }

              setConstantValuesTracked(isValueTracked.booleanValue());
      FieldDescr.setConstantValuesTracked(isConstantValuesTracked());
      log.println(i18nSt.getString("SignatureTest.mesg.sigtest.report"));
      log.println(i18nSt.getString("SignatureTest.mesg.sigtest.basevers", in.getApiVersion()));
      log.println(i18nSt.getString("SignatureTest.mesg.sigtest.testvers", apiVersion));

              if (!isThrowsRemoved) {
      log.println(i18nSt.getString("SignatureTest.mesg.sigtest.checkmode.norm", mode));
              } else {
      log.println(i18nSt.getString("SignatureTest.mesg.sigtest.checkmode.removed", mode));
              }

              if (isValueTracked.booleanValue()) {
      log.println(i18nSt.getString("SignatureTest.mesg.sigtest.constcheck", i18nSt.getString("SignatureTest.mesg.sigtest.constcheck.on")));
              } else {
      log.println(i18nSt.getString("SignatureTest.mesg.sigtest.constcheck", i18nSt.getString("SignatureTest.mesg.sigtest.constcheck.off")));
              }

              if (!isTigerFeaturesTracked) {
      log.println(i18nSt.getString("SignatureTest.mesg.sigtest.tigercheck"));
              }

              log.println();

              classpath.printErrors(log);

              trackedClassNames = new HashSet();

              ClassDescriptionLoader loader = getClassDescrLoader();
              setupLoaders(loader, in);
              loader = getClassDescrLoader();

              if (!isValueTracked.booleanValue() && loader instanceof LoadingHints) {
                  ((LoadingHints) loader).addLoadingHint(LoadingHints.DONT_READ_VALUES);
              }

              testableHierarchy = new ClassHierarchyImpl(loader, trackMode);

              testableMCBuilder = new MemberCollectionBuilder(this, "source:testable");

              signatureClassesHierarchy = new ClassHierarchyImpl(in, trackMode);

              String bcProcClassName = System.getProperty("BC_PROC_CLASS");
              Class bcProcClass = BCProcessor.class;
              if (bcProcClassName != null) {
                  bcProcClass = Class.forName(bcProcClassName);
              }


              // creates ErrorFormatter.
              if ((outFormat != null) && FORMAT_PLAIN.equals(outFormat)) {
                  setErrorManager(new ErrorFormatter(log));
              } else if ((outFormat != null) && FORMAT_HUMAN.equals(outFormat)) {
                  setErrorManager(new HumanErrorFormatter(log, isVerbose,
                          reportWarningAsError ? Level.WARNING : Level.SEVERE));
              } else if ((outFormat != null) && FORMAT_BACKWARD.equals(outFormat)) {


                  try {

                      Class[] argTypes = {PrintWriter.class, Boolean.class, Boolean.class,
                              ClassHierarchy.class, ClassHierarchy.class, Level.class, Boolean.class};

                      Object[] args = {log, isVerbose, BINARY_MODE.equals(mode),
                              testableHierarchy, signatureClassesHierarchy,
                              reportWarningAsError ? Level.WARNING : Level.SEVERE, extensibleInterfaces};

                      Constructor c = bcProcClass.getConstructor(argTypes);
                      ErrorFormatter ef = (ErrorFormatter) c.newInstance(args);
                      setErrorManager(ef);

                  } catch (NoSuchMethodException ex) {
                      ex.printStackTrace();
                  } catch (InvocationTargetException e) {
                      e.printStackTrace();
                  } catch (InstantiationException e) {
                      e.printStackTrace();
                  } catch (IllegalAccessException e) {
                      e.printStackTrace();
                  }


              } else {
                  setErrorManager(new SortedErrorFormatter(log, isVerbose));
              }

              return true;
          }

            ersh Mikhail Ershov (Inactive)
            kfertikov Kirill Fertikov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: