If one has NOT lost the ability to get into a jhana by the time of death, they WILL BE born in a Brahma realm corresponding to that jhana.
– That is true for an Ariya or anariya jhana.
The following details are important.
1. If one attains an Ariya jhana, that comes with or after getting into at least the Sotapanna Anugāmi stage. Then the ability to get into jhana will never be lost. Thus, they WILL BE born in a Brahma realm.
2. Conversely, anariya jhanas may be “lost.”
– Someone who attained an anariya jhāna may lose the ability to get into it later.
– For example, Devadatta had attained the highest (anariya) jhana but lost that ability after he injured the Buddha and was involved in Sanghabedha too. Thus, he lost the “good anantariya kamma” and gained a “bad anantariya kamma” by his death and was born in an apāya.