@@ -2,11 +2,13 @@ package proguard.util
2
2
3
3
import proguard.analysis.cpa.jvm.cfa.JvmCfa
4
4
import proguard.classfile.ClassPool
5
+ import proguard.classfile.Clazz
5
6
import proguard.classfile.Method
6
7
import proguard.classfile.MethodSignature
7
8
import proguard.classfile.ProgramClass
8
9
import proguard.classfile.ProgramMethod
9
10
import proguard.classfile.attribute.Attribute
11
+ import proguard.classfile.attribute.visitor.AllAttributeVisitor
10
12
import proguard.classfile.attribute.visitor.AttributeNameFilter
11
13
import proguard.classfile.instruction.visitor.AllInstructionVisitor
12
14
import proguard.classfile.visitor.ClassPrinter
@@ -22,52 +24,52 @@ import java.io.StringWriter
22
24
object DebugUtil {
23
25
24
26
/* *
25
- * Get the bytecode of a particular [ProgramClass ].
27
+ * Get the bytecode of a particular [Clazz ].
26
28
*/
27
29
@JvmStatic
28
- fun asString (clazz : ProgramClass ): String {
30
+ fun asString (clazz : Clazz ): String {
29
31
val sw = StringWriter ()
30
32
val pw = PrintWriter (sw)
31
33
clazz.accept(ClassPrinter (pw))
32
34
return sw.toString()
33
35
}
34
36
35
37
/* *
36
- * Get the bytecode of a particular [ProgramMethod ].
38
+ * Get the bytecode of a particular [Method ].
37
39
*/
38
40
@JvmStatic
39
41
@JvmOverloads
40
- fun asString (clazz : ProgramClass , method : ProgramMethod , verbose : Boolean = false): String {
42
+ fun asString (clazz : Clazz , method : Method , verbose : Boolean = false): String {
41
43
val sw = StringWriter ()
42
44
val pw = PrintWriter (sw)
43
45
if (verbose) {
44
46
method.accept(clazz, ClassPrinter (pw))
45
47
} else {
46
- method.attributesAccept (clazz, AttributeNameFilter (Attribute .CODE , AllInstructionVisitor (ClassPrinter (pw))))
48
+ method.accept (clazz, AllAttributeVisitor ( AttributeNameFilter (Attribute .CODE , AllInstructionVisitor (ClassPrinter (pw) ))))
47
49
}
48
50
return sw.toString()
49
51
}
50
52
51
53
/* *
52
- * Get the bytecode of a particular [ProgramMethod ] from your [ClassPool].
54
+ * Get the bytecode of a particular [Method ] from your [ClassPool].
53
55
*/
54
56
@JvmStatic
55
57
@JvmOverloads
56
58
fun asString (classPool : ClassPool , signature : MethodSignature , verbose : Boolean = false): String {
57
59
val clazz = classPool.getClass(signature.className)
58
- check(clazz is ProgramClass ) { " Program class " + clazz.name + " not found in class pool" }
60
+ check(clazz is Clazz ) { " Class " + clazz.name + " not found in class pool" }
59
61
val method = clazz.findMethod(signature.method, signature.descriptor.toString())
60
- check(method is ProgramMethod ) { " Program method " + signature + " not found in class " + clazz.getName() }
62
+ check(method is Method ) { " Method " + signature + " not found in class " + clazz.name }
61
63
return asString(clazz, method, verbose)
62
64
}
63
65
64
66
/* *
65
- * Get the bytecode of all methods in a [ProgramClass ] from your [ClassPool].
67
+ * Get the bytecode of all methods in a [Class ] from your [ClassPool].
66
68
*/
67
69
@JvmStatic
68
70
fun asString (classPool : ClassPool , className : String ): String {
69
71
val clazz = classPool.getClass(className)
70
- check(clazz is ProgramClass ) { " Program class $className not found in class pool" }
72
+ check(clazz is Clazz ) { " Class $className not found in class pool" }
71
73
return asString(clazz)
72
74
}
73
75
0 commit comments