[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Patch: FYI: fix PR 22963
From: |
Tom Tromey |
Subject: |
[cp-patches] Patch: FYI: fix PR 22963 |
Date: |
17 Sep 2005 18:50:23 -0600 |
I'm checking this in.
This fixes PR 22963 by changing the Charset loading code to use
ServiceFactory.
Tom
Index: ChangeLog
from Tom Tromey <address@hidden>
PR classpath/22963:
* java/nio/charset/Charset.java (forName): Javadoc fix.
(providers2): Use ServiceFactory.
Index: java/nio/charset/Charset.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/charset/Charset.java,v
retrieving revision 1.25
diff -u -r1.25 Charset.java
--- java/nio/charset/Charset.java 15 Sep 2005 14:42:36 -0000 1.25
+++ java/nio/charset/Charset.java 17 Sep 2005 23:20:41 -0000
@@ -38,19 +38,15 @@
package java.nio.charset;
+import gnu.classpath.ServiceFactory;
import gnu.classpath.SystemProperties;
-
import gnu.java.nio.charset.Provider;
import gnu.java.nio.charset.iconv.IconvProvider;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.spi.CharsetProvider;
import java.util.Collections;
-import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -174,7 +170,7 @@
* Returns the Charset instance for the charset of the given name.
*
* @param charsetName
- * @return
+ * @return the Charset instance for the indicated charset
* @throws UnsupportedCharsetException if this VM does not support
* the charset of the given name.
* @throws IllegalCharsetNameException if the given charset name is
@@ -265,24 +261,10 @@
{
try
{
- Enumeration en = ClassLoader.getSystemResources
- ("META-INF/services/java.nio.charset.spi.CharsetProvider");
+ Iterator i = ServiceFactory.lookupProviders(CharsetProvider.class);
LinkedHashSet set = new LinkedHashSet();
- while (en.hasMoreElements())
- {
- BufferedReader rdr = new BufferedReader(new InputStreamReader
- (((URL) (en.nextElement())).openStream()));
- while (true)
- {
- String s = rdr.readLine();
- if (s == null)
- break;
- CharsetProvider p =
- (CharsetProvider) ((Class.forName(s)).newInstance());
- set.add(p);
- }
- rdr.close();
- }
+ while (i.hasNext())
+ set.add(i.next());
providers = new CharsetProvider[set.size()];
set.toArray(providers);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] Patch: FYI: fix PR 22963,
Tom Tromey <=