0

I am working on migration my application to java9, I found that I can set Add-Opens in my manifest file to open some java internal packages for reflection usage. I am thinking fields like Add-Opens are only support after java9, so I wonder what will happen if I run it using lower version like java8. Will those unrecognized fields (general unrecognized fields not specific to Add-Opens) in the manifest file be ignored in java8? What impact they can have on the application when running on java8? Thank you.

  • Specifically for Add-Opens, I think the security functionality that manifest entry enables in modern JVMs is essentially the default behavior in 8 (i.e. you can already do reflection and call private methods, etc) – Gus Jun 08 '22 at 17:32
  • 1
    The [java.util.jar package documentation](https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/util/jar/package-summary.html) links to [the manifest specification](https://docs.oracle.com/en/java/javase/18/docs/specs/jar/jar.html#notes-on-manifest-and-signature-files), which states: “In all cases for all sections, attributes which are not understood are ignored.” – VGR Jun 08 '22 at 18:34
  • 1
    Just note that the Add-Opens manifest attribute only works when your whole application is a single jar and you start it by using `java -jar` – Thiago Henrique Hupner Jun 09 '22 at 12:20
  • 1
    @ThiagoHenriqueHupner, I think as long as I am using java -jar to run the executable jar it doesn't have to be a single jar right. It can have classpath folder outside jar, we just specify that in our executable jar's manifest file. – askaquestion Jun 09 '22 at 14:06

1 Answers1

0

Thanks for VGR's comment, this link for oracle official document on manifest states that Attributes which are not understood are ignored. Such attributes may include implementation specific information used by applications.

Reference: https://docs.oracle.com/en/java/javase/18/docs/specs/jar/jar.html#overview

  • 2
    In your specific case, it might be helpful to know that [Java 8’s policy](https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Manifest-Overview) was already the same. – Holger Jun 09 '22 at 06:51