uCosminexus Application Server, Maintenance and Migration Guide
For each stack frame information of the stack trace information output by the java.lang.Throwable.printStackTrace method, the local variable information within the method corresponding to that stack frame is inserted and output.
This is the example of output when you specify the -XX:+HitachiLocalsInThrowable option only as a function to output local variables.
The example of Java program and output of the corresponding local variable information within the stack trace are as follows:
class Example1 { public static void main(String[] args) { Example1 e1 = new Example1(); Object obj = new Object(); e1.method(1, 'Q', obj); // Execute-e1.method (5th line). } void method(int l1, char l2, Object l3) { float l4 = 4.0f; boolean l5 = true; double l6 = Double.MAX_VALUE; Object[] l7 = new Object[10]; try { <Exception occurred!> // methodProcess-when-there-is-an-exception-in-process-of-method(15th line). } catch (Exception e) { e.printStackTrace(); // output-stack-trace-information (17th line). } } } |
The example of output is described below.
This example is the stack trace information output by e.printStackTrace method on the 17th line when an exception occurs in e1.method method executed on the 5th line of example 1 of the Java program.
Figure 5-2 Output example of local variable information for example 1 of Java program (When the class file is created by specifying -g option or -g:vars option)
The output contents are as follows:
The example of output in the simple output format when you specify -XX:+HitachiLocalsSimpleFormat option, is described below. Further, the explanation of the output contents is the same as that for standard format.
Figure 5-3 Output example when -XX:+HitachiLocalsSimpleFormat option is specified
Moreover, if the -g option or -g:vars option is not specified when executing javac command, and since there is no local variable information, the output contents are restricted in the following manner. This is same as when executing the native method.
The example of output in the case of Java program example 1, when the local variable information does not exist, is described below. The example of output in the simple output format is as follows:
Figure 5-4 Output example when local variable information does not exist (Simple output format)
There are following differences as compared to Figure 5-3.
When the local variables to be output are of class or array type, there are times when the information required for troubleshooting cannot be acquired in the value expression of only the address. At this time, if you specify the -XX:HitachiCallToString option, you can acquire the value of class or array type variable as a character string. In options, you can specify minimal or full as the applicable scope.
When you specify -XX:HitachiCallToString=minimal option, among the classes in the java.lang package, String, StringBuffer, Boolean, Byte, Character, Short, Integer, Long, Float, or Double are the targets of a parameter. When specifying the -XX:HitachiCallToString=full option, all the classes are targets.
An example of the Java program and example of output when the -XX:HitachiCallToString option is specified is described below. Further, the simple output format is used below.
class Example2 { public static void main(String[] args) { Example2 e2 = new Example2(); e2.method();// Executes-e2.method-method (4th line). } void method() { String l1 = "local 1"; StringBuffer l2 = new StringBuffer(l1); l2.append(" + local 2"); Boolean l3 = new Boolean(false); Character l4 = new Character('X'); Long l5 = new Long(Long.MIN_VALUE); Object l6 = new Thread(); Object[] l7 = new Thread[10]; try { <Exception occurred!> // Process-when-exception-occurred-in-process-of-method (18th line). } catch (Exception e) { e.printStackTrace(); // Output stack trace information (20th line). } } public String toString() { return "I am an Example2 instance."; } } |
An example of output when specifying the -XX:HitachiCallToString=minimal option is described below:
This example is the stack trace information output by the 20th line e.printStackTrace method when an exception occurs in the e2.method method executed on the 4th line of example 1 of the Java program.
Figure 5-5 Output example when -XX:HitachiCallToString=minimal option is specified (Simple output format)
The output contents are as follows:
Shown below is the example of output when you specify the -XX:HitachiCallToString=full option.
Figure 5-6 Output example when -XX:HitachiCallToString=full option is specified (Simple output format)
There are following differences as compared to Figure 5-5.
However, the character string is not output and only the address is output, such as in the following cases:
When local variables that are output are of class or array type, there are cases when that variable type name and the type name of actually substituted value differ. For example, depending on the inheritance relationship of classes or the implementation relationship of interfaces, values of different type names are substituted in variables.
In this case, by specifying the -XX:+HitachiTrueTypeInLocals option, you can add the type name of a value actually substituted to the class or array type variables and acquire the character string.
The acquired character string is output by adding one single byte space at the end of the value expression and enclosing with parentheses (()). At this time, there is no limit on the output character string length.
An example of output when you specify -XX:+HitachiTrueTypeInLocals option is described below. Simple output format is shown below. The program to be executed is example 2 of the Java program. Moreover, this example is an example where you specify the -XX:HitachiCallToString=minimal option.
Figure 5-7 Output example when -XX:+HitachiTrueTypeInLocals option is specified (Simple output format)
The output contents are as follows:
Note that you can specify the -XX:+HitachiTrueTypeInLocals option along with the -XX:HitachiCallToString=full option.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.