Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method signature seems wrong #14

Closed
zhangjunhd opened this issue Nov 27, 2013 · 0 comments
Closed

method signature seems wrong #14

zhangjunhd opened this issue Nov 27, 2013 · 0 comments

Comments

@zhangjunhd
Copy link

hi,
I want to reflect a high-order function of scala,so i use classUtil to track it, but I found the print sigature of the method is wrong(just print as method name):

import org.clapper.classutil.ClassFinder
import org.clapper.classutil.ClassUtil

import java.io.File

object Main extends App {

val classpath = List(
    new File("target/scala-2.10/classes/com/alibaba/fodps/classUtil/"))
val finder = ClassFinder(classpath)
//val classes = finder.getClasses // classes is an Iterator[ClassInfo]

println("interface ...")
val ifaces = finder.getClasses.filter(_.isInterface)
ifaces.foreach(println(_))

println("concrete ...")
val crete = finder.getClasses.filter(_.isConcrete)
for (cls <- crete){
    println(cls.name)
    if (cls.name == "com.alibaba.fodps.classUtil.Foo$$anonfun$run$1"){
        printf("bingo, methods:%s\n",cls.methods)
        for (m <- cls.methods){
            if (m.name == "apply")
                printf("desc=%s,sig=%s\n", m.descriptor, m.signature)
        }
    }
}

}

use sbt and print:

run
[info] Compiling 1 Scala source to /Users/zhangjun/Documents/workspace/classUtil/target/scala-2.10/classes...
[info] Running com.alibaba.fodps.classUtil.Main
interface ...
concrete ...
com.alibaba.fodps.classUtil.Foo$$anonfun$run$1
bingo, methods:Set(, apply, apply$mcII$sp)
desc=(I)I,sig=apply <--------------------the sig is wrong here!!!
com.alibaba.fodps.classUtil.Foo
com.alibaba.fodps.classUtil.Main$$anonfun$1
com.alibaba.fodps.classUtil.Main$$anonfun$2
com.alibaba.fodps.classUtil.Main$$anonfun$3
com.alibaba.fodps.classUtil.Main$$anonfun$4$$anonfun$apply$1
com.alibaba.fodps.classUtil.Main$$anonfun$4
com.alibaba.fodps.classUtil.Main$
com.alibaba.fodps.classUtil.Main$delayedInit$body
com.alibaba.fodps.classUtil.Main
[success] Total time: 1 s, completed Nov 27, 2013 12:35:14 PM

build.sbt:
scalaVersion := "2.10.2"

libraryDependencies ++= Seq(
"org.scalatest" % "scalatest_2.10" % "2.0" % "test",
"org.slf4j" % "slf4j-api" % "1.7.2",
"org.slf4j" % "slf4j-simple" % "1.7.2",
"org.clapper" % "grizzled-scala_2.10" % "1.1.4",
"org.clapper" % "grizzled-slf4j_2.10" % "1.0.1",
"asm" % "asm" % "3.3.1",
"org.clapper" % "classutil_2.10" % "1.0.2"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant