diff --git a/core/lib/Drupal/Component/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Component/Plugin/Discovery/AnnotatedClassDiscovery.php
index 7e31231..2385fa0 100644
--- a/core/lib/Drupal/Component/Plugin/Discovery/AnnotatedClassDiscovery.php
+++ b/core/lib/Drupal/Component/Plugin/Discovery/AnnotatedClassDiscovery.php
@@ -86,7 +86,7 @@ public function getDefinitions() {
               // file. However, StaticReflectionParser needs a finder, so use a
               // mock version.
               $finder = MockFileFinder::create($fileinfo->getPathName());
-              $parser = new StaticReflectionParser($class, $finder);
+              $parser = new StaticReflectionParser($class, $finder, TRUE);
 
               if ($annotation = $reader->getClassAnnotation($parser->getReflectionClass(), $this->pluginDefinitionAnnotationName)) {
                 // AnnotationInterface::get() returns the array definition
diff --git a/core/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php b/core/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php
index 7f3e41f..f4981d6 100644
--- a/core/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php
+++ b/core/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php
@@ -119,7 +119,7 @@ protected function parse()
         $this->parsed = true;
         $contents = file_get_contents($fileName);
         if ($this->classAnnotationOptimize) {
-            if (preg_match("/(\A.*)^\s+(abstract|final)?\s+class\s+$className\s+{/sm", $contents, $matches)) {
+            if (preg_match('/(\A.*)^\s+(abstract|final)?\s+class\s+' . preg_quote($this->className, '/') . '\s+{/sm', $contents, $matches)) {
                 $contents = $matches[1];
             }
         }
