Skip to content

Commit 2a9a328

Browse files
kkrzywanskiskybber
authored andcommitted
Move comments and spaces from javassist 1:1 to make another migrations easier + small fix in Callback.java and Reflection.java
1 parent 8400633 commit 2a9a328

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+336
-384
lines changed

hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/ClassPool.java

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public void clearImportedPackages() {
301301
}
302302

303303
/**
304-
* Returns all the package names recorded by <code>importPackage()</code>.
304+
* Returns all the package names recorded by <code>importPackage()</code>.
305305
*
306306
* @see #importPackage(String)
307307
* @since 3.1
@@ -474,7 +474,7 @@ public CtClass getOrNull(String classname) {
474474
* that classname can be an array-type "descriptor" (an encoded
475475
* type name) such as <code>[Ljava/lang/Object;</code>.
476476
*
477-
* <p>Using this method is not recommended; this method should be
477+
* <p>Using this method is not recommended; this method should be
478478
* used only to obtain the <code>CtClass</code> object
479479
* with a name returned from <code>getClassInfo</code> in
480480
* <code>javassist.bytecode.ClassPool</code>. <code>getClassInfo</code>
@@ -538,7 +538,7 @@ protected synchronized CtClass get0(String classname, boolean useCache)
538538
* @return null if the class file could not be found.
539539
*/
540540
protected CtClass createCtClass(String classname, boolean useCache) {
541-
// accept "[L<class name>;" as a class name.
541+
// accept "[L<class name>;" as a class name.
542542
if (classname.charAt(0) == '[')
543543
classname = Descriptor.toClassName(classname);
544544

@@ -890,7 +890,7 @@ public synchronized CtClass makeInterface(String name, CtClass superclass)
890890
* the new interface overwrites that previous one.
891891
*
892892
* @param name a fully-qualified interface name.
893-
* Or null if the annotation has no super interface.
893+
* Or null if the annotation has no super interface.
894894
* @throws RuntimeException if the existing interface is frozen.
895895
* @since 3.19
896896
*/
@@ -1025,8 +1025,8 @@ public void appendPathList(String pathlist) throws NotFoundException {
10251025
* allowed any more.
10261026
* To load the class, this method uses the context class loader
10271027
* of the current thread. It is obtained by calling
1028-
* <code>getClassLoader()</code>.
1029-
*
1028+
* <code>getClassLoader()</code>.
1029+
*
10301030
* <p>This behavior can be changed by subclassing the pool and changing
10311031
* the <code>getClassLoader()</code> method.
10321032
* If the program is running on some application
@@ -1053,26 +1053,26 @@ public void appendPathList(String pathlist) throws NotFoundException {
10531053
public Class toClass(CtClass clazz) throws CannotCompileException {
10541054
// Some subclasses of ClassPool may override toClass(CtClass,ClassLoader).
10551055
// So we should call that method instead of toClass(.., ProtectionDomain).
1056-
return toClass(clazz, getClassLoader());
1056+
return toClass(clazz, getClassLoader());
10571057
}
10581058

10591059
/**
10601060
* Get the classloader for <code>toClass()</code>, <code>getAnnotations()</code> in
10611061
* <code>CtClass</code>, etc.
1062-
*
1062+
*
10631063
* <p>The default is the context class loader.
1064-
*
1064+
*
10651065
* @return the classloader for the pool
10661066
* @see #toClass(CtClass)
10671067
* @see CtClass#getAnnotations()
10681068
*/
10691069
public ClassLoader getClassLoader() {
10701070
return getContextClassLoader();
10711071
}
1072-
1072+
10731073
/**
10741074
* Obtains a class loader that seems appropriate to look up a class
1075-
* by name.
1075+
* by name.
10761076
*/
10771077
static ClassLoader getContextClassLoader() {
10781078
return Thread.currentThread().getContextClassLoader();
@@ -1250,15 +1250,11 @@ public Class toClass(CtClass ct, Class<?> neighbor, ClassLoader loader,
12501250
* performs nothing.
12511251
*
12521252
* <p>You do not necessarily need to
1253-
* call this method. If this method is called, then
1254-
* <code>getPackage()</code> on the <code>Class</code> object returned
1253+
* call this method. If this method is called, then
1254+
* <code>getPackage()</code> on the <code>Class</code> object returned
12551255
* by <code>toClass()</code> will return a non-null object.</p>
12561256
*
1257-
* <p>The jigsaw module introduced by Java 9 has broken this method.
1258-
* In Java 9 or later, the VM argument
1259-
* <code>--add-opens java.base/java.lang=ALL-UNNAMED</code>
1260-
* has to be given to the JVM so that this method can run.
1261-
* </p>
1257+
* <p>The jigsaw module introduced by Java 9 has broken this method.</p>
12621258
*
12631259
* @param loader the class loader passed to <code>toClass()</code> or
12641260
* the default one obtained by <code>getClassLoader()</code>.

hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/ClassPoolTail.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
package org.hotswap.agent.javassist;
1818

19-
import org.hotswap.agent.javassist.ClassClassPath;
20-
import org.hotswap.agent.javassist.LoaderClassPath;
21-
import org.hotswap.agent.javassist.NotFoundException;
22-
2319
import java.io.File;
2420
import java.io.FileInputStream;
2521
import java.io.FileNotFoundException;

hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CodeConverter.java

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void replaceNew(CtClass newClass,
131131
*
132132
* <p>Note that <code>Point2</code> must be type-compatible with <code>Point</code>.
133133
* It must have the same set of methods, fields, and constructors as the
134-
* replaced class.
134+
* replaced class.
135135
*/
136136
public void replaceNew(CtClass oldClass, CtClass newClass) {
137137
transformers = new TransformNewClass(transformers, oldClass.getName(),
@@ -244,28 +244,28 @@ public void replaceFieldWrite(CtField field,
244244
}
245245

246246
/**
247-
* Modify a method body, so that ALL accesses to an array are replaced with
248-
* calls to static methods within another class. In the case of reading an
249-
* element from the array, this is replaced with a call to a static method with
250-
* the array and the index as arguments, the return value is the value read from
251-
* the array. If writing to an array, this is replaced with a call to a static
252-
* method with the array, index and new value as parameters, the return value of
247+
* Modify a method body, so that ALL accesses to an array are replaced with
248+
* calls to static methods within another class. In the case of reading an
249+
* element from the array, this is replaced with a call to a static method with
250+
* the array and the index as arguments, the return value is the value read from
251+
* the array. If writing to an array, this is replaced with a call to a static
252+
* method with the array, index and new value as parameters, the return value of
253253
* the static method is <code>void</code>.
254-
*
255-
* <p>The <code>calledClass</code> parameter is the class containing the static methods to be used
256-
* for array replacement. The <code>names</code> parameter points to an implementation of
257-
* <code>ArrayAccessReplacementMethodNames</code> which specifies the names of the method to be
258-
* used for access for each type of array. For example reading from an <code>int[]</code> will
259-
* require a different method than if writing to an <code>int[]</code>, and writing to a <code>long[]</code>
260-
* will require a different method than if writing to a <code>byte[]</code>. If the implementation
261-
* of <code>ArrayAccessReplacementMethodNames</code> does not contain the name for access for a
254+
*
255+
* <p>The <code>calledClass</code> parameter is the class containing the static methods to be used
256+
* for array replacement. The <code>names</code> parameter points to an implementation of
257+
* <code>ArrayAccessReplacementMethodNames</code> which specifies the names of the method to be
258+
* used for access for each type of array. For example reading from an <code>int[]</code> will
259+
* require a different method than if writing to an <code>int[]</code>, and writing to a <code>long[]</code>
260+
* will require a different method than if writing to a <code>byte[]</code>. If the implementation
261+
* of <code>ArrayAccessReplacementMethodNames</code> does not contain the name for access for a
262262
* type of array, that access is not replaced.
263-
*
264-
* <p>A default implementation of <code>ArrayAccessReplacementMethodNames</code> called
265-
* <code>DefaultArrayAccessReplacementMethodNames</code> has been provided and is what is used in the
266-
* following example. This also assumes that <code>'foo.ArrayAdvisor'</code> is the name of the
263+
*
264+
* <p>A default implementation of <code>ArrayAccessReplacementMethodNames</code> called
265+
* <code>DefaultArrayAccessReplacementMethodNames</code> has been provided and is what is used in the
266+
* following example. This also assumes that <code>'foo.ArrayAdvisor'</code> is the name of the
267267
* <code>CtClass</code> passed in.
268-
*
268+
*
269269
* <p>If we have the following class:
270270
* <pre>class POJO{
271271
* int[] ints = new int[]{1, 2, 3, 4, 5};
@@ -276,64 +276,64 @@ public void replaceFieldWrite(CtField field,
276276
* </pre>
277277
* and this is accessed as:
278278
* <pre>POJO p = new POJO();
279-
*
279+
*
280280
* //Write to int array
281281
* p.ints[2] = 7;
282-
*
282+
*
283283
* //Read from int array
284284
* int i = p.ints[2];
285-
*
285+
*
286286
* //Write to long array
287287
* p.longs[2] = 1000L;
288-
*
288+
*
289289
* //Read from long array
290290
* long l = p.longs[2];
291-
*
291+
*
292292
* //Write to Object array
293293
* p.objects[2] = "Hello";
294-
*
294+
*
295295
* //Read from Object array
296296
* Object o = p.objects[2];
297-
*
297+
*
298298
* //Write to Integer array
299299
* Integer integer = new Integer(5);
300300
* p.integers[0] = integer;
301-
*
301+
*
302302
* //Read from Object array
303303
* integer = p.integers[0];
304304
* </pre>
305-
*
305+
*
306306
* Following instrumentation we will have
307307
* <pre>POJO p = new POJO();
308-
*
308+
*
309309
* //Write to int array
310310
* ArrayAdvisor.arrayWriteInt(p.ints, 2, 7);
311-
*
311+
*
312312
* //Read from int array
313313
* int i = ArrayAdvisor.arrayReadInt(p.ints, 2);
314-
*
314+
*
315315
* //Write to long array
316316
* ArrayAdvisor.arrayWriteLong(p.longs, 2, 1000L);
317-
*
317+
*
318318
* //Read from long array
319319
* long l = ArrayAdvisor.arrayReadLong(p.longs, 2);
320-
*
320+
*
321321
* //Write to Object array
322322
* ArrayAdvisor.arrayWriteObject(p.objects, 2, "Hello");
323-
*
323+
*
324324
* //Read from Object array
325325
* Object o = ArrayAdvisor.arrayReadObject(p.objects, 2);
326-
*
326+
*
327327
* //Write to Integer array
328328
* Integer integer = new Integer(5);
329329
* ArrayAdvisor.arrayWriteObject(p.integers, 0, integer);
330-
*
330+
*
331331
* //Read from Object array
332332
* integer = ArrayAdvisor.arrayWriteObject(p.integers, 0);
333333
* </pre>
334-
*
334+
*
335335
* @see DefaultArrayAccessReplacementMethodNames
336-
*
336+
*
337337
* @param calledClass the class containing the static methods.
338338
* @param names contains the names of the methods to replace
339339
* the different kinds of array access with.

hotswap-agent-core/src/main/java/org/hotswap/agent/javassist/CtBehavior.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
/**
4343
* <code>CtBehavior</code> represents a method, a constructor,
44-
* or a static constructor (class initializer).
44+
* or a static constructor (class initializer).
4545
* It is the abstract super class of
4646
* <code>CtMethod</code> and <code>CtConstructor</code>.
4747
*
@@ -191,9 +191,9 @@ public void setModifiers(int mod) {
191191
public boolean hasAnnotation(String typeName) {
192192
MethodInfo mi = getMethodInfo2();
193193
AnnotationsAttribute ainfo = (AnnotationsAttribute)
194-
mi.getAttribute(AnnotationsAttribute.invisibleTag);
194+
mi.getAttribute(AnnotationsAttribute.invisibleTag);
195195
AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
196-
mi.getAttribute(AnnotationsAttribute.visibleTag);
196+
mi.getAttribute(AnnotationsAttribute.visibleTag);
197197
return CtClassType.hasAnnotationType(typeName,
198198
getDeclaringClass().getClassPool(),
199199
ainfo, ainfo2);
@@ -214,9 +214,9 @@ public boolean hasAnnotation(String typeName) {
214214
public Object getAnnotation(Class<?> clz) throws ClassNotFoundException {
215215
MethodInfo mi = getMethodInfo2();
216216
AnnotationsAttribute ainfo = (AnnotationsAttribute)
217-
mi.getAttribute(AnnotationsAttribute.invisibleTag);
217+
mi.getAttribute(AnnotationsAttribute.invisibleTag);
218218
AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
219-
mi.getAttribute(AnnotationsAttribute.visibleTag);
219+
mi.getAttribute(AnnotationsAttribute.visibleTag);
220220
return CtClassType.getAnnotationType(clz,
221221
getDeclaringClass().getClassPool(),
222222
ainfo, ainfo2);
@@ -238,7 +238,7 @@ public Object[] getAnnotations() throws ClassNotFoundException {
238238
* Returns the annotations associated with this method or constructor.
239239
* If any annotations are not on the classpath, they are not included
240240
* in the returned array.
241-
*
241+
*
242242
* @return an array of annotation-type objects.
243243
* @see #getAnnotations()
244244
* @since 3.3
@@ -258,9 +258,9 @@ private Object[] getAnnotations(boolean ignoreNotFound)
258258
{
259259
MethodInfo mi = getMethodInfo2();
260260
AnnotationsAttribute ainfo = (AnnotationsAttribute)
261-
mi.getAttribute(AnnotationsAttribute.invisibleTag);
261+
mi.getAttribute(AnnotationsAttribute.invisibleTag);
262262
AnnotationsAttribute ainfo2 = (AnnotationsAttribute)
263-
mi.getAttribute(AnnotationsAttribute.visibleTag);
263+
mi.getAttribute(AnnotationsAttribute.visibleTag);
264264
return CtClassType.toAnnotationType(ignoreNotFound,
265265
getDeclaringClass().getClassPool(),
266266
ainfo, ainfo2);
@@ -285,7 +285,7 @@ public Object[][] getParameterAnnotations() throws ClassNotFoundException {
285285
* Returns the parameter annotations associated with this method or constructor.
286286
* If any annotations are not on the classpath, they are not included in the
287287
* returned array.
288-
*
288+
*
289289
* @return an array of annotation-type objects. The length of the returned array is
290290
* equal to the number of the formal parameters. If each parameter has no
291291
* annotation, the elements of the returned array are empty arrays.
@@ -308,9 +308,9 @@ Object[][] getParameterAnnotations(boolean ignoreNotFound)
308308
{
309309
MethodInfo mi = getMethodInfo2();
310310
ParameterAnnotationsAttribute ainfo = (ParameterAnnotationsAttribute)
311-
mi.getAttribute(ParameterAnnotationsAttribute.invisibleTag);
311+
mi.getAttribute(ParameterAnnotationsAttribute.invisibleTag);
312312
ParameterAnnotationsAttribute ainfo2 = (ParameterAnnotationsAttribute)
313-
mi.getAttribute(ParameterAnnotationsAttribute.visibleTag);
313+
mi.getAttribute(ParameterAnnotationsAttribute.visibleTag);
314314
return CtClassType.toAnnotationType(ignoreNotFound,
315315
getDeclaringClass().getClassPool(),
316316
ainfo, ainfo2, mi);
@@ -727,7 +727,7 @@ public void instrument(CodeConverter converter)
727727
* in <code>Expr</code> is available for bytecode modification.
728728
* Other methods such as <code>insertBefore()</code> may collapse
729729
* the bytecode because the <code>ExprEditor</code> loses
730-
* its current position.
730+
* its current position.
731731
*
732732
* @param editor specifies how to modify.
733733
* @see javassist.expr.Expr#replace(String)
@@ -812,7 +812,7 @@ private void insertBefore(String src, boolean rebuild)
812812

813813
/**
814814
* Inserts bytecode at the end of the body.
815-
* The bytecode is inserted just before every return insturction.
815+
* The bytecode is inserted just before every return instruction.
816816
* It is not executed when an exception is thrown.
817817
*
818818
* @param src the source code representing the inserted bytecode.
@@ -826,7 +826,7 @@ public void insertAfter(String src)
826826

827827
/**
828828
* Inserts bytecode at the end of the body.
829-
* The bytecode is inserted just before every return insturction.
829+
* The bytecode is inserted just before every return instruction.
830830
*
831831
* @param src the source code representing the inserted bytecode.
832832
* It must be a single statement or block.
@@ -893,7 +893,7 @@ public void insertAfter(String src, boolean asFinally, boolean redundant)
893893
jv, src);
894894
int handlerPos = iterator.getCodeLength();
895895
if (asFinally)
896-
ca.getExceptionTable().add(getStartPosOfBody(ca), handlerPos, handlerPos, 0);
896+
ca.getExceptionTable().add(getStartPosOfBody(ca), handlerPos, handlerPos, 0);
897897

898898
int adviceLen = 0;
899899
int advicePos = 0;
@@ -1025,7 +1025,7 @@ else if (offset <= Short.MAX_VALUE) {
10251025
else {
10261026
if (gap.length < 4) {
10271027
CodeIterator.Gap gap2 = iterator.insertGapAt(gap.position, 2, false);
1028-
pos = gap2.position + gap2.length + gap.length - 4;
1028+
pos = gap2.position + gap2.length + gap.length - 4;
10291029
}
10301030

10311031
iterator.writeByte(Opcode.GOTO_W, pos);
@@ -1242,7 +1242,7 @@ public int insertAt(int lineNum, String src)
12421242
* For example, if there is only a closing brace at that line, the
12431243
* bytecode would be inserted at another line below.
12441244
* To know exactly where the bytecode will be inserted, call with
1245-
* <code>modify</code> set to <code>false</code>.
1245+
* <code>modify</code> set to <code>false</code>.
12461246
*
12471247
* @param lineNum the line number. The bytecode is inserted at the
12481248
* beginning of the code at the line specified by this

0 commit comments

Comments
 (0)