Section 4.2.2 of JAX-RS spec says that when choosing the right MessageBodyWriter to do the job, the runtime needs to order them with the supported media type being the primary key and the generic type being the secondary key. The spec also says app-provided providers take precedence over implementation-provided ones (the spec is ambiguous wrt. whether this is supposed to be the primary key or tertiary key).
Based on the use-cases we've run into with Jersey, seems the right ordering should instead be based on the following criteria:
primary) java type more specific
secondary) media type more specific
tertiary) app-provided vs. impl-provided
Representative example (many similar can be found):
Any POJO provider (e.g. Jackson writer that writes any pojo to application/json) vs. spec-dictated providers - e.g. writer for java.io.InputStream (registered with @Produces("/") according to the spec
In this scenario, the jackson writer always wins (even if my resource method returns InputStream) as it has more specific media type and is application-provided. Which is obviously wrong.
I could not find any counter-example that would support the ordering that is currently in the spec.
See Section 4.2.2. Implementations are REQUIRED to provide a backward compatible flag for those applications that rely on the previous ordering.