-XX:[+|-]HitachiLocalsInThrowable (Option for collecting the local variable information when an exception occurs)
- Organization of this page
Format
- -XX:+HitachiLocalsInThrowable
-
This option outputs the local variable information of the methods in the stack trace.
The -XX:+HitachiLocalsInThrowable option is ignored when java.lang.StackOverflowError occurs.
- -XX:-HitachiLocalsInThrowable
-
This option does not output the local variable information of the methods in the stack trace.
Description
When the java.lang.Throwable.fillInStackTrace method is executed, the local variable information of the method in the stack trace is collected.
- Default value
-
-
-XX:-HitachiLocalsInThrowable
-
Output format
locals: name: <name> type: <type> value: <value> ...
The output contents are explained below:
-
In the first line, "locals:" header is output.
-
From second line onwards, the following information is output line by line for each local variable that can be collected:
-
Variable name
-
Type name (basic type name, class name, or array type name)
-
Character string that represents variable value
-
Note that the output contents of each local variable are demarcated with a blank line.
- name
-
Local variable name.
For the argument passed to the method, [arg***](*** is the argument number) will be displayed in continuation to the variable name.
- type
-
Type name of the local variable (the basic type name, class name, or the array type name)
- value
-
Character string representing the value of local variable
-
Basic type:
Value converted as it is into a character string
-
Class or array type:
When variable type is null: (null)
Other than the above-mentioned: existing-address-of-the-object
Maximum length of the character string representing a value is 64. When the character string exceeds the maximum length, the characters up to 64th character are output and after that "..." character string is output. In the case of the class or array type, you can add detailed expressions by specifying the following add options:
-
-XX:+HitachiLocalsSimpleFormat
-
-XX:+HitachiTrueTypeInLocals
-
-XX:HitachiCallToString
-
Examples of output
The following is an example of output using Java program example 1:
- When all the 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.000000 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: ...
When the local variable information does not exist
-
For a class file generated without adding the -g option or the -g:vars option
-
For the native method of a class file generated by adding 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: ...
Precautions
-
To collect complete local variable information, while you are creating the class file in javac, you need to add the -g option or the -g:vars option and fill the local variable information in the class file. For the class file created without adding the -g option or the -g:vars option, the local variable information is output in the collectable range.
-
The local variable information does not exist for the native method even if the class file is generated by adding the -g option or the -g:vars option.
-
When the JIT compiler compiles a method, as a part of optimization, the local variables determined as unnecessary, are removed.
(Example) Consider a declaration and local variable that is not used after initialization as "int not_used = 12345":
In this case, the following value is output in 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)
-
When the local variable information of the method containing complicated control structure and multiple lines is to be output, analysis takes time, and hence, when an exception occurs the process for generating the exception object may take longer time.
-
To output the local variable information to the stack trace of the current thread obtained by using the getStackTrace method of the java.lang.Thread class, you must set up the option for collecting the local variable information for an exception (-XX:+HitachiLocalsInThrowable), which outputs the local variable information to the stack trace used for an exception.