1
1
/*
2
- * Copyright 2002-2022 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
17
17
package org .springframework .aot .agent ;
18
18
19
19
import java .util .HashSet ;
20
+ import java .util .Locale ;
20
21
import java .util .Set ;
21
22
22
23
import org .springframework .asm .ClassVisitor ;
@@ -40,6 +41,7 @@ class InvocationsRecorderClassVisitor extends ClassVisitor implements Opcodes {
40
41
41
42
private final ClassWriter classWriter ;
42
43
44
+
43
45
public InvocationsRecorderClassVisitor () {
44
46
this (new ClassWriter (ClassWriter .COMPUTE_MAXS ));
45
47
}
@@ -49,6 +51,7 @@ private InvocationsRecorderClassVisitor(ClassWriter classWriter) {
49
51
this .classWriter = classWriter ;
50
52
}
51
53
54
+
52
55
public boolean isTransformed () {
53
56
return this .isTransformed ;
54
57
}
@@ -64,6 +67,7 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str
64
67
return new InvocationsRecorderMethodVisitor (mv );
65
68
}
66
69
70
+
67
71
@ SuppressWarnings ("deprecation" )
68
72
class InvocationsRecorderMethodVisitor extends MethodVisitor implements Opcodes {
69
73
@@ -83,7 +87,6 @@ public InvocationsRecorderMethodVisitor(MethodVisitor mv) {
83
87
super (SpringAsmInfo .ASM_VERSION , mv );
84
88
}
85
89
86
-
87
90
@ Override
88
91
public void visitMethodInsn (int opcode , String owner , String name , String descriptor , boolean isInterface ) {
89
92
if (isOpcodeSupported (opcode ) && shouldRecordMethodCall (owner , name )) {
@@ -116,21 +119,19 @@ public void visitInvokeDynamicInsn(String name, String descriptor, Handle bootst
116
119
super .visitInvokeDynamicInsn (name , descriptor , bootstrapMethodHandle , bootstrapMethodArguments );
117
120
}
118
121
119
-
120
122
private boolean shouldRecordMethodCall (String owner , String method ) {
121
123
String methodReference = owner + "#" + method ;
122
124
return instrumentedMethods .contains (methodReference );
123
125
}
124
126
125
127
private String rewriteMethodName (String owner , String methodName ) {
126
128
int classIndex = owner .lastIndexOf ('/' );
127
- return owner .substring (classIndex + 1 ).toLowerCase () + methodName ;
129
+ return owner .substring (classIndex + 1 ).toLowerCase (Locale . ROOT ) + methodName ;
128
130
}
129
131
130
132
private String rewriteDescriptor (int opcode , String owner , String name , String descriptor ) {
131
133
return (opcode == Opcodes .INVOKESTATIC || opcode == Opcodes .H_INVOKESTATIC ) ? descriptor : "(L" + owner + ";" + descriptor .substring (1 );
132
134
}
133
-
134
135
}
135
136
136
137
}
0 commit comments