src/java.base/share/classes/java/lang/Class.java
changeset 53212 bccff579c2ff
parent 52914 4fa75d8ad418
child 53293 64049c8e7452
--- a/src/java.base/share/classes/java/lang/Class.java	Wed Jan 09 10:59:37 2019 -0800
+++ b/src/java.base/share/classes/java/lang/Class.java	Wed Jan 09 20:28:16 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -795,14 +795,13 @@
      */
     public String getName() {
         String name = this.name;
-        if (name == null)
-            this.name = name = getName0();
-        return name;
+        return name != null ? name : initClassName();
     }
 
-    // cache the name to reduce the number of calls into the VM
+    // Cache the name to reduce the number of calls into the VM.
+    // This field would be set by VM itself during initClassName call.
     private transient String name;
-    private native String getName0();
+    private native String initClassName();
 
     /**
      * Returns the class loader for the class.  Some implementations may use