Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Commit 03c826c

Browse files
committed
remove workaround for MS1252 bug (fixed in JDK5+)
svn path=/trunk/; revision=333
1 parent a581ac0 commit 03c826c

File tree

4 files changed

+3
-811
lines changed

4 files changed

+3
-811
lines changed

codemodel/codemodel/src/main/java/com/sun/codemodel/util/EncoderFactory.java

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -43,46 +43,20 @@
4343
*/
4444
package com.sun.codemodel.util;
4545

46-
import java.lang.reflect.Constructor;
4746
import java.nio.charset.Charset;
4847
import java.nio.charset.CharsetEncoder;
4948

5049
/**
5150
* Creates {@link CharsetEncoder} from a charset name.
5251
*
53-
* Fixes a MS1252 handling bug in JDK1.4.2.
54-
*
5552
* @author
5653
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
5754
*/
5855
public class EncoderFactory {
59-
60-
public static CharsetEncoder createEncoder( String encodin ) {
56+
57+
public static CharsetEncoder createEncoder( String encodin ) {
6158
Charset cs = Charset.forName(System.getProperty("file.encoding"));
6259
CharsetEncoder encoder = cs.newEncoder();
63-
64-
if( cs.getClass().getName().equals("sun.nio.cs.MS1252") ) {
65-
try {
66-
// at least JDK1.4.2_01 has a bug in MS1252 encoder.
67-
// specifically, it returns true for any character.
68-
// return a correct encoder to workaround this problem
69-
70-
// statically binding to MS1252Encoder will cause a Link error
71-
// (at least in IBM JDK1.4.1)
72-
@SuppressWarnings("unchecked")
73-
Class<? extends CharsetEncoder> ms1252encoder = (Class<? extends CharsetEncoder>) Class.forName("com.sun.codemodel.util.MS1252Encoder");
74-
Constructor<? extends CharsetEncoder> c = ms1252encoder.getConstructor(new Class[]{
75-
Charset.class
76-
});
77-
return c.newInstance(new Object[]{cs});
78-
} catch( Throwable t ) {
79-
// if something funny happens, ignore it and fall back to
80-
// a broken MS1252 encoder. It's probably still better
81-
// than choking here.
82-
return encoder;
83-
}
84-
}
85-
8660
return encoder;
8761
}
8862
}

codemodel/codemodel/src/main/java/com/sun/codemodel/util/MS1252Encoder.java

Lines changed: 0 additions & 238 deletions
This file was deleted.

0 commit comments

Comments
 (0)