Skip to content

Commit

Permalink
printing invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
avantgardnerio committed Oct 30, 2018
1 parent ae26384 commit 177bad4
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/test/kotlin/ResolverTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ResolverTest {
* Called when a class is visited. This is the method called first
*/
override fun visit(version: Int, access: Int, name: String?,
signature: String?, superName: String?, interfaces: Array<String>?) {
signature: String?, superName: String?, interfaces: Array<String>?) {
println("Visiting class: $name")
println("Class Major Version: $version")
println("Super class: $superName")
Expand All @@ -52,7 +52,7 @@ class ResolverTest {
* Invoked when a class level annotation is encountered
*/
override fun visitAnnotation(desc: String?,
visible: Boolean): AnnotationVisitor? {
visible: Boolean): AnnotationVisitor? {
println("Annotation: $desc")
return super.visitAnnotation(desc, visible)
}
Expand All @@ -69,7 +69,7 @@ class ResolverTest {
* When an inner class is encountered
*/
override fun visitInnerClass(name: String?, outerName: String?,
innerName: String?, access: Int) {
innerName: String?, access: Int) {
println("Inner Class: $innerName defined in $outerName")
super.visitInnerClass(name, outerName, innerName, access)
}
Expand All @@ -78,7 +78,7 @@ class ResolverTest {
* When a field is encountered
*/
override fun visitField(access: Int, name: String?,
desc: String?, signature: String?, value: Any?): FieldVisitor? {
desc: String?, signature: String?, value: Any?): FieldVisitor? {
println("Field: $name $desc value:$value")
return super.visitField(access, name, desc, signature, value)
}
Expand All @@ -92,19 +92,21 @@ class ResolverTest {
/**
* When a method is encountered
*/
override fun visitMethod(access: Int, name: String?,
desc: String?, signature: String?, exceptions: Array<String>?): MethodVisitor? {
println("Method: $name $desc")
override fun visitMethod(access: Int, methodName: String?,
desc: String?, signature: String?, exceptions: Array<String>?): MethodVisitor? {
println("Method: $methodName $desc")

System.out.println("\n" + name + desc)
val oriMv: MethodVisitor = object : MethodVisitor(Opcodes.ASM7) { }
System.out.println("\n" + methodName + desc)
val oriMv: MethodVisitor = object : MethodVisitor(Opcodes.ASM7) {}
val instMv = object : InstructionAdapter(Opcodes.ASM7, oriMv) {
override fun visitInsn(opcode: Int) {
println(opcode)
super.visitInsn(opcode)

override fun visitMethodInsn(opcode: Int, owner: String?, name: String?, descriptor: String?, isInterface: Boolean) {
println("invoke ${owner}.${name} from ${file.name} ${clazz.name}.${methodName}()")
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface)
}

}
return instMv
return instMv
//return super.visitMethod(access, name, desc, signature, exceptions)
}

Expand Down

0 comments on commit 177bad4

Please sign in to comment.