Java Code Examples for java.util.EnumSet#containsAll()

The following examples show how to use java.util.EnumSet#containsAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeAzureFileSystem.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public FSDataOutputStream createNonRecursive(Path f, FsPermission permission,
    EnumSet<CreateFlag> flags, int bufferSize, short replication, long blockSize,
    Progressable progress) throws IOException {

  // Check if file should be appended or overwritten. Assume that the file
  // is overwritten on if the CREATE and OVERWRITE create flags are set. Note
  // that any other combinations of create flags will result in an open new or
  // open with append.
  final EnumSet<CreateFlag> createflags =
      EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE);
  boolean overwrite = flags.containsAll(createflags);

  // Delegate the create non-recursive call.
  return this.createNonRecursive(f, permission, overwrite,
      bufferSize, replication, blockSize, progress);
}
 
Example 2
Source File: NativeAzureFileSystem.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public FSDataOutputStream createNonRecursive(Path f, FsPermission permission,
    EnumSet<CreateFlag> flags, int bufferSize, short replication, long blockSize,
    Progressable progress) throws IOException {

  // Check if file should be appended or overwritten. Assume that the file
  // is overwritten on if the CREATE and OVERWRITE create flags are set. Note
  // that any other combinations of create flags will result in an open new or
  // open with append.
  final EnumSet<CreateFlag> createflags =
      EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE);
  boolean overwrite = flags.containsAll(createflags);

  // Delegate the create non-recursive call.
  return this.createNonRecursive(f, permission, overwrite,
      bufferSize, replication, blockSize, progress);
}
 
Example 3
Source File: MobileServiceTableBase.java    From azure-mobile-apps-android-client with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the system properties header value from the
 * MobileServiceSystemProperties.
 *
 * @param properties The system properties to set in the system properties header.
 * @return The system properties header value. Returns null if properties is
 * null or empty.
 */
private static String getSystemPropertiesString(EnumSet<MobileServiceSystemProperty> properties) {
    if (properties == null || properties.isEmpty()) {
        return null;
    }

    if (properties.containsAll(EnumSet.allOf(MobileServiceSystemProperty.class))) {
        return "*";
    }

    StringBuilder sb = new StringBuilder();

    int i = 0;

    for (MobileServiceSystemProperty systemProperty : properties) {
        sb.append(getSystemPropertyString(systemProperty));

        i++;

        if (i < properties.size()) {
            sb.append(",");
        }
    }

    return sb.toString();
}
 
Example 4
Source File: Historian.java    From ICS-TestBed-Framework with GNU General Public License v3.0 5 votes vote down vote up
public ValidationResult onValidate(Cert certificate, ApplicationDescription applicationDescription,
                                   EnumSet<CertificateCheck> passedChecks) {
    System.out.println("Validating Server Certificate...");
    if (passedChecks.containsAll(CertificateCheck.COMPULSORY)) {
        System.out.println("Server Certificate is valid and trusted, accepting certificate!");
        return ValidationResult.AcceptPermanently;
    } else {
        System.out.println("Certificate Details: " + certificate.getCertificate().toString());
        System.out.println("Do you want to accept this certificate?\n" + " (A=Always, Y=Yes, this time, N=No)");
        while (true) {
            try {
                char c;
                c = Character.toLowerCase((char) System.in.read());
                if (c == 'a') {
                    return ValidationResult.AcceptPermanently;
                }
                if (c == 'y') {
                    return ValidationResult.AcceptOnce;
                }
                if (c == 'n') {
                    return ValidationResult.Reject;
                }
            } catch (IOException e) {
                System.out.println("Error reading input! Not accepting certificate.");
                return ValidationResult.Reject;
            }
        }
    }
}
 
Example 5
Source File: Warn5.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
void check() {

        EnumSet<WarningKind> expectedWarnings =
                EnumSet.noneOf(WarningKind.class);

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                suppressLevel != SuppressLevel.VARARGS &&
                xlint != XlintOption.NONE &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                body.hasAliasing &&
                (methKind == MethodKind.CONSTRUCTOR ||
                (methKind == MethodKind.METHOD &&
                modKind != ModifierKind.NONE))) {
            expectedWarnings.add(WarningKind.UNSAFE_BODY);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.DONT_TRUST &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                xlint == XlintOption.ALL) {
            expectedWarnings.add(WarningKind.UNSAFE_DECL);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                (!sig.isVarargs ||
                (modKind == ModifierKind.NONE &&
                methKind == MethodKind.METHOD))) {
            expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                xlint != XlintOption.NONE &&
                suppressLevel != SuppressLevel.VARARGS &&
                (modKind != ModifierKind.NONE ||
                methKind == MethodKind.CONSTRUCTOR) &&
                sig.isVarargs &&
                sig.isReifiableArg) {
            expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
        }

        if (!expectedWarnings.containsAll(dc.warnings) ||
                !dc.warnings.containsAll(expectedWarnings)) {
            throw new Error("invalid diagnostics for source:\n" +
                    source.getCharContent(true) +
                    "\nOptions: " + xlint.getXlintOption() +
                    "\nExpected warnings: " + expectedWarnings +
                    "\nFound warnings: " + dc.warnings);
        }
    }
 
Example 6
Source File: Warn5.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void check() {

        EnumSet<WarningKind> expectedWarnings =
                EnumSet.noneOf(WarningKind.class);

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                suppressLevel != SuppressLevel.VARARGS &&
                xlint != XlintOption.NONE &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                body.hasAliasing &&
                (methKind == MethodKind.CONSTRUCTOR ||
                (methKind == MethodKind.METHOD &&
                modKind != ModifierKind.NONE))) {
            expectedWarnings.add(WarningKind.UNSAFE_BODY);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.DONT_TRUST &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                xlint == XlintOption.ALL) {
            expectedWarnings.add(WarningKind.UNSAFE_DECL);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                (!sig.isVarargs ||
                (modKind == ModifierKind.NONE &&
                methKind == MethodKind.METHOD))) {
            expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                xlint != XlintOption.NONE &&
                suppressLevel != SuppressLevel.VARARGS &&
                (modKind != ModifierKind.NONE ||
                methKind == MethodKind.CONSTRUCTOR) &&
                sig.isVarargs &&
                sig.isReifiableArg) {
            expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
        }

        if (!expectedWarnings.containsAll(dc.warnings) ||
                !dc.warnings.containsAll(expectedWarnings)) {
            throw new Error("invalid diagnostics for source:\n" +
                    source.getCharContent(true) +
                    "\nOptions: " + xlint.getXlintOption() +
                    "\nExpected warnings: " + expectedWarnings +
                    "\nFound warnings: " + dc.warnings);
        }
    }
 
Example 7
Source File: Warn5.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void check() {

        EnumSet<WarningKind> expectedWarnings =
                EnumSet.noneOf(WarningKind.class);

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                suppressLevel != SuppressLevel.VARARGS &&
                xlint != XlintOption.NONE &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                body.hasAliasing &&
                (methKind == MethodKind.CONSTRUCTOR ||
                (methKind == MethodKind.METHOD &&
                modKind != ModifierKind.NONE))) {
            expectedWarnings.add(WarningKind.UNSAFE_BODY);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.DONT_TRUST &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                xlint == XlintOption.ALL) {
            expectedWarnings.add(WarningKind.UNSAFE_DECL);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                (!sig.isVarargs ||
                (modKind == ModifierKind.NONE &&
                methKind == MethodKind.METHOD))) {
            expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                xlint != XlintOption.NONE &&
                suppressLevel != SuppressLevel.VARARGS &&
                (modKind != ModifierKind.NONE ||
                methKind == MethodKind.CONSTRUCTOR) &&
                sig.isVarargs &&
                sig.isReifiableArg) {
            expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
        }

        if (!expectedWarnings.containsAll(dc.warnings) ||
                !dc.warnings.containsAll(expectedWarnings)) {
            throw new Error("invalid diagnostics for source:\n" +
                    source.getCharContent(true) +
                    "\nOptions: " + xlint.getXlintOption() +
                    "\nExpected warnings: " + expectedWarnings +
                    "\nFound warnings: " + dc.warnings);
        }
    }
 
Example 8
Source File: Warn5.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void check() {

        EnumSet<WarningKind> expectedWarnings =
                EnumSet.noneOf(WarningKind.class);

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                suppressLevel != SuppressLevel.VARARGS &&
                xlint != XlintOption.NONE &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                body.hasAliasing &&
                (methKind == MethodKind.CONSTRUCTOR ||
                (methKind == MethodKind.METHOD &&
                modKind != ModifierKind.NONE))) {
            expectedWarnings.add(WarningKind.UNSAFE_BODY);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.DONT_TRUST &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                xlint == XlintOption.ALL) {
            expectedWarnings.add(WarningKind.UNSAFE_DECL);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                (!sig.isVarargs ||
                (modKind == ModifierKind.NONE &&
                methKind == MethodKind.METHOD))) {
            expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                xlint != XlintOption.NONE &&
                suppressLevel != SuppressLevel.VARARGS &&
                (modKind != ModifierKind.NONE ||
                methKind == MethodKind.CONSTRUCTOR) &&
                sig.isVarargs &&
                sig.isReifiableArg) {
            expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
        }

        if (!expectedWarnings.containsAll(dc.warnings) ||
                !dc.warnings.containsAll(expectedWarnings)) {
            throw new Error("invalid diagnostics for source:\n" +
                    source.getCharContent(true) +
                    "\nOptions: " + xlint.getXlintOption() +
                    "\nExpected warnings: " + expectedWarnings +
                    "\nFound warnings: " + dc.warnings);
        }
    }
 
Example 9
Source File: Implementation.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns true if the given scope is adequate for analyzing this issue.
 * This looks through the analysis scopes (see
 * {@link #getAnalysisScopes()}) and if the scope passed in fully
 * covers at least one of them, or if it covers the scope of the issue
 * itself (see {@link #getScope()}, which should be a superset of all the
 * analysis scopes) returns true.
 * <p>
 * The scope set returned by {@link #getScope()} lists all the various
 * scopes that are <b>affected</b> by this issue, meaning the detector
 * should consider it. Frequently, the detector must analyze all these
 * scopes in order to properly decide whether an issue is found. For
 * example, the unused resource detector needs to consider both the XML
 * resource files and the Java source files in order to decide if a resource
 * is unused. If it analyzes just the Java files for example, it might
 * incorrectly conclude that a resource is unused because it did not
 * discover a resource reference in an XML file.
 * <p>
 * However, there are other issues where the issue can occur in a variety of
 * files, but the detector can consider each in isolation. For example, the
 * API checker is affected by both XML files and Java class files (detecting
 * both layout constructor references in XML layout files as well as code
 * references in .class files). It doesn't have to analyze both; it is
 * capable of incrementally analyzing just an XML file, or just a class
 * file, without considering the other.
 * <p>
 * An issue can register additional scope sets that can are adequate
 * for analyzing the issue, by supplying it to
 * {@link #Implementation(Class, java.util.EnumSet, java.util.EnumSet[])}.
 * This method returns true if the given scope matches one or more analysis
 * scope, or the overall scope.
 *
 * @param scope the scope available for analysis
 * @return true if this issue can be analyzed with the given available scope
 */
public boolean isAdequate(@NonNull EnumSet<Scope> scope) {
    if (scope.containsAll(mScope)) {
        return true;
    }

    if (mAnalysisScopes != null) {
        for (EnumSet<Scope> analysisScope : mAnalysisScopes) {
            if (scope.containsAll(analysisScope)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 10
Source File: Warn5.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void check(Result<?> res) {

        EnumSet<WarningKind> foundWarnings = EnumSet.noneOf(WarningKind.class);
        for (Diagnostic.Kind kind : new Kind[] { Kind.ERROR, Kind.MANDATORY_WARNING, Kind.WARNING}) {
            for (Diagnostic<? extends JavaFileObject> diag : res.diagnosticsForKind(kind)) {
                for (WarningKind wk : WarningKind.values()) {
                    if (wk.code.equals(diag.getCode())) {
                        foundWarnings.add(wk);
                    }
                }
            }
        }

        EnumSet<WarningKind> expectedWarnings =
                EnumSet.noneOf(WarningKind.class);

        if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
                trustMe == TrustMe.TRUST &&
                suppressLevel != SuppressLevel.VARARGS &&
                xlint != XlintOption.NONE &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                body.hasAliasing &&
                (methKind == MethodKind.CONSTRUCTOR ||
                (methKind == MethodKind.METHOD &&
                 modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
                 (modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0)))) {
            expectedWarnings.add(WarningKind.UNSAFE_BODY);
        }

        if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
                trustMe == TrustMe.DONT_TRUST &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                xlint == XlintOption.ALL) {
            expectedWarnings.add(WarningKind.UNSAFE_DECL);
        }

        if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
                trustMe == TrustMe.TRUST &&
                (!sig.isVarargs ||
                 ((modKind == ModifierKind.NONE ||
                 modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) < 0 ) &&
                 methKind == MethodKind.METHOD))) {
            expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
        }

        if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 &&
                trustMe == TrustMe.TRUST &&
                xlint != XlintOption.NONE &&
                suppressLevel != SuppressLevel.VARARGS &&
                (modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC ||
                 (modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0) ||
                 methKind == MethodKind.CONSTRUCTOR) &&
                sig.isVarargs &&
                sig.isReifiableArg) {
            expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
        }

        if (!expectedWarnings.containsAll(foundWarnings) ||
                !foundWarnings.containsAll(expectedWarnings)) {
            fail("invalid diagnostics for source:\n" +
                    res.compilationInfo() +
                    "\nOptions: " + xlint.getXlintOption() +
                    "\nSource Level: " + sourceLevel +
                    "\nExpected warnings: " + expectedWarnings +
                    "\nFound warnings: " + foundWarnings);
        }
    }
 
Example 11
Source File: OraOopOracleQueries.java    From aliyun-maxcompute-data-collectors with Apache License 2.0 4 votes vote down vote up
private static List<OracleTable> getTables(Connection connection,
    String owner, String tableName, TableNameQueryType tableNameQueryType)
    throws SQLException {

  EnumSet<GetTablesOptions> options = EnumSet.noneOf(GetTablesOptions.class);

  if (owner != null && !owner.isEmpty()) {
    options.add(GetTablesOptions.Owner);
  }

  if (tableName != null && !tableName.isEmpty()) {
    options.add(GetTablesOptions.Table);
  }

  String sql =
      "SELECT owner, table_name " + " FROM dba_tables" + " %s %s %s %s "
          + " ORDER BY owner, table_name";

  String tableComparitor = null;
  switch (tableNameQueryType) {
    case Equals:
      tableComparitor = "=";
      break;
    case Like:
      tableComparitor = "LIKE";
      break;
    default:
      throw new RuntimeException("Operator not implemented.");
  }

  sql =
      String.format(sql, options.isEmpty() ? "" : "WHERE", options
          .contains(GetTablesOptions.Owner) ? "owner = ?" : "", options
          .containsAll(EnumSet.of(GetTablesOptions.Owner,
              GetTablesOptions.Table)) ? "AND" : "", options
          .contains(GetTablesOptions.Table) ? String.format(
          "table_name %s ?", tableComparitor) : "");

  PreparedStatement statement = connection.prepareStatement(sql);

  if (options.containsAll(EnumSet.of(GetTablesOptions.Owner,
      GetTablesOptions.Table))) {
    statement.setString(1, owner);
    statement.setString(2, tableName);
  } else {
    if (options.contains(GetTablesOptions.Owner)) {
      statement.setString(1, owner);
    } else if (options.contains(GetTablesOptions.Table)) {
      statement.setString(1, tableName);
    }
  }

  ResultSet resultSet = statement.executeQuery();

  ArrayList<OracleTable> result = new ArrayList<OracleTable>();
  while (resultSet.next()) {
    result.add(new OracleTable(resultSet.getString("owner"), resultSet
        .getString("table_name")));
  }

  resultSet.close();
  statement.close();

  return result;
}
 
Example 12
Source File: Warn5.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
void check() {

        EnumSet<WarningKind> expectedWarnings =
                EnumSet.noneOf(WarningKind.class);

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                suppressLevel != SuppressLevel.VARARGS &&
                xlint != XlintOption.NONE &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                body.hasAliasing &&
                (methKind == MethodKind.CONSTRUCTOR ||
                (methKind == MethodKind.METHOD &&
                modKind != ModifierKind.NONE))) {
            expectedWarnings.add(WarningKind.UNSAFE_BODY);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.DONT_TRUST &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                xlint == XlintOption.ALL) {
            expectedWarnings.add(WarningKind.UNSAFE_DECL);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                (!sig.isVarargs ||
                (modKind == ModifierKind.NONE &&
                methKind == MethodKind.METHOD))) {
            expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                xlint != XlintOption.NONE &&
                suppressLevel != SuppressLevel.VARARGS &&
                (modKind != ModifierKind.NONE ||
                methKind == MethodKind.CONSTRUCTOR) &&
                sig.isVarargs &&
                sig.isReifiableArg) {
            expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
        }

        if (!expectedWarnings.containsAll(dc.warnings) ||
                !dc.warnings.containsAll(expectedWarnings)) {
            throw new Error("invalid diagnostics for source:\n" +
                    source.getCharContent(true) +
                    "\nOptions: " + xlint.getXlintOption() +
                    "\nExpected warnings: " + expectedWarnings +
                    "\nFound warnings: " + dc.warnings);
        }
    }
 
Example 13
Source File: Warn5.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void check() {

        EnumSet<WarningKind> expectedWarnings =
                EnumSet.noneOf(WarningKind.class);

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                suppressLevel != SuppressLevel.VARARGS &&
                xlint != XlintOption.NONE &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                body.hasAliasing &&
                (methKind == MethodKind.CONSTRUCTOR ||
                (methKind == MethodKind.METHOD &&
                modKind != ModifierKind.NONE))) {
            expectedWarnings.add(WarningKind.UNSAFE_BODY);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.DONT_TRUST &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                xlint == XlintOption.ALL) {
            expectedWarnings.add(WarningKind.UNSAFE_DECL);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                (!sig.isVarargs ||
                (modKind == ModifierKind.NONE &&
                methKind == MethodKind.METHOD))) {
            expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                xlint != XlintOption.NONE &&
                suppressLevel != SuppressLevel.VARARGS &&
                (modKind != ModifierKind.NONE ||
                methKind == MethodKind.CONSTRUCTOR) &&
                sig.isVarargs &&
                sig.isReifiableArg) {
            expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
        }

        if (!expectedWarnings.containsAll(dc.warnings) ||
                !dc.warnings.containsAll(expectedWarnings)) {
            throw new Error("invalid diagnostics for source:\n" +
                    source.getCharContent(true) +
                    "\nOptions: " + xlint.getXlintOption() +
                    "\nExpected warnings: " + expectedWarnings +
                    "\nFound warnings: " + dc.warnings);
        }
    }
 
Example 14
Source File: Warn5.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
void check() {

        EnumSet<WarningKind> expectedWarnings =
                EnumSet.noneOf(WarningKind.class);

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                suppressLevel != SuppressLevel.VARARGS &&
                xlint != XlintOption.NONE &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                body.hasAliasing &&
                (methKind == MethodKind.CONSTRUCTOR ||
                (methKind == MethodKind.METHOD &&
                modKind != ModifierKind.NONE))) {
            expectedWarnings.add(WarningKind.UNSAFE_BODY);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.DONT_TRUST &&
                sig.isVarargs &&
                !sig.isReifiableArg &&
                xlint == XlintOption.ALL) {
            expectedWarnings.add(WarningKind.UNSAFE_DECL);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                (!sig.isVarargs ||
                (modKind == ModifierKind.NONE &&
                methKind == MethodKind.METHOD))) {
            expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
        }

        if (sourceLevel == SourceLevel.JDK_7 &&
                trustMe == TrustMe.TRUST &&
                xlint != XlintOption.NONE &&
                suppressLevel != SuppressLevel.VARARGS &&
                (modKind != ModifierKind.NONE ||
                methKind == MethodKind.CONSTRUCTOR) &&
                sig.isVarargs &&
                sig.isReifiableArg) {
            expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
        }

        if (!expectedWarnings.containsAll(dc.warnings) ||
                !dc.warnings.containsAll(expectedWarnings)) {
            throw new Error("invalid diagnostics for source:\n" +
                    source.getCharContent(true) +
                    "\nOptions: " + xlint.getXlintOption() +
                    "\nExpected warnings: " + expectedWarnings +
                    "\nFound warnings: " + dc.warnings);
        }
    }
 
Example 15
Source File: App.java    From para with Apache License 2.0 4 votes vote down vote up
private boolean isAllowAllPermission(EnumSet<AllowedMethods> permission) {
	return permission != null && (permission.containsAll(ALL) || permission.contains(READ_WRITE) ||	// * || rw = *
				(permission.contains(READ_ONLY) && permission.contains(WRITE_ONLY)) ||				//   r + w = *
				(permission.contains(GET) && permission.contains(WRITE_ONLY)));						//   r + w = *
}