changeset 1748:020a0fed38c9

6881442: (reflect) Race condition in Class.getName() Summary: only read "name" field racily once Reviewed-by: darcy
author martin
date Sat, 12 Sep 2009 15:30:13 -0700
parents 46406871599c
children 060c4c7082ef
files src/share/classes/java/lang/Class.java
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/Class.java	Fri Sep 11 16:36:22 2009 -0700
+++ b/src/share/classes/java/lang/Class.java	Sat Sep 12 15:30:13 2009 -0700
@@ -565,8 +565,9 @@
      *          represented by this object.
      */
     public String getName() {
+        String name = this.name;
         if (name == null)
-            name = getName0();
+            this.name = name = getName0();
         return name;
     }