You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by Apache Wiki <wi...@apache.org> on 2006/05/18 01:43:56 UTC

[Db-derby Wiki] Update of "AvoidNonPortableMethods" by SunithaKambhampati

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Db-derby Wiki" for change notification.

The following page has been changed by SunithaKambhampati:
http://wiki.apache.org/db-derby/AvoidNonPortableMethods

New page:
== Summary ==

Derby is written in java and the wonderful part is, it is thus expected to work across platforms without having the need to do any porting.  Write once, run anywhere :)   

But beware, there are constructors/methods/classes in Java that use default platform encoding and this can lead to non portable behavior across platforms.  For e.g.  new String(byte[]) uses default platform encoding to convert bytes to String.

Recently, when testing Derby on Z/OS, a number of issues were encountered because of usage of the encoding - unsafe methods in Derby code.

This page attempts to list the non portable methods in java that needs to be either avoided or investigated thoroughly as to why its use is required when writing Derby code. At the  bare minimum, it is advised to please add a comment if a usage of such a method is absolutely required.

This list covers cases in String class and java.io package and is no means the complete list of all the non-portable methods in java. So please add/edit if you come across another non-portable method/class

There is existing bug DERBY-1256 that is a placeholder to remove/investigate the usage of all the non-portable methods in derby code. Please add information to this jira entry if you find any other occurences of non-portable methods usage.

|| '''Non-portable method''' || '''Comments''' ||
|| || ||
||	String(byte[])	||		||
||	String(byte[],int,int)	||		||
||	String.getBytes()	||		||
||	ByteArrayOutputStream.toString()	||		||
||	ByteArrayOutputStream.toString(int hibyte)	||	Deprecated	||
||	DataInputStream.readLine()	||	also deprecated	||
||	File.toURL()	||	system dependent	||
||	File.toURI()	||	system dependent	||
||	InputStreamReader(InputStream)	||	Create an InputStreamReader that uses the default charset.	||
||	LineNumberInputStream	||	deprecated, This class incorrectly assumes that bytes adequately represent char	||
||	LineNumberReader.readLine()	||	unclear, but it seems like readLine() can cause problems on different platforms. Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.	||
||	ObjectInputStream.readLine()	||		||
||	OutputStreamWriter()	||	 Create an OutputStreamWriter that uses the default character encoding.	||
||	OutputStreamWriter.readLine()	||		||
||	PrintStream	||	All characters printed by a PrintStream are converted into bytes using the platform's default character encoding	||
||	PrintWriter	||	printf(float f)Print a floating-point number. The string produced by String.valueOf(float) is translated into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the write(int) method.	||
||	RandomAccessFile.readLine()	||	This method does not support the full Unicode character set.	||
||	StringBufferInputStream(deprecated)	||	This class does not properly convert characters into bytes	||


Status of Jira entries related to usage of non-encoding safe methods.

|| '''Jira Entry''' || '''Comments''' ||
|| || ||
||<#FF0000> [http://issues.apache.org/jira/browse/DERBY-1256 DERBY-1256] || Open,generic jira to remove/investigate usage of all encoding-unsafe and non portable methods in Derby||
||<#00FF00> [http://issues.apache.org/jira/browse/DERBY-900 DERBY-900] || Fixed ||
||<#00FF00> [http://issues.apache.org/jira/browse/DERBY-901 DERBY-901] || Fixed ||
||<#00FF00> [http://issues.apache.org/jira/browse/DERBY-902 DERBY-902] || Fixed ||
||<#00FF00> [http://issues.apache.org/jira/browse/DERBY-903 DERBY-903] || Fixed ||
||<#00FF00> [http://issues.apache.org/jira/browse/DERBY-972 DERBY-972] || Fixed ||
||<#00FF00> [http://issues.apache.org/jira/browse/DERBY-575 DERBY-575] || Fixed ||
||<#00FF00> [http://issues.apache.org/jira/browse/DERBY-1127 DERBY-1127] || Fixed ||
||<#00FF00> [http://issues.apache.org/jira/browse/DERBY-877 DERBY-877] || Fixed ||