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

com.netflix.gradle.plugins.utils.UnsafeHelper.groovy Maven / Gradle / Ivy

package com.netflix.gradle.plugins.utils

import sun.misc.Unsafe

import java.lang.reflect.Field

@Deprecated // This is not used anymore
class UnsafeHelper {
    private static final Unsafe getUnsafe() {
        Field field = Class.forName('sun.misc.Unsafe').getDeclaredField('theUnsafe')
        field.setAccessible(true)
        field.get(null) as Unsafe
    }

    static void monkeyPatchField(Field field, Object newObject) {
        def base = unsafe.staticFieldBase(field)
        def offset = unsafe.staticFieldOffset(field)
        unsafe.putObject(base, offset, newObject)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy