# Final fields

DevFeed: [Final fields](<https://devfeed.tech/articles/final-fields-27264.md>)

Original publisher: [Read original article](<https://blog.pchudzik.com/201612/final-fields/>)

Published: 2016-12-03T00:00:00Z

Content type: tutorial

Language: en

Sources: [Paweł Chudzik](<https://devfeed.tech/sources/pawe-chudzik.md>)

Topics: [Hibernate](<https://devfeed.tech/topics/hibernate.md>), [Java](<https://devfeed.tech/topics/java.md>), [inlining](<https://devfeed.tech/topics/inlining.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>)

Tags: [bytecode](<https://devfeed.tech/tags/bytecode.md>), [hibernate](<https://devfeed.tech/tags/hibernate.md>), [inlining](<https://devfeed.tech/tags/inlining.md>), [java](<https://devfeed.tech/tags/java.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [trace](<https://devfeed.tech/tags/trace.md>)

## AI overview

This tutorial explains how private final fields can be modified through reflection, including how Hibernate uses the technique to hydrate final entity fields. It also demonstrates how Java compile-time constants and inlining can cause modified primitive final fields to behave unexpectedly, while object fields such as Long can reflect the changed value.

## Source excerpt

Private final field modification is possible and it doesn't require a lot of work. Since you should not use this mechanism in real life there are cases when it is useful. For example this how is Hibernate using this to hydrate final entity fields. But when using final fields with Hibernate you should be extra careful how you declare them. Read more