Skip to content

Commit a481252

Browse files
author
Jaroslav Bachorik
committed
updating samples
1 parent e5d33de commit a481252

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

‎samples/AllCalls2.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525

2626
package com.sun.btrace.samples;
2727

28-
import com.sun.btrace.AnyType;
2928
import com.sun.btrace.annotations.*;
3029
import static com.sun.btrace.BTraceUtils.*;
3130

3231
/**
3332
* This script demonstrates the possibility to intercept
34-
* method calls that are abou to be executed from the body of
33+
* method calls that are about to be executed from the body of
3534
* a certain method. This is achieved by using the {@linkplain Kind#CALL}
3635
* location value.
3736
*/

‎samples/AllCalls3.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
/**
3333
* This script demonstrates the possibility to intercept
34-
* method calls that are abou to be executed from the body of
34+
* method calls that are about to be executed from the body of
3535
* a certain method. This is achieved by using the {@linkplain Kind#CALL}
3636
* location value.
3737
*/

‎samples/JdbcQueries.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
import com.sun.btrace.annotations.OnEvent;
5555
import com.sun.btrace.annotations.OnMethod;
5656
import com.sun.btrace.annotations.TLS;
57+
import com.sun.btrace.annotations.Return;
58+
import com.sun.btrace.annotations.Self;
5759

5860
/**
5961
* BTrace script to print timings for all executed JDBC statements on an event. Demonstrates
@@ -105,7 +107,7 @@ public class JdbcQueries {
105107
*/
106108
@OnMethod(clazz = "+java.sql.Connection", method = "/prepare.*/")
107109
public static void onPrepare(AnyType[] args) {
108-
preparingStatement = useStackTrace ? jstackStr() : str(args[1]);
110+
preparingStatement = useStackTrace ? jstackStr() : str(args[0]);
109111
}
110112

111113
/**
@@ -115,10 +117,9 @@ public static void onPrepare(AnyType[] args) {
115117
* the return value from the prepareXxx() method.
116118
*/
117119
@OnMethod(clazz = "+java.sql.Connection", method = "/prepare.*/", location = @Location(Kind.RETURN))
118-
public static void onPrepareReturn(AnyType arg) {
120+
public static void onPrepareReturn(@Return Statement preparedStatement) {
119121
if (preparingStatement != null) {
120122
print("P"); // Debug Prepared
121-
Statement preparedStatement = (Statement) arg;
122123
put(preparedStatementDescriptions, preparedStatement, preparingStatement);
123124
preparingStatement = null;
124125
}
@@ -129,14 +130,13 @@ public static void onPrepareReturn(AnyType arg) {
129130
// Otherwise the SQL is in the first argument.
130131

131132
@OnMethod(clazz = "+java.sql.Statement", method = "/execute.*/")
132-
public static void onExecute(AnyType[] args) {
133-
if (args.length == 1) {
133+
public static void onExecute(@Self Statement currentStatement, AnyType[] args) {
134+
if (args.length == 0) {
134135
// No SQL argument; lookup the SQL from the prepared statement
135-
Statement currentStatement = (Statement) args[0]; // this
136136
executingStatement = get(preparedStatementDescriptions, currentStatement);
137137
} else {
138138
// Direct SQL in the first argument
139-
executingStatement = useStackTrace ? jstackStr() : str(args[1]);
139+
executingStatement = useStackTrace ? jstackStr() : str(args[0]);
140140
}
141141
}
142142

0 commit comments

Comments
 (0)