Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.lang.reflect.Field;

public class Main {
    public static <T> void setFinalField(Class<T> clazz, T object, String fieldName, Object value) {
        try {
            Field headerField = clazz.getDeclaredField(fieldName);
            headerField.setAccessible(true);
            headerField.set(object, value);
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e2) {
            throw new RuntimeException(e2);
        }
    }
}