Example usage for java.lang NoSuchFieldError initCause

List of usage examples for java.lang NoSuchFieldError initCause

Introduction

In this page you can find the example usage for java.lang NoSuchFieldError initCause.

Prototype

public synchronized Throwable initCause(Throwable cause) 

Source Link

Document

Initializes the cause of this throwable to the specified value.

Usage

From source file:LinkedTransferQueue.java

static long objectFieldOffset(sun.misc.Unsafe UNSAFE, String field, Class<?> klazz) {
    try {//from w w  w. jav a 2 s .c o m
        return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
    } catch (NoSuchFieldException e) {
        // Convert Exception to corresponding Error
        NoSuchFieldError error = new NoSuchFieldError(field);
        error.initCause(e);
        throw error;
    }
}