谷本 心 in せろ部屋

はてなダイアリーから引っ越してきました

BTraceのCompilerを直接叩いてみた。

ということで、叩いてみた。

com.sun.btrace.compiler.Compiler compiler = new Compiler();
Map<String, byte[]> classMap = compiler.compile("Trace.java", source,
		new OutputStreamWriter(System.err), null, null);

System.out.println(classMap.get("Trace").length);

実行には、btrace-client.jarとtools.jarが必要。


結果、「source」で渡した文字列がコンパイルされてクラスのバイトができた模様。
sourceがBTraceのルールに違反していると、ちゃんとエラーが出てくれるので
きっとうまく叩けているんだと思う。