JDK-8148776 : Add macro for Unified Logging to internalize ResourceMark allocation
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2016-02-01
  • Updated: 2019-05-22
  • Resolved: 2017-06-12
Related Reports
Relates :  
Description
To improve clarity and conciseness in logging code, a macro should be added so that when LogHandle(<tag>)::<level>_stream() is passed into a logging function, a ResourceMark is automatically created. A macro is also needed for when the external_name() function is used with classunload logging, so that

if (log_is_enabled(Trace, classunload)) {
ResourceMark rm;
log_trace(classunload)("unlinking class (sibling) %s", sibling->external_name());
}

does not require the first two lines.


Comments
Because of nested macros and literal log tags in the existing logging code, adding a ResourceMark to a macro or function is not feasible.
12-06-2017

One almost always wants this to do something like: log_info(stacktrace)("Stack trace depth %d for exception %s", depth, throwable->name_as_C_string());
02-02-2016