Hi Bertrand,
On Thu, 2017-04-27 at 18:33 +0200, Bertrand Delacretaz wrote:
> Hi,
>
> Does anyone have a good trick for doing that? So far my best solution
> is reimplementing Manifest.write(..) which is kind of ugly.
No tricks here. I only have two ideas, and they are probably not as
good as overwriting Manifest#write:
1. Use reflection to change the inner HashMap fields to LinkedHashMap
2. Intercept the OutputStream after it has been written and apply the
sorting in-place
> The use case is to have reproducible builds when our slingstart
> plugin
> rewrites a manifest using our BSNRenamer[1] - currently multiple
> builds (on different platforms maybe) can lead to jars with
> MANIFEST.MF entries in a different order, making the jars different
> from a binary/digest point of view. Not the end of the world but
> inconvenient.
My hunch is that this ordering change happens because of it being ran
with different Java versions. There were some hash algorithm changes
[2] with Java 8 which lead to Hash{Map,Set} getting a different
iteration order.
Robert
>
> -Bertrand
>
> [1] https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi
> /src/main/java/org/apache/sling/commons/osgi/BSNRenamer.java
[2]: https://docs.oracle.com/javase/8/docs/technotes/guides/collections
/changes8.html