java - 关于 btrace 的代码的含义是什么

标签 java btrace

在下面的代码中:

import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.annotations.*;
import org.jboss.deployment.DeploymentInfo; 

@BTrace public class Trace{
   @OnMethod(
      clazz="org.jboss.deployment.SARDeployer",
      method="parseDocument"
   )
   public static void traceExecute(DeploymentInfo di){
      printFields(di);
   }

   @OnMethod(
      clazz="java.net.URL",
      method="openConnection",
      location=@Location(Kind.RETURN)
   )
   public static void resolveEntity(@Self Object instance){
     String protocol = str(get(field("java.net.URL", "protocol"),instance));
     String file = str(get(field("java.net.URL", "file"),instance));
     if(startsWith(protocol,"http") && (endsWith(file,".xsd") || endsWith(file,".dtd"))){
        String authority = str(get(field("java.net.URL", "authority"),instance));
        String path = str(get(field("java.net.URL", "path"),instance));
        println("=====================================");
        print(protocol);
        print("://");
        print(authority);
        print(path);
        println(" not found!");
        println("who call:");
        jstack();
     }
   }
}

这是什么意思:get(field("java.net.URL", "authority"),instance)

请引用文档。

最佳答案

field("java.net.URL", "authority") 将从类 java.net.URL< 中安全地检索名为 authority 的字段/strong>

get(field, instance) 以反射方式获取指定实例中给定字段的值。

Javadoc for BTraceUtils是一个很好的起点。

关于java - 关于 btrace 的代码的含义是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19429895/

相关文章:

java.lang.IllegalArgumentException : contentIntent required 异常

java - JSP在表单中设置 boolean 值

java - 如何通过命令行选项使用 Maven Surefire 排除标签?

java - 正则表达式捕获第一个冒号 : and the last square brackets having colon : in it 之间的单词

java - Android 表格单元格边框

java - 如何将日志写入 btrace 中的文件?

java - 使用@Duration 注解时,BTrace 提供了哪些时间单位?毫、微米或纳米?在文档中找不到

java - BTrace 的开销是多少

java - Btrace 不返回任何东西

java - 使用 JDK5 进行跟踪