-
Bug
-
Resolution: Fixed
-
P2
-
1.1
-
1.1fcs
-
generic
-
generic
-
Not verified
masayoshi.okutsu@Eng 1996-12-20
A field name in non-ASCII characters cannot be found using
Class.getField() or Class.getDeclaredField().
To reproduce, run the following:
Source program:
import java.lang.reflect.*;
public class fieldmini{
//
public static void main(String[] args){
Field field;
testField testfield = new testField();
Class c = testfield.getClass();
String fieldName = "\u30c6\u30b9\u30c8";
//
// getField()
//
try{
field = c.getField(fieldName);
}
catch(NoSuchFieldException e){ e.printStackTrace(); }
catch(SecurityException e){ e.printStackTrace(); }
//
// getDeclaredField()
//
try{
field = c.getDeclaredField(fieldName);
}
catch(NoSuchFieldException e){ e.printStackTrace(); }
catch(SecurityException e){ e.printStackTrace(); }
}
}
//
// class testField
//
class testField{
public final static int \u30c6\u30b9\u30c8 = 0;
public testField(){}
public static void test(){}
}
Execution result:
% java fieldmini
java.lang.NoSuchFieldException
at java.lang.Class.getField(Class.java)
at fieldmini.main(fieldmini.java:14)
java.lang.NoSuchFieldException
at java.lang.Class.getDeclaredField(Class.java)
at fieldmini.main(fieldmini.java:22)
masayoshi.okutsu@Eng 1996-12-20
See also the attachment. It tests non-ascii names for a class. (Written in EUCJIS)
- relates to
-
JDK-4023101 Class.getMethod()/getDeclaredMethod() doesn't find non-ASCII method name
- Closed