51 public static void main(String[] args) throws Exception { 52 // build the set of all Charset subclasses in the 53 // two known charset implementation packages 54 Set charsets = new HashSet(); 55 addCharsets(charsets, "sun.nio.cs"); 56 addCharsets(charsets, "sun.nio.cs.ext"); 57 58 // remove the charsets that the API says are available 59 Collection availableCharsets = Charset.availableCharsets().values(); 60 Iterator iter = availableCharsets.iterator(); 61 while (iter.hasNext()) { 62 charsets.remove(((Charset) iter.next()).getClass()); 63 } 64 65 // remove the known pseudo-charsets that serve only to implement 66 // other charsets, but shouldn't be known to the public 67 charsets.remove(Class.forName("sun.nio.cs.Unicode")); 68 charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022")); 69 charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022_CN_GB")); 70 charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022_CN_CNS")); 71 72 // report the charsets that are implemented but not available 73 iter = charsets.iterator(); 74 while (iter.hasNext()) { 75 System.out.println("Unused Charset subclass: " + ((Class) iter.next()).getName()); 76 } 77 if (charsets.size() > 0) { 78 throw new RuntimeException(); 79 } 80 } 81 82 private static Vector classPathSegments = new Vector(); 83 84 private static void addCharsets(Set charsets, final String packageName) 85 throws Exception { 86 87 String classPath = 88 (String) java.security.AccessController.doPrivileged( 89 new sun.security.action.GetPropertyAction("sun.boot.class.path")); 90 String s = | 51 public static void main(String[] args) throws Exception { 52 // build the set of all Charset subclasses in the 53 // two known charset implementation packages 54 Set charsets = new HashSet(); 55 addCharsets(charsets, "sun.nio.cs"); 56 addCharsets(charsets, "sun.nio.cs.ext"); 57 58 // remove the charsets that the API says are available 59 Collection availableCharsets = Charset.availableCharsets().values(); 60 Iterator iter = availableCharsets.iterator(); 61 while (iter.hasNext()) { 62 charsets.remove(((Charset) iter.next()).getClass()); 63 } 64 65 // remove the known pseudo-charsets that serve only to implement 66 // other charsets, but shouldn't be known to the public 67 charsets.remove(Class.forName("sun.nio.cs.Unicode")); 68 charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022")); 69 charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022_CN_GB")); 70 charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022_CN_CNS")); 71 charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0208_Solaris")); 72 charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0208_MS932")); 73 charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0212_MS5022X")); 74 charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0212_Solaris")); 75 charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0208_MS5022X")); 76 77 // report the charsets that are implemented but not available 78 iter = charsets.iterator(); 79 while (iter.hasNext()) { 80 System.out.println("Unused Charset subclass: " + ((Class) iter.next()).getName()); 81 } 82 if (charsets.size() > 0) { 83 throw new RuntimeException(); 84 } 85 } 86 87 private static Vector classPathSegments = new Vector(); 88 89 private static void addCharsets(Set charsets, final String packageName) 90 throws Exception { 91 92 String classPath = 93 (String) java.security.AccessController.doPrivileged( 94 new sun.security.action.GetPropertyAction("sun.boot.class.path")); 95 String s = |