public static int getFieldTag(Class<? extends Message> protoClass, String fieldName) { if (protoClass == null) { throw new RuntimeException("protoClass should not be null"); } try { Field field = protoClass.getField(fieldName); ProtoField protoField = field.getAnnotation(ProtoField.class); if (protoField == null) { throw new RuntimeException( "the field do not have ProtoField annotation, " + "field name=" + fieldName); } return protoField.tag(); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } }