Java 类sun.misc.JavaLangAccess 实例源码

项目:OpenJSharp    文件:Finalizer.java   
private void runFinalizer(JavaLangAccess jla) {
    synchronized (this) {
        if (hasBeenFinalized()) return;
        remove();
    }
    try {
        Object finalizee = this.get();
        if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
            jla.invokeFinalize(finalizee);

            /* Clear stack slot containing this variable, to decrease
               the chances of false retention with a conservative GC */
            finalizee = null;
        }
    } catch (Throwable x) { }
    super.clear();
}
项目:OpenJSharp    文件:Finalizer.java   
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
项目:OpenJSharp    文件:Finalizer.java   
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
项目:OpenJSharp    文件:TypeAnnotationParser.java   
static TypeAnnotation[] parseAllTypeAnnotations(AnnotatedElement decl) {
    Class<?> container;
    byte[] rawBytes;
    JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess();
    if (decl instanceof Class) {
        container = (Class<?>)decl;
        rawBytes = javaLangAccess.getRawClassTypeAnnotations(container);
    } else if (decl instanceof Executable) {
        container = ((Executable)decl).getDeclaringClass();
        rawBytes = javaLangAccess.getRawExecutableTypeAnnotations((Executable)decl);
    } else {
        // Should not reach here. Assert?
        return EMPTY_TYPE_ANNOTATION_ARRAY;
    }
    return parseTypeAnnotations(rawBytes, javaLangAccess.getConstantPool(container),
                                decl, container);
}
项目:jdk8u-jdk    文件:Finalizer.java   
private void runFinalizer(JavaLangAccess jla) {
    synchronized (this) {
        if (hasBeenFinalized()) return;
        remove();
    }
    try {
        Object finalizee = this.get();
        if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
            jla.invokeFinalize(finalizee);

            /* Clear stack slot containing this variable, to decrease
               the chances of false retention with a conservative GC */
            finalizee = null;
        }
    } catch (Throwable x) { }
    super.clear();
}
项目:jdk8u-jdk    文件:Finalizer.java   
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
项目:jdk8u-jdk    文件:Finalizer.java   
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
项目:jdk8u-jdk    文件:TypeAnnotationParser.java   
static TypeAnnotation[] parseAllTypeAnnotations(AnnotatedElement decl) {
    Class<?> container;
    byte[] rawBytes;
    JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess();
    if (decl instanceof Class) {
        container = (Class<?>)decl;
        rawBytes = javaLangAccess.getRawClassTypeAnnotations(container);
    } else if (decl instanceof Executable) {
        container = ((Executable)decl).getDeclaringClass();
        rawBytes = javaLangAccess.getRawExecutableTypeAnnotations((Executable)decl);
    } else {
        // Should not reach here. Assert?
        return EMPTY_TYPE_ANNOTATION_ARRAY;
    }
    return parseTypeAnnotations(rawBytes, javaLangAccess.getConstantPool(container),
                                decl, container);
}
项目:Java8CN    文件:Finalizer.java   
private void runFinalizer(JavaLangAccess jla) {
    synchronized (this) {
        if (hasBeenFinalized()) return;
        remove();
    }
    try {
        Object finalizee = this.get();
        if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
            jla.invokeFinalize(finalizee);

            /* Clear stack slot containing this variable, to decrease
               the chances of false retention with a conservative GC */
            finalizee = null;
        }
    } catch (Throwable x) { }
    super.clear();
}
项目:Java8CN    文件:Finalizer.java   
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
项目:Java8CN    文件:Finalizer.java   
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
项目:jdk8u_jdk    文件:Finalizer.java   
private void runFinalizer(JavaLangAccess jla) {
    synchronized (this) {
        if (hasBeenFinalized()) return;
        remove();
    }
    try {
        Object finalizee = this.get();
        if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
            jla.invokeFinalize(finalizee);

            /* Clear stack slot containing this variable, to decrease
               the chances of false retention with a conservative GC */
            finalizee = null;
        }
    } catch (Throwable x) { }
    super.clear();
}
项目:jdk8u_jdk    文件:Finalizer.java   
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
项目:jdk8u_jdk    文件:Finalizer.java   
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
项目:jdk8u_jdk    文件:TypeAnnotationParser.java   
static TypeAnnotation[] parseAllTypeAnnotations(AnnotatedElement decl) {
    Class<?> container;
    byte[] rawBytes;
    JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess();
    if (decl instanceof Class) {
        container = (Class<?>)decl;
        rawBytes = javaLangAccess.getRawClassTypeAnnotations(container);
    } else if (decl instanceof Executable) {
        container = ((Executable)decl).getDeclaringClass();
        rawBytes = javaLangAccess.getRawExecutableTypeAnnotations((Executable)decl);
    } else {
        // Should not reach here. Assert?
        return EMPTY_TYPE_ANNOTATION_ARRAY;
    }
    return parseTypeAnnotations(rawBytes, javaLangAccess.getConstantPool(container),
                                decl, container);
}
项目:lookaside_java-1.8.0-openjdk    文件:Finalizer.java   
private void runFinalizer(JavaLangAccess jla) {
    synchronized (this) {
        if (hasBeenFinalized()) return;
        remove();
    }
    try {
        Object finalizee = this.get();
        if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
            jla.invokeFinalize(finalizee);

            /* Clear stack slot containing this variable, to decrease
               the chances of false retention with a conservative GC */
            finalizee = null;
        }
    } catch (Throwable x) { }
    super.clear();
}
项目:lookaside_java-1.8.0-openjdk    文件:Finalizer.java   
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
项目:lookaside_java-1.8.0-openjdk    文件:Finalizer.java   
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
项目:lookaside_java-1.8.0-openjdk    文件:TypeAnnotationParser.java   
static TypeAnnotation[] parseAllTypeAnnotations(AnnotatedElement decl) {
    Class<?> container;
    byte[] rawBytes;
    JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess();
    if (decl instanceof Class) {
        container = (Class<?>)decl;
        rawBytes = javaLangAccess.getRawClassTypeAnnotations(container);
    } else if (decl instanceof Executable) {
        container = ((Executable)decl).getDeclaringClass();
        rawBytes = javaLangAccess.getRawExecutableTypeAnnotations((Executable)decl);
    } else {
        // Should not reach here. Assert?
        return EMPTY_TYPE_ANNOTATION_ARRAY;
    }
    return parseTypeAnnotations(rawBytes, javaLangAccess.getConstantPool(container),
                                decl, container);
}
项目:jdk-1.7-annotated    文件:Finalizer.java   
private void runFinalizer(JavaLangAccess jla) {
    synchronized (this) {
        if (hasBeenFinalized()) return;
        remove();
    }
    try {
        Object finalizee = this.get();
        if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
            jla.invokeFinalize(finalizee);

            /* Clear stack slot containing this variable, to decrease
               the chances of false retention with a conservative GC */
            finalizee = null;
        }
    } catch (Throwable x) { }
    super.clear();
}
项目:jdk-1.7-annotated    文件:Finalizer.java   
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
项目:jdk-1.7-annotated    文件:Finalizer.java   
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
项目:infobip-open-jdk-8    文件:Finalizer.java   
private void runFinalizer(JavaLangAccess jla) {
    synchronized (this) {
        if (hasBeenFinalized()) return;
        remove();
    }
    try {
        Object finalizee = this.get();
        if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
            jla.invokeFinalize(finalizee);

            /* Clear stack slot containing this variable, to decrease
               the chances of false retention with a conservative GC */
            finalizee = null;
        }
    } catch (Throwable x) { }
    super.clear();
}
项目:infobip-open-jdk-8    文件:Finalizer.java   
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
项目:infobip-open-jdk-8    文件:Finalizer.java   
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
项目:infobip-open-jdk-8    文件:TypeAnnotationParser.java   
static TypeAnnotation[] parseAllTypeAnnotations(AnnotatedElement decl) {
    Class<?> container;
    byte[] rawBytes;
    JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess();
    if (decl instanceof Class) {
        container = (Class<?>)decl;
        rawBytes = javaLangAccess.getRawClassTypeAnnotations(container);
    } else if (decl instanceof Executable) {
        container = ((Executable)decl).getDeclaringClass();
        rawBytes = javaLangAccess.getRawExecutableTypeAnnotations((Executable)decl);
    } else {
        // Should not reach here. Assert?
        return EMPTY_TYPE_ANNOTATION_ARRAY;
    }
    return parseTypeAnnotations(rawBytes, javaLangAccess.getConstantPool(container),
                                decl, container);
}
项目:jdk8u-dev-jdk    文件:Finalizer.java   
private void runFinalizer(JavaLangAccess jla) {
    synchronized (this) {
        if (hasBeenFinalized()) return;
        remove();
    }
    try {
        Object finalizee = this.get();
        if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
            jla.invokeFinalize(finalizee);

            /* Clear stack slot containing this variable, to decrease
               the chances of false retention with a conservative GC */
            finalizee = null;
        }
    } catch (Throwable x) { }
    super.clear();
}
项目:jdk8u-dev-jdk    文件:Finalizer.java   
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
项目:jdk8u-dev-jdk    文件:Finalizer.java   
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
项目:jdk8u-dev-jdk    文件:TypeAnnotationParser.java   
static TypeAnnotation[] parseAllTypeAnnotations(AnnotatedElement decl) {
    Class<?> container;
    byte[] rawBytes;
    JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess();
    if (decl instanceof Class) {
        container = (Class<?>)decl;
        rawBytes = javaLangAccess.getRawClassTypeAnnotations(container);
    } else if (decl instanceof Executable) {
        container = ((Executable)decl).getDeclaringClass();
        rawBytes = javaLangAccess.getRawExecutableTypeAnnotations((Executable)decl);
    } else {
        // Should not reach here. Assert?
        return EMPTY_TYPE_ANNOTATION_ARRAY;
    }
    return parseTypeAnnotations(rawBytes, javaLangAccess.getConstantPool(container),
                                decl, container);
}
项目:OLD-OpenJDK8    文件:Finalizer.java   
private void runFinalizer(JavaLangAccess jla) {
    synchronized (this) {
        if (hasBeenFinalized()) return;
        remove();
    }
    try {
        Object finalizee = this.get();
        if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
            jla.invokeFinalize(finalizee);

            /* Clear stack slot containing this variable, to decrease
               the chances of false retention with a conservative GC */
            finalizee = null;
        }
    } catch (Throwable x) { }
    super.clear();
}
项目:OLD-OpenJDK8    文件:Finalizer.java   
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
项目:OLD-OpenJDK8    文件:Finalizer.java   
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
项目:OLD-OpenJDK8    文件:TypeAnnotationParser.java   
static TypeAnnotation[] parseAllTypeAnnotations(AnnotatedElement decl) {
    Class<?> container;
    byte[] rawBytes;
    JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess();
    if (decl instanceof Class) {
        container = (Class<?>)decl;
        rawBytes = javaLangAccess.getRawClassTypeAnnotations(container);
    } else if (decl instanceof Executable) {
        container = ((Executable)decl).getDeclaringClass();
        rawBytes = javaLangAccess.getRawExecutableTypeAnnotations((Executable)decl);
    } else {
        // Should not reach here. Assert?
        return EMPTY_TYPE_ANNOTATION_ARRAY;
    }
    return parseTypeAnnotations(rawBytes, javaLangAccess.getConstantPool(container),
                                decl, container);
}
项目:openjdk-jdk7u-jdk    文件:Finalizer.java   
private void runFinalizer(JavaLangAccess jla) {
    synchronized (this) {
        if (hasBeenFinalized()) return;
        remove();
    }
    try {
        Object finalizee = this.get();
        if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
            jla.invokeFinalize(finalizee);

            /* Clear stack slot containing this variable, to decrease
               the chances of false retention with a conservative GC */
            finalizee = null;
        }
    } catch (Throwable x) { }
    super.clear();
}
项目:openjdk-jdk7u-jdk    文件:Finalizer.java   
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
项目:openjdk-jdk7u-jdk    文件:Finalizer.java   
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
项目:OpenJSharp    文件:LogRecord.java   
private void inferCaller() {
    needToInferCaller = false;
    JavaLangAccess access = SharedSecrets.getJavaLangAccess();
    Throwable throwable = new Throwable();
    int depth = access.getStackTraceDepth(throwable);

    boolean lookingForLogger = true;
    for (int ix = 0; ix < depth; ix++) {
        // Calling getStackTraceElement directly prevents the VM
        // from paying the cost of building the entire stack frame.
        StackTraceElement frame =
            access.getStackTraceElement(throwable, ix);
        String cname = frame.getClassName();
        boolean isLoggerImpl = isLoggerImplFrame(cname);
        if (lookingForLogger) {
            // Skip all frames until we have found the first logger frame.
            if (isLoggerImpl) {
                lookingForLogger = false;
            }
        } else {
            if (!isLoggerImpl) {
                // skip reflection call
                if (!cname.startsWith("java.lang.reflect.") && !cname.startsWith("sun.reflect.")) {
                   // We've found the relevant frame.
                   setSourceClassName(cname);
                   setSourceMethodName(frame.getMethodName());
                   return;
                }
            }
        }
    }
    // We haven't found a suitable frame, so just punt.  This is
    // OK as we are only committed to making a "best effort" here.
}
项目:OpenJSharp    文件:PlatformLogger.java   
private String getCallerInfo() {
    String sourceClassName = null;
    String sourceMethodName = null;

    JavaLangAccess access = SharedSecrets.getJavaLangAccess();
    Throwable throwable = new Throwable();
    int depth = access.getStackTraceDepth(throwable);

    String logClassName = "sun.util.logging.PlatformLogger";
    boolean lookingForLogger = true;
    for (int ix = 0; ix < depth; ix++) {
        // Calling getStackTraceElement directly prevents the VM
        // from paying the cost of building the entire stack frame.
        StackTraceElement frame =
            access.getStackTraceElement(throwable, ix);
        String cname = frame.getClassName();
        if (lookingForLogger) {
            // Skip all frames until we have found the first logger frame.
            if (cname.equals(logClassName)) {
                lookingForLogger = false;
            }
        } else {
            if (!cname.equals(logClassName)) {
                // We've found the relevant frame.
                sourceClassName = cname;
                sourceMethodName = frame.getMethodName();
                break;
            }
        }
    }

    if (sourceClassName != null) {
        return sourceClassName + " " + sourceMethodName;
    } else {
        return name;
    }
}
项目:jdk8u-jdk    文件:LogRecord.java   
private void inferCaller() {
    needToInferCaller = false;
    JavaLangAccess access = SharedSecrets.getJavaLangAccess();
    Throwable throwable = new Throwable();
    int depth = access.getStackTraceDepth(throwable);

    boolean lookingForLogger = true;
    for (int ix = 0; ix < depth; ix++) {
        // Calling getStackTraceElement directly prevents the VM
        // from paying the cost of building the entire stack frame.
        StackTraceElement frame =
            access.getStackTraceElement(throwable, ix);
        String cname = frame.getClassName();
        boolean isLoggerImpl = isLoggerImplFrame(cname);
        if (lookingForLogger) {
            // Skip all frames until we have found the first logger frame.
            if (isLoggerImpl) {
                lookingForLogger = false;
            }
        } else {
            if (!isLoggerImpl) {
                // skip reflection call
                if (!cname.startsWith("java.lang.reflect.") && !cname.startsWith("sun.reflect.")) {
                   // We've found the relevant frame.
                   setSourceClassName(cname);
                   setSourceMethodName(frame.getMethodName());
                   return;
                }
            }
        }
    }
    // We haven't found a suitable frame, so just punt.  This is
    // OK as we are only committed to making a "best effort" here.
}