How to calculate the SHA256 hashes in a JAR's .SF signature file?

I'm currently trying to write a JAR signer as a side-project. In the Manifest file (.MF) I add the Base64-encoded SHA256 hash of each file like so:

Name: com/sample/MySample.class
SHA-256-Digest: TRqPMBJdQrIg5jHsAaoT1Rp5fjFjB8z/c2I+AHs5rX8=

In the signature file (.SF) I have to add another SHA256-hash for each file, but I'm not sure how it is calculated. The docs say, that it is the SHA256 hash of the corresponding manifest block, but hashing the string from "Name" to the end of the digest doesn't give me the same result as the original jarsigner.exe of the JDK.

How to calculate this hash?

I tried to hash various different things (e.g., rehash the hash, hash the whole block, hash only the name and the hash) but nothing worked. Are there any docs describing better what to hash?