All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.auties.protobuf.tool.util.LoggerUtils Maven / Gradle / Ivy

The newest version!
package it.auties.protobuf.tool.util;

import lombok.experimental.UtilityClass;
import sun.misc.Unsafe;

@UtilityClass
public class LoggerUtils {
    public void suppressIllegalAccessWarning() {
        try {
            var unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
            unsafeField.setAccessible(true);
            var unsafe = (Unsafe) unsafeField.get(null);

            var loggerClass = Class.forName("jdk.internal.module.IllegalAccessLogger");
            var logger = loggerClass.getDeclaredField("logger");
            unsafe.putObjectVolatile(loggerClass, unsafe.staticFieldOffset(logger), null);
        } catch (Throwable ignored) {

        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy