Bug 959478 - Add sun.nio.cs & sun.nio.ext paths to sun.jdk module
Summary: Add sun.nio.cs & sun.nio.ext paths to sun.jdk module
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Class Loading
Version: 6.0.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ER6
: EAP 6.2.0
Assignee: David M. Lloyd
QA Contact: Ladislav Thon
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-05-03 15:16 UTC by Brad Maxwell
Modified: 2018-12-01 15:10 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Missing packages in the `sun.jdk` module resulted in a `ServiceConfigurationError` exception being thrown when attempting to load custom character sets when using `sun.jdk`. This release of JBoss EAP 6 has added the missing packages `sun.nio.cs` and `sun.nio.cs.ext`, and as a result, custom character sets can be used with the `sun.jdk` module.
Clone Of:
Environment:
Last Closed: 2013-12-15 16:55:40 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Project with WAR to demonstrate the problem (327.24 KB, application/zip)
2013-05-14 21:53 UTC, Erhard Siegl
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker WFLY-1341 0 Major Resolved Missing charset-related paths from sun.jdk 2015-04-20 06:54:25 UTC

Description Brad Maxwell 2013-05-03 15:16:37 UTC
Description of problem:

sun.nio.cs & sun.nio.ext paths are not exposed in sun.jdk module, which causes an issue when we try to load a custom character set using ServiceLoader

Version-Release number of selected component (if applicable):

EAP 6.0.1 / EAP 6.1.0 Beta1

How reproducible:

Steps to Reproduce:
1. java.util.ServiceLoader.load(java.nio.charset.spi.CharsetProvider.class)
  
Actual results:

Caused by: java.util.ServiceConfigurationError: java.nio.charset.spi.CharsetProvider: Provider sun.nio.cs.ext.ExtendedCharsets not found
	at java.util.ServiceLoader.fail(ServiceLoader.java:214) [rt.jar:1.6.0_24]
	at java.util.ServiceLoader.access$400(ServiceLoader.java:164) [rt.jar:1.6.0_24]
	at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:350) [rt.jar:1.6.0_24]
	at java.util.ServiceLoader$1.next(ServiceLoader.java:421) [rt.jar:1.6.0_24]

Expected results:

No exception

Comment 1 David M. Lloyd 2013-05-03 16:20:17 UTC
The simple workaround is to use the variant of ServiceLoader.load() which accepts a class loader, and pass in null.  In fact this is almost always the right way to load things when you know they're part of the JDK.

Comment 2 Erhard Siegl 2013-05-14 21:53:18 UTC
Created attachment 747944 [details]
Project with WAR to demonstrate the problem

Comment 3 Erhard Siegl 2013-05-14 22:06:34 UTC
In this particular case we don't want to load a class from the JDK, but we created our own charset. But JBoss includes <path name="META-INF/services"/> in modules/sun/jdk/main/module.xml. Therefore it loads META-INF/services/java.nio.charset.spi.CharsetProvider from jre/lib/charsets.jar. But then it can't find sun.nio.cs.ext.ExtendedCharsets since this path is not included in the module. So it throws an exception before it gets to the custom service.
In my opinion sun/jdk/main/module.xml is not consistent. Either it should not include META-INF/services, or, if it does, it has to include the classes that are referenced in the extensions.

Comment 4 David M. Lloyd 2013-05-15 02:13:21 UTC
OK that makes sense.

Comment 5 Jaikiran Pai 2013-05-15 02:26:17 UTC
Added dev_ack+ on behalf of David.

Comment 9 Ladislav Thon 2013-10-07 12:05:56 UTC
I don't think this has been fixed correctly. Specifically, I belive that there is no such package as "sun.nio.ext" -- instead, it should have been "sun.nio.cs.ext". Moving back to assigned.

On the other hand, I admit I'm not expert in this area, so I'd like to be proven wrong :-)

Comment 12 Ladislav Thon 2013-10-11 06:52:55 UTC
I took the liberty to fix this myself. Here's the upstream pull request: https://github.com/wildfly/wildfly/pull/5259

Comment 17 Ladislav Thon 2013-10-21 09:13:05 UTC
Verified with EAP 6.2.0.ER6.


Note You need to log in before you can comment on or make changes to this bug.