Skip to content

Commit eff8174

Browse files
committed
javadoc
1 parent 0f02c76 commit eff8174

File tree

12 files changed

+71
-65
lines changed

12 files changed

+71
-65
lines changed

class-inject/src/main/java/datadog/instrument/classinject/ClassInjector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static List<Class<?>> injectBootClasses(Map<String, byte[]> bytecode) {
4949
}
5050

5151
/**
52-
* Injects classes using the specified class-loader.
52+
* Injects classes using the given class-loader.
5353
*
5454
* @param bytecode the named bytecode to inject
5555
* @param cl the class-loader to use

class-match/src/main/java/datadog/instrument/classmatch/ClassFile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ private static String utf(byte[] bytecode, int utfOffset) {
301301
// most class-names will be ASCII, confirm with a quick scan
302302
for (int u = utfStart; u < utfEnd; u++) {
303303
if ((bytecode[u] & 0x80) != 0) {
304+
// found non-ASCII byte, prepare char array for decoding
304305
chars = new char[utfLen];
305306
break;
306307
}

class-match/src/main/java/datadog/instrument/classmatch/ClassHeader.java

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

1111
import java.util.List;
1212

13-
/** Minimal class header that describes its access flags and immediate class hierarchy. */
13+
/** Minimal class header that describes its access modifiers and immediate class hierarchy. */
1414
public class ClassHeader {
1515

1616
/** Access modifiers for this class. */

class-match/src/main/java/datadog/instrument/classmatch/ClassMatcher.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public interface ClassMatcher extends Predicate<ClassOutline> {
2323
* Matches classes that declare a field matching the given criteria.
2424
*
2525
* @param fieldMatcher the field matcher
26-
* @return matcher of classes with a field matching tbe criteria
26+
* @return matcher of classes with a matching field
2727
*/
2828
static ClassMatcher declares(FieldMatcher fieldMatcher) {
2929
return c -> anyMatch(c.fields, fieldMatcher);
@@ -32,20 +32,20 @@ static ClassMatcher declares(FieldMatcher fieldMatcher) {
3232
/**
3333
* Matches classes that declare a field matching the given criteria.
3434
*
35-
* @param accessMatcher the access flags matcher
35+
* @param accessMatcher the access matcher
3636
* @param fieldMatcher the field matcher
37-
* @return matcher of classes with a field matching tbe criteria
37+
* @return matcher of classes with a matching field
3838
*/
3939
static ClassMatcher declares(IntPredicate accessMatcher, FieldMatcher fieldMatcher) {
40-
FieldMatcher combinedMatcher = fieldMatcher.withAccess(accessMatcher);
40+
FieldMatcher combinedMatcher = fieldMatcher.access(accessMatcher);
4141
return c -> anyMatch(c.fields, combinedMatcher);
4242
}
4343

4444
/**
4545
* Matches classes that declare a method matching the given criteria.
4646
*
4747
* @param methodMatcher the method matcher
48-
* @return matcher of classes with a method matching tbe criteria
48+
* @return matcher of classes with a matching method
4949
*/
5050
static ClassMatcher declares(MethodMatcher methodMatcher) {
5151
return c -> anyMatch(c.methods, methodMatcher);
@@ -54,44 +54,44 @@ static ClassMatcher declares(MethodMatcher methodMatcher) {
5454
/**
5555
* Matches classes that declare a method matching the given criteria.
5656
*
57-
* @param accessMatcher the access flags matcher
57+
* @param accessMatcher the access matcher
5858
* @param methodMatcher the method matcher
59-
* @return matcher of classes with a method matching tbe criteria
59+
* @return matcher of classes with a matching method
6060
*/
6161
static ClassMatcher declares(IntPredicate accessMatcher, MethodMatcher methodMatcher) {
62-
MethodMatcher combinedMatcher = methodMatcher.withAccess(accessMatcher);
62+
MethodMatcher combinedMatcher = methodMatcher.access(accessMatcher);
6363
return c -> anyMatch(c.methods, combinedMatcher);
6464
}
6565

6666
/**
67-
* Matches methods annotated with the given type.
67+
* Matches classes annotated with the given type.
6868
*
69-
* @param annotation the expected annotation type
70-
* @return matcher of methods annotated with the same type
69+
* @param annotationType the annotation type
70+
* @return matcher of classes annotated with the type
7171
*/
72-
static ClassMatcher annotatedWith(String annotation) {
73-
Predicate<String[]> annotationMatcher = declaresAnnotation(annotation);
72+
static ClassMatcher annotatedWith(String annotationType) {
73+
Predicate<String[]> annotationMatcher = declaresAnnotation(annotationType);
7474
return c -> annotationMatcher.test(c.annotations);
7575
}
7676

7777
/**
7878
* Matches classes annotated with one of the given types.
7979
*
80-
* @param annotations the expected annotation types
81-
* @return matcher of methods annotated with one of the types
80+
* @param annotationTypes the annotation types
81+
* @return matcher of classes annotated with one of the types
8282
*/
83-
static ClassMatcher annotatedWith(String... annotations) {
84-
return annotatedWith(asList(annotations));
83+
static ClassMatcher annotatedWith(String... annotationTypes) {
84+
return annotatedWith(asList(annotationTypes));
8585
}
8686

8787
/**
8888
* Matches classes annotated with one of the given types.
8989
*
90-
* @param annotations the expected annotation types
91-
* @return matcher of methods annotated with one of the types
90+
* @param annotationTypes the annotation types
91+
* @return matcher of classes annotated with one of the types
9292
*/
93-
static ClassMatcher annotatedWith(Collection<String> annotations) {
94-
Predicate<String[]> annotationMatcher = declaresAnnotationOneOf(annotations);
93+
static ClassMatcher annotatedWith(Collection<String> annotationTypes) {
94+
Predicate<String[]> annotationMatcher = declaresAnnotationOneOf(annotationTypes);
9595
return c -> annotationMatcher.test(c.annotations);
9696
}
9797

class-match/src/main/java/datadog/instrument/classmatch/ClassOutline.java

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

1111
import java.util.List;
1212

13-
/** Outlines a class; access flags, immediate class hierarchy, field, methods, annotations. */
13+
/** Outlines a class; access modifiers, immediate class hierarchy, field, methods, annotations. */
1414
public final class ClassOutline extends ClassHeader {
1515

1616
/** Outlines of fields declared by this class. */

class-match/src/main/java/datadog/instrument/classmatch/FieldMatcher.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public interface FieldMatcher extends Predicate<FieldOutline> {
1818
/**
1919
* Matches fields with the given name.
2020
*
21-
* @param name the expected name
22-
* @return matcher of fields that have the same name
21+
* @param name the field name
22+
* @return matcher of fields with the same name
2323
*/
2424
static FieldMatcher field(String name) {
2525
return f -> name.equals(f.fieldName);
@@ -28,18 +28,18 @@ static FieldMatcher field(String name) {
2828
/**
2929
* Matches fields with names matching the given criteria.
3030
*
31-
* @param nameMatcher the name matcher
32-
* @return matcher of fields whose name matches tbe criteria
31+
* @param nameMatcher the field name matcher
32+
* @return matcher of fields with a matching name
3333
*/
3434
static FieldMatcher field(Predicate<String> nameMatcher) {
3535
return f -> nameMatcher.test(f.fieldName);
3636
}
3737

3838
/**
39-
* Matches fields with access flags matching the given criteria.
39+
* Matches fields with access modifiers matching the given criteria.
4040
*
41-
* @param accessMatcher the access flag matcher
42-
* @return matcher of fields whose access flags match tbe criteria
41+
* @param accessMatcher the access matcher
42+
* @return matcher of fields with matching access
4343
*/
4444
default FieldMatcher withAccess(IntPredicate accessMatcher) {
4545
return and(f -> accessMatcher.test(f.access));
@@ -48,8 +48,8 @@ default FieldMatcher withAccess(IntPredicate accessMatcher) {
4848
/**
4949
* Matches fields of the given type.
5050
*
51-
* @param type the type name
52-
* @return matcher of fields of the same type
51+
* @param type the field type
52+
* @return matcher of fields with the same type
5353
*/
5454
default FieldMatcher ofType(String type) {
5555
String descriptor = descriptor(type);
@@ -59,8 +59,8 @@ default FieldMatcher ofType(String type) {
5959
/**
6060
* Matches fields of the given type.
6161
*
62-
* @param type the type name
63-
* @return matcher of fields of the same type
62+
* @param type the field type
63+
* @return matcher of fields with the same type
6464
*/
6565
default FieldMatcher ofType(Class<?> type) {
6666
String descriptor = descriptor(type);

class-match/src/main/java/datadog/instrument/classmatch/FieldOutline.java

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

77
package datadog.instrument.classmatch;
88

9-
/** Outlines a field; access flags, field name, descriptor. */
9+
/** Outlines a field; access modifiers, field name, descriptor. */
1010
public final class FieldOutline {
1111

1212
/** Access modifiers for this field. */

class-match/src/main/java/datadog/instrument/classmatch/InternalMatchers.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ private InternalMatchers() {}
2222
/** Matches when at least one annotation has the given name. */
2323
static Predicate<String[]> declaresAnnotation(String name) {
2424
String internalName = internalName(name);
25+
// note this annotation is of interest when parsing
2526
ClassFile.annotationOfInterest(internalName);
2627
// performance tip: capture this method-ref outside the lambda
2728
Predicate<String> annotationNamed = internalName::equals;
@@ -31,6 +32,7 @@ static Predicate<String[]> declaresAnnotation(String name) {
3132
/** Matches when at least one annotation has one of the given names. */
3233
static Predicate<String[]> declaresAnnotationOneOf(Collection<String> names) {
3334
Set<String> internalNames = internalNames(names);
35+
// note these annotations are of interest when parsing
3436
ClassFile.annotationsOfInterest(internalNames);
3537
// performance tip: capture this method-ref outside the lambda
3638
Predicate<String> annotationNamedOneOf = internalNames::contains;

class-match/src/main/java/datadog/instrument/classmatch/MethodMatcher.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ static MethodMatcher method() {
3333
/**
3434
* Matches methods with the given name.
3535
*
36-
* @param name the expected name
37-
* @return matcher of methods that have the same name
36+
* @param name the method name
37+
* @return matcher of methods with the same name
3838
*/
3939
static MethodMatcher method(String name) {
4040
return m -> name.equals(m.methodName);
@@ -43,8 +43,8 @@ static MethodMatcher method(String name) {
4343
/**
4444
* Matches methods with names matching the given criteria.
4545
*
46-
* @param nameMatcher the name matcher
47-
* @return matcher of methods whose name matches tbe criteria
46+
* @param nameMatcher the method name matcher
47+
* @return matcher of methods with a matching name
4848
*/
4949
static MethodMatcher method(Predicate<String> nameMatcher) {
5050
return m -> nameMatcher.test(m.methodName);
@@ -69,10 +69,10 @@ static MethodMatcher staticInitializer() {
6969
}
7070

7171
/**
72-
* Matches methods with access flags matching the given criteria.
72+
* Matches methods with access modifiers matching the given criteria.
7373
*
74-
* @param accessMatcher the access flag matcher
75-
* @return matcher of methods whose access flags match tbe criteria
74+
* @param accessMatcher the access matcher
75+
* @return matcher of methods with matching access
7676
*/
7777
default MethodMatcher withAccess(IntPredicate accessMatcher) {
7878
return and(m -> accessMatcher.test(m.access));
@@ -81,7 +81,7 @@ default MethodMatcher withAccess(IntPredicate accessMatcher) {
8181
/**
8282
* Matches methods with the given parameter count.
8383
*
84-
* @param paramCount the expected parameter count
84+
* @param paramCount the parameter count
8585
* @return matcher of methods with the same parameter count
8686
*/
8787
default MethodMatcher withParameters(int paramCount) {
@@ -91,7 +91,7 @@ default MethodMatcher withParameters(int paramCount) {
9191
/**
9292
* Matches methods with the given parameter types.
9393
*
94-
* @param paramTypes the expected parameter types
94+
* @param paramTypes the parameter types
9595
* @return matcher of methods with the same parameter types
9696
*/
9797
default MethodMatcher withParameters(String... paramTypes) {
@@ -106,7 +106,7 @@ default MethodMatcher withParameters(String... paramTypes) {
106106
/**
107107
* Matches methods with the given parameter types.
108108
*
109-
* @param paramTypes the expected parameter types
109+
* @param paramTypes the parameter types
110110
* @return matcher of methods with the same parameter types
111111
*/
112112
default MethodMatcher withParameters(Class<?>... paramTypes) {
@@ -121,8 +121,8 @@ default MethodMatcher withParameters(Class<?>... paramTypes) {
121121
/**
122122
* Matches methods with the given parameter type at the given position.
123123
*
124-
* @param paramIndex the expected parameter index
125-
* @param paramType the expected parameter type
124+
* @param paramIndex the parameter index
125+
* @param paramType the parameter type
126126
* @return matcher of methods with the same parameter type at the same position
127127
*/
128128
default MethodMatcher withParameter(int paramIndex, String paramType) {
@@ -133,8 +133,8 @@ default MethodMatcher withParameter(int paramIndex, String paramType) {
133133
/**
134134
* Matches methods with the given parameter type at the given position.
135135
*
136-
* @param paramIndex the expected parameter index
137-
* @param paramType the expected parameter type
136+
* @param paramIndex the parameter index
137+
* @param paramType the parameter type
138138
* @return matcher of methods with the same parameter type at the same position
139139
*/
140140
default MethodMatcher withParameter(int paramIndex, Class<?> paramType) {
@@ -145,7 +145,7 @@ default MethodMatcher withParameter(int paramIndex, Class<?> paramType) {
145145
/**
146146
* Matches methods returning the given type.
147147
*
148-
* @param returnType the expected return type
148+
* @param returnType the return type
149149
* @return matcher of methods returning the same type
150150
*/
151151
default MethodMatcher returning(String returnType) {
@@ -156,7 +156,7 @@ default MethodMatcher returning(String returnType) {
156156
/**
157157
* Matches methods returning the given type.
158158
*
159-
* @param returnType the expected return type
159+
* @param returnType the return type
160160
* @return matcher of methods returning the same type
161161
*/
162162
default MethodMatcher returning(Class<?> returnType) {
@@ -167,32 +167,32 @@ default MethodMatcher returning(Class<?> returnType) {
167167
/**
168168
* Matches methods annotated with the given type.
169169
*
170-
* @param annotation the expected annotation type
170+
* @param annotationType the annotation type
171171
* @return matcher of methods annotated with the same type
172172
*/
173-
default MethodMatcher annotatedWith(String annotation) {
174-
Predicate<String[]> annotationMatcher = declaresAnnotation(annotation);
173+
default MethodMatcher annotatedWith(String annotationType) {
174+
Predicate<String[]> annotationMatcher = declaresAnnotation(annotationType);
175175
return and(m -> annotationMatcher.test(m.annotations));
176176
}
177177

178178
/**
179179
* Matches methods annotated with one of the given types.
180180
*
181-
* @param annotations the expected annotation types
181+
* @param annotationTypes the annotation types
182182
* @return matcher of methods annotated with one of the types
183183
*/
184-
default MethodMatcher annotatedWith(String... annotations) {
185-
return annotatedWith(asList(annotations));
184+
default MethodMatcher annotatedWith(String... annotationTypes) {
185+
return annotatedWith(asList(annotationTypes));
186186
}
187187

188188
/**
189189
* Matches methods annotated with one of the given types.
190190
*
191-
* @param annotations the expected annotation types
191+
* @param annotationTypes the annotation types
192192
* @return matcher of methods annotated with one of the types
193193
*/
194-
default MethodMatcher annotatedWith(Collection<String> annotations) {
195-
Predicate<String[]> annotationMatcher = declaresAnnotationOneOf(annotations);
194+
default MethodMatcher annotatedWith(Collection<String> annotationTypes) {
195+
Predicate<String[]> annotationMatcher = declaresAnnotationOneOf(annotationTypes);
196196
return and(m -> annotationMatcher.test(m.annotations));
197197
}
198198

class-match/src/main/java/datadog/instrument/classmatch/MethodOutline.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import java.util.BitSet;
1212
import java.util.List;
1313

14-
/** Outlines a method; access flags, method name, descriptor, annotations. */
14+
/** Outlines a method; access modifiers, method name, descriptor, annotations. */
1515
public final class MethodOutline {
1616

1717
/** Access modifiers for this method. */
@@ -26,6 +26,7 @@ public final class MethodOutline {
2626
/** Internal names of annotations declared on this method. */
2727
final String[] annotations;
2828

29+
/** Lazy cache of boundaries between each parameter/return descriptor. */
2930
private int[] descriptorBoundaries;
3031

3132
/**
@@ -49,6 +50,8 @@ public List<String> annotations() {
4950
*
5051
* <p>The number of boundaries is the same as the number of parameters: there is no boundary
5152
* before the first parameter, and the return boundary is omitted if there are no parameters.
53+
* (This is to save space - the first parameter always starts at index 1; and if there are no
54+
* parameters then the return descriptor always starts at index 2.)
5255
*/
5356
int[] descriptorBoundaries() {
5457
if (descriptorBoundaries == null) {

0 commit comments

Comments
 (0)