sun.misc.JavaLangAccess Java Examples

The following examples show how to use sun.misc.JavaLangAccess. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Finalizer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            // in case of recursive call to run()
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
 
Example #2
Source File: Finalizer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            // in case of recursive call to 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);
            }}});
}
 
Example #3
Source File: Finalizer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example #4
Source File: TypeAnnotationParser.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: TypeAnnotationParser.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #6
Source File: TypeAnnotationParser.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #7
Source File: Finalizer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example #8
Source File: Finalizer.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
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();
}
 
Example #9
Source File: Java7ShutdownHookRegister.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
@Override
public void register(Thread thread) {
    logger.info("register() started.");

    JavaLangAccess javaLangAccess = SharedSecrets.getJavaLangAccess();
    for (int i = 3; i < 10; i++) {
        try {
            javaLangAccess.registerShutdownHook(i, true, thread);
            logger.info("register() completed.");
            return;
        } catch (Throwable e) {
        }
    }

    Runtime.getRuntime().addShutdownHook(thread);
    logger.info("register() completed. (ShutdownHook registered in java.lang.Runtime.)");
}
 
Example #10
Source File: Finalizer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example #11
Source File: Finalizer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            // in case of recursive call to run()
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
 
Example #12
Source File: Finalizer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            // in case of recursive call to 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);
            }}});
}
 
Example #13
Source File: TypeAnnotationParser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #14
Source File: TypeAnnotationParser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #15
Source File: Finalizer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example #16
Source File: Finalizer.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            // in case of recursive call to run()
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
 
Example #17
Source File: Finalizer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    });
}
 
Example #18
Source File: TypeAnnotationParser.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #19
Source File: TypeAnnotationParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #20
Source File: Finalizer.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
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);
            }
        }
    });
}
 
Example #21
Source File: Finalizer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example #22
Source File: Finalizer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    });
}
 
Example #23
Source File: Finalizer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
            }}});
}
 
Example #24
Source File: Finalizer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
            }}});
}
 
Example #25
Source File: TypeAnnotationParser.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #26
Source File: Finalizer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    });
}
 
Example #27
Source File: Finalizer.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #28
Source File: Finalizer.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
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);
            }
        }
    });
}
 
Example #29
Source File: Finalizer.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
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);
            }}});
}
 
Example #30
Source File: Finalizer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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();
}