JDK-4023100 : Class.getField()/getDeclaredField() doesn't find non-ASCII field name
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 1.1
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 1996-12-20
  • Updated: 2012-09-28
  • Resolved: 1997-10-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.1 1.1fcsFixed
Related Reports
Relates :  
Description
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)

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.1fcs INTEGRATED IN: 1.1fcs
14-06-2004

EVALUATION [saraiya 1/21/97] The native methods on Class, Field, Method and Constructor don't handle conversions betwee Java Strings and VM-maintained UTF strings correctly. In particular, javaString2CString truncates the high byte of unicode characters and makeJavaString doesn't deal with UTF8 encoding. Add two functions -- javaString2UTF and makeJavaStringUTF to centralize the conversions between Java Strings and UTF strings. See attachment utf-diffs.tar.Z for diffs. ----
11-06-2004

PUBLIC COMMENTS Class.getField()/getDeclaredField() doesn't find a non-ASCII field name.
10-06-2004