8216302: StackTraceElement::fill_in can use cached Class.name

Reviewed-by: coleenp, dholmes, mchung
This commit is contained in:
Aleksey Shipilev 2019-01-09 20:28:16 +01:00
parent 79c92eadc3
commit f44e59355c
8 changed files with 140 additions and 31 deletions

View file

@ -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 final class Class<T> implements java.io.Serializable,
*/
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