java.lang.NoSuchFieldException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(66)

本文整理了Java中java.lang.NoSuchFieldException.getMessage()方法的一些代码示例,展示了NoSuchFieldException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NoSuchFieldException.getMessage()方法的具体详情如下:
包路径:java.lang.NoSuchFieldException
类名称:NoSuchFieldException
方法名:getMessage

NoSuchFieldException.getMessage介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

public Field run() {
    final Field field;
    try {
      field = clazz.getDeclaredField(fieldName);
    } catch (NoSuchFieldException e) {
      throw new NoSuchFieldError(e.getMessage());
    }
    field.setAccessible(true);
    return field;
  }
}

代码示例来源:origin: wildfly/wildfly

public Unsafe run() {
    try {
      final Field field = Unsafe.class.getDeclaredField("theUnsafe");
      field.setAccessible(true);
      return (Unsafe) field.get(null);
    } catch (IllegalAccessException e) {
      throw new IllegalAccessError(e.getMessage());
    } catch (NoSuchFieldException e) {
      throw new NoSuchFieldError(e.getMessage());
    }
  }
});

代码示例来源:origin: wildfly/wildfly

public Field run() {
    try {
      return clazz.getDeclaredField(name);
    } catch (NoSuchFieldException e) {
      throw new NoSuchFieldError(e.getMessage());
    }
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public Field[] getEnumConstants(Class clazz) {
  try {
    Object[] values = clazz.getEnumConstants();
    Field[] fields = new Field[values.length];
    for (int i = 0; i < values.length; i++) {
      fields[i] = clazz.getField(((Enum) values[i]).name());
    }
    return fields;
  } catch (NoSuchFieldException e) {
    // impossible
    throw new NoSuchFieldError(e.getMessage());
  }
}

代码示例来源:origin: MorphiaOrg/morphia

private Field getField(final Class c, final String field) {
  try {
    return c.getDeclaredField(field);
  } catch (NoSuchFieldException e) {
    throw new RuntimeException(e.getMessage(), e);
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

代码示例来源:origin: udacity/ud851-Sunshine

static String studentReadableNoSuchField(NoSuchFieldException e) {
    String message = e.getMessage();

    Pattern p = Pattern.compile("No field (\\w*) in class L.*/(\\w*\\$?\\w*);");

    Matcher m = p.matcher(message);

    if (m.find()) {
      String missingFieldName = m.group(1);
      String classForField = m.group(2).replaceAll("\\$", ".");
      String fieldNotFoundReadableMessage = "Couldn't find "
          + missingFieldName + " in class " + classForField + "."
          + "\nPlease make sure you've declared that field and followed the TODOs.";
      return fieldNotFoundReadableMessage;
    } else {
      return e.getMessage();
    }
  }
}

相关文章