jdk/src/share/classes/java/util/logging/LogRecord.java
changeset 3861 a98a057ec335
parent 3853 9d2382b74894
child 5506 202f599c92aa
equal deleted inserted replaced
3854:b2a90c48e69f 3861:a98a057ec335
   528         JavaLangAccess access = SharedSecrets.getJavaLangAccess();
   528         JavaLangAccess access = SharedSecrets.getJavaLangAccess();
   529         Throwable throwable = new Throwable();
   529         Throwable throwable = new Throwable();
   530         int depth = access.getStackTraceDepth(throwable);
   530         int depth = access.getStackTraceDepth(throwable);
   531 
   531 
   532         String logClassName = "java.util.logging.Logger";
   532         String logClassName = "java.util.logging.Logger";
       
   533         String plogClassName = "sun.util.logging.PlatformLogger";
   533         boolean lookingForLogger = true;
   534         boolean lookingForLogger = true;
   534         for (int ix = 0; ix < depth; ix++) {
   535         for (int ix = 0; ix < depth; ix++) {
   535             // Calling getStackTraceElement directly prevents the VM
   536             // Calling getStackTraceElement directly prevents the VM
   536             // from paying the cost of building the entire stack frame.
   537             // from paying the cost of building the entire stack frame.
   537             StackTraceElement frame =
   538             StackTraceElement frame =
   538                 access.getStackTraceElement(throwable, ix);
   539                 access.getStackTraceElement(throwable, ix);
   539             String cname = frame.getClassName();
   540             String cname = frame.getClassName();
   540             if (lookingForLogger) {
   541             if (lookingForLogger) {
   541                 // Skip all frames until we have found the first logger frame.
   542                 // Skip all frames until we have found the first logger frame.
   542                 if (cname.equals(logClassName)) {
   543                 if (cname.equals(logClassName) || cname.startsWith(plogClassName)) {
   543                     lookingForLogger = false;
   544                     lookingForLogger = false;
   544                 }
   545                 }
   545             } else {
   546             } else {
   546                 if (!cname.equals(logClassName)) {
   547                 if (!cname.equals(logClassName) && !cname.startsWith(plogClassName)) {
   547                     // We've found the relevant frame.
   548                     // skip reflection call
   548                     setSourceClassName(cname);
   549                     if (!cname.startsWith("java.lang.reflect.") && !cname.startsWith("sun.reflect.")) {
   549                     setSourceMethodName(frame.getMethodName());
   550                        // We've found the relevant frame.
   550                     return;
   551                        setSourceClassName(cname);
       
   552                        setSourceMethodName(frame.getMethodName());
       
   553                        return;
       
   554                     }
   551                 }
   555                 }
   552             }
   556             }
   553         }
   557         }
   554         // We haven't found a suitable frame, so just punt.  This is
   558         // We haven't found a suitable frame, so just punt.  This is
   555         // OK as we are only committed to making a "best effort" here.
   559         // OK as we are only committed to making a "best effort" here.