Esempio n. 1
0
  private void checkForBrokenFieldAccess(
      CheckerState state,
      Artifact artifact,
      DeclaredClass clazz,
      DeclaredMethod method,
      ImmutableList.Builder<Conflict> builder) {
    for (AccessedField field : method.fieldAccesses()) {
      final ClassTypeDescriptor owningClass = field.owner();
      final DeclaredClass calledClass = state.knownClasses().get(owningClass);

      DeclaredField declaredField =
          new DeclaredFieldBuilder().descriptor(field.descriptor()).name(field.name()).build();

      if (calledClass == null) {
        builder.add(
            conflict(
                ConflictCategory.CLASS_NOT_FOUND,
                "Class not found: " + owningClass,
                dependency(clazz, method, field),
                artifact.name(),
                state.sourceMappings().get(owningClass)));
      } else if (missingField(declaredField, calledClass, state.knownClasses())) {
        builder.add(
            conflict(
                ConflictCategory.FIELD_NOT_FOUND,
                "Field not found: " + field.name(),
                dependency(clazz, method, field),
                artifact.name(),
                state.sourceMappings().get(owningClass)));
      } else {
        // Everything is ok!

      }
    }
  }
Esempio n. 2
0
 private Dependency dependency(DeclaredClass clazz, DeclaredMethod method, AccessedField field) {
   return new FieldDependencyBuilder()
       .fromClass(clazz.className())
       .fromMethod(method.descriptor())
       .fromLineNumber(field.lineNumber())
       .targetClass(field.owner())
       .fieldType(field.descriptor())
       .fieldName(field.name())
       .build();
 }