Here are some examples of method trace commands and their results.
-Xtrace:methods=java/lang/String.*,print=mtThis example traces entry and exit of all methods in the java.lang.String class. The name of the class must include the full package name, using '/' as a separator. The method name is separated from the class name by a dot '.' In this example, '*' is used to include all methods. Sample output:
09:39:05.569 0x1a1100 mt.0 > java/lang/String.length()I Bytecode method, This = 8b27d8 09:39:05.579 0x1a1100 mt.6 < java/lang/String.length()I Bytecode method
-Xtrace:methods=java/lang/Thread.*(),print=mtThis example traces all methods in the java.lang.Thread class, with the parentheses '()' indicating that the trace should also include the method call parameters. The output includes an extra line, giving the class and location of the object on which the method was called, and the values of the parameters. In this example the method call is Thread.join(long millis,int nanos), which has two parameters:
09:58:12.949 0x4236ce00 mt.0 > java/lang/Thread.join(JI)V Bytecode method, This = 8ffd20 09:58:12.959 0x4236ce00 mt.18 - Instance method receiver: com/ibm/tools/attach/javaSE/AttachHandler@008FFD20 arguments: ((long)1000,(int)0)
-Xtrace:methods={java/util/HashMap.size,java/lang/String.length},print=mtThis example traces the size method on the java.util.HashMap class and the length method on the java.lang.String class. The method specification includes the two methods separated by a comma, with the entire method specification enclosed in braces '{' and '}'. Sample output:
10:28:19.296 0x1a1100 mt.0 > java/lang/String.length()I Bytecode method, This = 8c2548 10:28:19.306 0x1a1100 mt.6 < java/lang/String.length()I Bytecode method 10:28:19.316 0x1a1100 mt.0 > java/util/HashMap.size()I Bytecode method, This = 8dd7e8 10:28:19.326 0x1a1100 mt.6 < java/util/HashMap.size()I Bytecode method
-Xtrace:methods={java/util/HashMap.*,!java/util/HashMap.put*},printThis example traces all methods in the java.util.HashMap class except those beginning with put. Sample output:
10:37:42.225 0x1a1100 mt.0 > java/util/HashMap.createHashedEntry(Ljava/lang/Object;II)Ljava/util/HashMap$Entry; Bytecode method, This = 8e09 e0 10:37:42.246 0x1a1100 mt.6 < java/util/HashMap.createHashedEntry(Ljava/lang/Object;II)Ljava/util/HashMap$Entry; Bytecode method 10:37:42.256 0x1a1100 mt.1 > java/util/HashMap.findNonNullKeyEntry(Ljava/lang/Object;II)Ljava/util/HashMap$Entry; Compiled method, This = 8d d7e0 10:37:42.266 0x1a1100 mt.7 < java/util/HashMap.findNonNullKeyEntry(Ljava/lang/Object;II)Ljava/util/HashMap$Entry; Compiled method