diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index cb1fe97..3bd7269 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -621,7 +621,7 @@ function drupalGetNodeByTitle($title, $reset = FALSE) {
       // Grant the specified permissions to the role, if any.
       if (!empty($permissions)) {
         user_role_grant_permissions($role->id(), $permissions);
-        $assigned_permissions = entity_load('user_role', $role->id())->permissions;
+        $assigned_permissions = entity_load('user_role', $role->id())->getPermissions();
         $missing_permissions = array_diff($permissions, $assigned_permissions);
         if (!$missing_permissions) {
           $this->pass(String::format('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), 'Role');
diff --git a/core/modules/user/src/Entity/Role.php b/core/modules/user/src/Entity/Role.php
index b517ac9..e02c97a 100644
--- a/core/modules/user/src/Entity/Role.php
+++ b/core/modules/user/src/Entity/Role.php
@@ -47,28 +47,28 @@ class Role extends ConfigEntityBase implements RoleInterface {
    *
    * @var string
    */
-  public $id;
+  protected $id;
 
   /**
    * The human-readable label of this role.
    *
    * @var string
    */
-  public $label;
+  protected $label;
 
   /**
    * The weight of this role in administrative listings.
    *
    * @var int
    */
-  public $weight;
+  protected $weight;
 
   /**
    * The permissions belonging to this role.
    *
    * @var array
    */
-  public $permissions = array();
+  protected $permissions = array();
 
   /**
    * {@inheritdoc}
@@ -80,6 +80,21 @@ class Role extends ConfigEntityBase implements RoleInterface {
   /**
    * {@inheritdoc}
    */
+  public function getWeight() {
+    return $this->get('weight');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setWeight($weight) {
+    $this->set('weight', $weight);
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
   public function hasPermission($permission) {
     return in_array($permission, $this->permissions);
   }
diff --git a/core/modules/user/src/RoleForm.php b/core/modules/user/src/RoleForm.php
index 2bed647..1961a75 100644
--- a/core/modules/user/src/RoleForm.php
+++ b/core/modules/user/src/RoleForm.php
@@ -42,7 +42,7 @@ class RoleForm extends EntityForm {
     );
     $form['weight'] = array(
       '#type' => 'value',
-      '#value' => $entity->get('weight'),
+      '#value' => $entity->getWeight(),
     );
 
     return parent::form($form, $form_state, $entity);
diff --git a/core/modules/user/src/RoleInterface.php b/core/modules/user/src/RoleInterface.php
index 1cae601..f1d76ee 100644
--- a/core/modules/user/src/RoleInterface.php
+++ b/core/modules/user/src/RoleInterface.php
@@ -41,8 +41,7 @@
    * @param string $permission
    *   The permission to grant.
    *
-   * @return RoleInterface
-   *   The called object for chaining.
+   * @return $this
    */
   public function grantPermission($permission);
 
@@ -52,9 +51,26 @@
    * @param string $permission
    *   The permission to revoke.
    *
-   * @return RoleInterface
-   *   The called object for chaining.
+   * @return $this
    */
   public function revokePermission($permission);
 
+  /**
+   * Returns the weight.
+   *
+   * @return int
+   *   The weight of this role.
+   */
+  public function getWeight();
+
+  /**
+   * Sets the weight to the given value.
+   *
+   * @param int $weight
+   *   The desired weight.
+   *
+   * @return $this
+   */
+  public function setWeight($weight);
+
 }
diff --git a/core/modules/user/src/Tests/UserRoleAdminTest.php b/core/modules/user/src/Tests/UserRoleAdminTest.php
index fa42d8c..89b99d2 100644
--- a/core/modules/user/src/Tests/UserRoleAdminTest.php
+++ b/core/modules/user/src/Tests/UserRoleAdminTest.php
@@ -98,9 +98,9 @@ function testRoleWeightOrdering() {
     // Change the role weights to make the roles in reverse order.
     $edit = array();
     foreach ($roles as $role) {
-      $edit['entities['. $role->id() .'][weight]'] =  $weight;
+      $edit['entities[' . $role->id() . '][weight]'] = $weight;
       $new_role_weights[$role->id()] = $weight;
-      $saved_rids[] = $role->id;
+      $saved_rids[] = $role->id();
       $weight--;
     }
     $this->drupalPostForm('admin/people/roles', $edit, t('Save order'));
@@ -112,8 +112,8 @@ function testRoleWeightOrdering() {
     $rids = array();
     // Test that the role weights have been correctly saved.
     foreach ($roles as $role) {
-      $this->assertEqual($role->weight, $new_role_weights[$role->id()]);
-      $rids[] = $role->id;
+      $this->assertEqual($role->getWeight(), $new_role_weights[$role->id()]);
+      $rids[] = $role->id();
     }
     // The order of the roles should be reversed.
     $this->assertIdentical($rids, array_reverse($saved_rids));
