JDK-7199750 : Loading sequence of service provider is changed
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-09-20
  • Updated: 2013-01-07
  • Resolved: 2012-11-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
8 b66Fixed
Related Reports
Relates :  
Beginning from Java 8 b55, when there are mutiple provider-configuration files with same name, the sequence of loading the service provider is changed.

For exmaple,
pseudolocales1.jar and pseudolocales2.jar are all in the java extension directory. 

pseudolocales1/META-INF/services/java.util.spi.CurrencyNameProvider points to CurrencyNameProviderImpl1
pseudolocales2/META-INF/services/java.util.spi.CurrencyNameProvider points to CurrencyNameProviderImpl2

Before 8 b55, for example, in 8 b54, JRE loads CurrencyNameProviderImpl1 first and then CurrencyNameProviderImpl2, but from 8 b55, CurrencyNameProviderImpl2 is loaded first.

Verified in b67

Sorry that I closed the issue as verified based on PIT build. I set back it to the current status fixed in team.

verified in b65

In JDK7, SPI provider implementations are kept in a LinkedHashSet in the order that ServiceLoader.loadInstalled() enumerates. And they are examined in that order for selecting the appropriate implementations for a requested locale. With the change for JEP 127, now it is changed to LIFO style, ie., if two distinct SPI implementations provide the service for the same locale, the one returned from ServiceLoader.loadInstalled() later was being used. This needs to be corrected to be compatible with JDK7.

Reopening it to investigate the new code hasn't done some stupid thing...

I created JDK-8000997 to deal with the issue mentioned above. The possible original issue described in this bug (which is actually not observed due to the bug 8000997) will not be fixed, as we cannot guarantee the same order with JDK7 implementation, which uses the Set interface for retaining the installed providers.

Turned out that in the new implementation, only one SPI implementation is allowed to be loaded. This needs to be corrected.