8340404: CharsetProvider specification updates

Reviewed-by: alanb, naoto
This commit is contained in:
Justin Lu 2024-09-27 18:26:08 +00:00
parent a7bfced605
commit 082125d61e
4 changed files with 178 additions and 10 deletions

View file

@ -33,17 +33,29 @@ import java.util.Iterator;
* Charset service-provider class.
*
* <p> A charset provider is a concrete subclass of this class that has a
* zero-argument constructor and some number of associated charset
* implementation classes. Charset providers may be installed in an instance
* of the Java platform as extensions. Providers may also be made available by
* adding them to the application class path or by some other
* platform-specific means. Charset providers are looked up via the current
* thread's {@link java.lang.Thread#getContextClassLoader() context class
* loader}.
* zero-argument constructor and some number of associated {@code Charset}
* implementation classes. Charset providers are deployed on the application
* module path or the application class path. In order to be looked up, charset
* providers must be visible to the {@link ClassLoader#getSystemClassLoader() system
* class loader}. See {@link java.util.ServiceLoader##developing-service-providers
* Deploying Service Providers} for further detail on deploying a charset
* provider as a module or on the class path.
*
* <p> A charset provider identifies itself with a provider-configuration file
* named {@code java.nio.charset.spi.CharsetProvider} in the resource
* directory {@code META-INF/services}. The file should contain a list of
* <p> For a charset provider deployed in a module, the <i>provides</i>
* directive must be specified in the module declaration. The provides directive
* specifies both the service and the service provider. In this case, the service
* is {@code java.nio.charset.spi.CharsetProvider}.
*
* <p> As an example, a charset provider deployed as a module might specify the
* following directive:
* <pre>{@code
* provides java.nio.charset.spi.CharsetProvider with com.example.ExternalCharsetProvider;
* }</pre>
*
* <p> For a charset provider deployed on the class path, it identifies itself
* with a provider-configuration file named {@code
* java.nio.charset.spi.CharsetProvider} in the resource directory
* {@code META-INF/services}. The file should contain a list of
* fully-qualified concrete charset-provider class names, one per line. A line
* is terminated by any one of a line feed ({@code '\n'}), a carriage return
* ({@code '\r'}), or a carriage return followed immediately by a line feed.