diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/UserData.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/UserData.php
index f0074fa..f3e5c2f 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/field/UserData.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/UserData.php
@@ -12,6 +12,7 @@
 use Drupal\views\ViewExecutable;
 use Drupal\user\UserDataInterface;
 use Drupal\Component\Annotation\PluginID;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Provides access to the user data service.
@@ -32,12 +33,26 @@ class UserData extends FieldPluginBase {
   protected $userData;
 
   /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) {
+    return new static($configuration, $plugin_id, $plugin_definition, $container->get('user.data'));
+  }
+
+  /**
+   * Constructs a UserData object.
+   */
+  public function __construct(array $configuration, $plugin_id, array $plugin_definition, UserDataInterface $user_data) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition);
+
+    $this->userData = $user_data;
+  }
+
+  /**
    * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
    */
   public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
     parent::init($view, $display, $options);
-
-    $this->userData = drupal_container()->get('user.data');
   }
 
   /**
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
index 42c2f7f..9dd3933 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
@@ -72,7 +72,7 @@ function testUserCancelUid1() {
     $password = user_password();
     $account = array(
       'name' => 'user1',
-      'pass' => drupal_container()->get('password')->hash(trim($password)),
+      'pass' => $this->container->get('password')->hash(trim($password)),
     );
     // We cannot use $account->save() here, because this would result in the
     // password being hashed again.
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
index 38b7abf..2953bf4 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
@@ -107,7 +107,7 @@ function testPasswordRehashOnLogin() {
     $default_count_log2 = 16;
 
     // Retrieve instance of password hashing algorithm
-    $password_hasher = drupal_container()->get('password');
+    $password_hasher = $this->container->get('password');
 
     // Create a new user and authenticate.
     $account = $this->drupalCreateUser(array());
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index f1cacc0..a2486c0 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -605,7 +605,7 @@ function user_validate_current_pass(&$form, &$form_state) {
     // form values like password_confirm that have their own validation
     // that prevent them from being empty if they are changed.
     if ((strlen(trim($form_state['values'][$key])) > 0) && ($form_state['values'][$key] != $account->$key)) {
-      $current_pass_failed = empty($form_state['values']['current_pass']) || !drupal_container()->get('password')->check($form_state['values']['current_pass'], $account);
+      $current_pass_failed = empty($form_state['values']['current_pass']) || !Drupal::service('password')->check($form_state['values']['current_pass'], $account);
       if ($current_pass_failed) {
         form_set_error('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name)));
         form_set_error($key);
@@ -1108,7 +1108,7 @@ function user_authenticate($name, $password) {
   if (!empty($name) && !empty($password)) {
     $account = user_load_by_name($name);
     if ($account) {
-      $password_hasher = drupal_container()->get('password');
+      $password_hasher = Drupal::service('password');
       if ($password_hasher->check($password, $account)) {
         // Successful authentication.
         $uid = $account->id();
@@ -2010,7 +2010,7 @@ function user_modules_installed($modules) {
  */
 function user_modules_uninstalled($modules) {
   // Remove any potentially orphan module data stored for users.
-  drupal_container()->get('user.data')->delete($modules);
+  Drupal::service('user.data')->delete($modules);
 }
 
 /**
diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc
index 04bd69c..bc74e40 100644
--- a/core/modules/user/user.pages.inc
+++ b/core/modules/user/user.pages.inc
@@ -303,7 +303,7 @@ function user_cancel_confirm($account, $timestamp = 0, $hashed_pass = '') {
   $current = REQUEST_TIME;
 
   // Basic validation of arguments.
-  $account_data = drupal_container()->get('user.data')->get('user', $account->id());
+  $account_data = Drupal::service('user.data')->get('user', $account->id());
   if (isset($account_data['cancel_method']) && !empty($timestamp) && !empty($hashed_pass)) {
     // Validate expiration and hashed password/login.
     if ($timestamp <= $current && $current - $timestamp < $timeout && $account->id() && $timestamp >= $account->getLastLoginTime() && $hashed_pass == user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())) {
