Lines on Windows OS end with CRLF (\r\n). Method org.jboss.osgi.metadata.ManifestBuilder.getManifest() does not count with this fact. If bytes.length == 511 then a line will have 513 bytes and method Manifest#read will throw IOException and the building of the manifest will fail.
The following line will crop byte \n:
and then the following condition will fail because the value of lbuf[--len] expression is '\r'.