Skip to content

Commit

Permalink
Refactor transform.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongl authored and jushi committed Jun 19, 2012
1 parent 7f9a2ea commit 58a2438
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
* @author <a href="mailto:[email protected]">zhongl<a>
*/
public class Inspect extends TransformCommand {


public Inspect(Instrumentation inst, PrintOut out) {
super("", "", inst, out);
super("inspect", "display fields of a class.", inst, out);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/com/github/zhongl/housemd/command/Trace.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class Trace(val inst: Instrumentation, out: PrintOut)
override def heartbeat(now: Long) {
if (now - last >= intervalMillis) {
last = now
statistics foreach { s => println(s.reps(maxMethodSignLength, maxClassLoaderLength)) }
if (statistics.isEmpty) println("No traced method invoked")
else statistics foreach { s => println(s.reps(maxMethodSignLength, maxClassLoaderLength)) }
println()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@ class Transform extends ((Instrumentation, Filter, Seconds, Int, Loggable, Hook)

@inline
def isNotFromHouseMD = if (c.getName.startsWith("com.github.zhongl.housemd")) {
log.warn("Skip " + c + " from HouseMD")
log.warn("Skip " + c + " belongs to HouseMD")
false
} else true

@inline
def isNotInterface = if (c.isInterface) {log.warn("Skip " + c); false} else true

filter(c) && isNotFromHouseMD && isNotInterface
@inline
def isNotFromBootClassLoader =
if (isFromBootClassLoader(c)) {log.warn("Skip " + c + " loaded from bootclassloader"); false} else true

filter(c) && isNotFromHouseMD && isNotInterface && isNotFromBootClassLoader
}

if (candidates.isEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ class TransformCommandSpec extends FunSpec with ShouldMatchers with AdviceReflec
}
}

ignore("should not probe class loaded by boot classloader") {
it("should not probe class loaded by boot classloader") {
parseAndRun("String") { out =>
out.split("\n").head should be("WARN : Skip " + classOf[String] + " loaded from bootclassloader.")
out.split("\n").head should be("WARN : Skip " + classOf[String] + " loaded from bootclassloader")
}
}

Expand Down

0 comments on commit 58a2438

Please sign in to comment.