Skip to content

Commit fa81dce

Browse files
yewtonjbachorik
authored andcommitted
Correctly set field name for @TargetMethodOrField
Fixes #694
1 parent 894f37d commit fa81dce

20 files changed

+50
-30
lines changed

btrace-instr/src/main/java/org/openjdk/btrace/instr/Instrumentor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,8 @@ && matches(targetFieldName, name)) {
966966
getMethodOrFieldName(
967967
om.isTargetMethodOrFieldFqn(),
968968
opcode,
969-
targetClassName,
970-
targetFieldName,
969+
owner,
970+
name,
971971
desc)),
972972
constArg(om.getClassNameParameter(), className.replace('/', '.')),
973973
constArg(om.getMethodParameter(), getName(om.isMethodFqn())),
@@ -1015,8 +1015,8 @@ && matches(targetFieldName, name)) {
10151015
getMethodOrFieldName(
10161016
om.isTargetMethodOrFieldFqn(),
10171017
opcode,
1018-
targetClassName,
1019-
targetFieldName,
1018+
owner,
1019+
name,
10201020
desc)),
10211021
localVarArg(om.getReturnParameter(), fldType, returnValIndex),
10221022
constArg(om.getClassNameParameter(), className.replace('/', '.')),
@@ -1085,8 +1085,8 @@ && matches(targetFieldName, name)) {
10851085
getMethodOrFieldName(
10861086
om.isTargetMethodOrFieldFqn(),
10871087
opcode,
1088-
targetClassName,
1089-
targetFieldName,
1088+
owner,
1089+
name,
10901090
desc)),
10911091
constArg(om.getClassNameParameter(), className.replace('/', '.')),
10921092
constArg(om.getMethodParameter(), getName(om.isMethodFqn())),
@@ -1129,8 +1129,8 @@ && matches(targetFieldName, name)) {
11291129
getMethodOrFieldName(
11301130
om.isTargetMethodOrFieldFqn(),
11311131
opcode,
1132-
targetClassName,
1133-
targetFieldName,
1132+
owner,
1133+
name,
11341134
desc)),
11351135
constArg(om.getClassNameParameter(), className.replace('/', '.')),
11361136
constArg(om.getMethodParameter(), getName(om.isMethodFqn())),

btrace-instr/src/test/btrace/onmethod/FieldGetAfter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public class FieldGetAfter {
4646
location =
4747
@Location(
4848
value = Kind.FIELD_GET,
49-
clazz = "resources.OnMethodTest",
50-
field = "field",
49+
clazz = "/^resources.OnMethodTest$/",
50+
field = "/^field$/",
5151
where = Where.AFTER))
5252
public static void args(
5353
@Self Object self,

btrace-instr/src/test/btrace/onmethod/FieldGetAfterStatic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public class FieldGetAfterStatic {
4646
location =
4747
@Location(
4848
value = Kind.FIELD_GET,
49-
clazz = "resources.OnMethodTest",
50-
field = "sField",
49+
clazz = "/^resources.OnMethodTest$/",
50+
field = "/^sField$/",
5151
where = Where.AFTER))
5252
public static void args(
5353
@Self Object self,

btrace-instr/src/test/btrace/onmethod/FieldGetBefore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class FieldGetBefore {
4141
@OnMethod(
4242
clazz = "/.*\\.OnMethodTest/",
4343
method = "field",
44-
location = @Location(value = Kind.FIELD_GET, clazz = "/.*\\.OnMethodTest/", field = "field"))
44+
location = @Location(value = Kind.FIELD_GET, clazz = "/.*\\.OnMethodTest/", field = "/^field$/"))
4545
public static void args(
4646
@Self Object self, @TargetInstance Object inst, @TargetMethodOrField String fldName) {
4747
println("args");

btrace-instr/src/test/btrace/onmethod/FieldGetBeforeStatic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class FieldGetBeforeStatic {
4141
@OnMethod(
4242
clazz = "/.*\\.OnMethodTest/",
4343
method = "staticField",
44-
location = @Location(value = Kind.FIELD_GET, clazz = "/.*\\.OnMethodTest/", field = "sField"))
44+
location = @Location(value = Kind.FIELD_GET, clazz = "/.*\\.OnMethodTest/", field = "/^sField$/"))
4545
public static void args(
4646
@Self Object self, @TargetInstance Object inst, @TargetMethodOrField String fldName) {
4747
println("args");

btrace-instr/src/test/btrace/onmethod/FieldSetAfter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class FieldSetAfter {
4646
@Location(
4747
value = Kind.FIELD_SET,
4848
clazz = "resources.OnMethodTest",
49-
field = "field",
49+
field = "/^field$/",
5050
where = Where.AFTER))
5151
public static void args(
5252
@Self Object self,

btrace-instr/src/test/btrace/onmethod/FieldSetAfterStatic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class FieldSetAfterStatic {
4646
@Location(
4747
value = Kind.FIELD_SET,
4848
clazz = "resources.OnMethodTest",
49-
field = "sField",
49+
field = "/^sField$/",
5050
where = Where.AFTER))
5151
public static void args(
5252
@Self Object self,

btrace-instr/src/test/btrace/onmethod/FieldSetBefore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class FieldSetBefore {
4141
@OnMethod(
4242
clazz = "/.*\\.OnMethodTest/",
4343
method = "field",
44-
location = @Location(value = Kind.FIELD_SET, clazz = "/.*\\.OnMethodTest/", field = "field"))
44+
location = @Location(value = Kind.FIELD_SET, clazz = "/.*\\.OnMethodTest/", field = "/^field$/"))
4545
public static void args(
4646
@Self Object self,
4747
@TargetInstance Object inst,

btrace-instr/src/test/btrace/onmethod/FieldSetBeforeStatic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class FieldSetBeforeStatic {
4141
@OnMethod(
4242
clazz = "/.*\\.OnMethodTest/",
4343
method = "staticField",
44-
location = @Location(value = Kind.FIELD_SET, clazz = "/.*\\.OnMethodTest/", field = "sField"))
44+
location = @Location(value = Kind.FIELD_SET, clazz = "/.*\\.OnMethodTest/", field = "/^sField$/"))
4545
public static void args(
4646
@Self Object self,
4747
@TargetInstance Object inst,

btrace-instr/src/test/btrace/onmethod/leveled/FieldGetAfter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public class FieldGetAfter {
4747
location =
4848
@Location(
4949
value = Kind.FIELD_GET,
50-
clazz = "resources.OnMethodTest",
51-
field = "field",
50+
clazz = "/^resources.OnMethodTest$/",
51+
field = "/^field$/",
5252
where = Where.AFTER),
5353
enableAt = @Level(">=1"))
5454
public static void args(

0 commit comments

Comments
 (0)