7.10.3 -XX:[+|-]HitachiLocalsInThrowable
-XX:[+|-]HitachiLocalsInThrowable outputs the local variable information of the methods in the stack traces.
Description
-XX:[+|-]HitachiLocalsInThrowable collects the local variable information of the methods in the stack traces when the java.lang.Throwable.fillInStackTrace method is executed.
- Format of output
-
locals: name: name type: type value: value ...
-
In the first line, locals: is output as the header.
-
From second line onwards, information about collected local variables is output to one line for each variable.
The following information about local variables is output:
-
Variable name
-
Type name (basic type name, class name or array type name)
-
Character string that indicates a variable value
Note that the content output for each local variable is delimited by blank lines.
Output item
Output content
name
Local variable name.
If this variable is passed to a method, [arg***] (*** indicates the argument number) appears after the variable name.
type
Type of the local variable (basic type, class name, or array type).
value
String that represents the value of the local variable.
-
Basic type
Character string that is generated by converting the value
-
Class or array type
When the variable is null:(null)
Other: address_where_the_object_exists
The maximum number of characters that represent the value is 64. If the maximum number is exceeded, the first 64 characters and the character string "..." are output. For class or array type, you can add more detailed expressions by specifying the following additional options:
-
-XX:+HitachiLocalsSimpleFormat
-
-XX:+HitachiTrueTypeInLocals
-
-XX:HitachiCallToString
-
Syntax
-XX:[+|-]HitachiLocalsInThrowable
Specifiable values
Type: String
- -XX:+HitachiLocalsInThrowable
-
Outputs the local variable information of the methods in the stack trace.
This option is ignored when java.lang.StackOverflowError occurs.
- -XX:-HitachiLocalsInThrowable
-
Does not output the local variable information of the methods in the stack trace.
Examples
Examples of output (in the simple output format) when the following Java program example is used are shown below.
- Java program example
class Example1 { public static void main(String[] args) { Example1 e1 = new Example1(); Object obj = new Object(); e1.method(1, 'Q', obj); // 5th line } void method(int l1, char l2, Object l3) { float l4 = 4.0f; boolean l5 = true; double l6 = Double.MAX_VALUE; // Maximum value of the double data type Object[] l7 = new Object[10]; try { <An exception occurred!> // 15th line } catch (Exception e) { e.printStackTrace(); } } }
- Example of output 1
-
When all local variable information is output:
at Example1.method(Example1.java:15) locals: name: this type: Example1 value: <0x922f42d0> name: l1 [arg1] type: int value: 1 name: l2 [arg2] type; char value: 'Q' name: l3 [arg3] type: java.lang.Object value: <0xaf112f08> name: l4 type: float value: 4 name: l5 type: boolean value: true name: l6 type: double value: 1.79769E+308 name: l7 type: java.lang.Object[] value: <0x922f42d8> at Example1.main(Example1.java:5) locals: ...
- Example of output 2
-
When no local variable information exists:
-
When the class file is generated without specifying the -g option or the -g:vars option.
-
The native method of a class file is generated by specifying the -g option or the -g:vars option.
at Example1.method(Example1.java:15) locals: name: this type: Example1 value: <0x922f42d0> name: [arg1] type: int value: 1 name: [arg2] type; char value: 'Q' name: [arg3] type: java.lang.Object value: <0xaf112f08> at Example1.main(Example1.java:5) locals: ...
-
Notes
-
To collect all local variable information, when you create the class file by using javac, you must embed local variable information in the class file by specifying the -g option or the -g:vars option. If you create the class file without specifying either the -g option or the -g:vars option, the local variable information will be output within the collectable range.
-
No local variable information exists for the native method, even if the class file was generated by specifying the -g option or the -g:vars option.
-
When the JIT compiler compiles a method, as a part of optimization, local variables that are determined to be unnecessary might be removed.
Example: Declarations (such as "int not_used = 12345") and local variables that are not used after initialization
In this example, one of the following values is output as the local variable information when an exception occurs:
Type name
Output information
boolean type
false
char type
'\0'
byte type
short type
int type
long type
float type
double type
0
Class type
Array type
(null)
-
During the output the local variable information of a method containing a complicated control structure and many lines, analysis takes more time. As a result, the generation of an exception object when an exception occurs might take more time.
-
To output the local variable information to the stack trace of the current thread obtained by using the method getStackTrace of the class java.lang.Thread, the option (-XX:+HitachiLocalsInThrowable) that collects and outputs the local variable information to the stack trace when an exception occurs is necessary.