FULL PRODUCT VERSION :
java version "1.6.0-rc-fastdebug"
Java(TM) SE Runtime Environment (build 1.6.0-rc-fastdebug-b93)
Java HotSpot(TM) Client VM (build 1.6.0-rc-fastdebug-b93-debug, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
sun.beans.editors.StringEditor does not handle the \n character correctly. It should replace it with the string "\\n", but instead passes it through as the carriage return character. This causes strings containing carriage returns to generate incorrect code.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
The below class is a good workaround. t must be registered with the PropertyEditorManager so that the bean manager can find it.
public class StringPropertyEditorSupport extends sun.beans.editors.StringEditor
{
/** Creates a new instance of StringPropertyEditorSupport */
public StringPropertyEditorSupport()
{
}
public String getJavaInitializationString()
{
String value = super.getJavaInitializationString();
value = value.replaceAll("\\n", "\\\\n\" +\n \"");
return value;
}
}