[
https://issues.apache.org/jira/browse/LANG-535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759514#action_12759514
]
mark juchems edited comment on LANG-535 at 9/25/09 5:53 AM:
------------------------------------------------------------
So I put it all together in 1.5:
String sArray[] = new String[2];
sArray[0] = "mark";
sArray[1] = "is cool";
sArray.getClass().getSimpleName();
this returns: String[]
I guess the java team has spoken. I suggest deleting since 1.5 has an
alternative...
I still think I would rather have just the name and no brackets, however.
For my use I would have to do some additional editing. I am sending in an
Object[] or an Object into a method and need the same behavior for both.
This failed when I sent in an array:
protected void createXML(XStream xStream, PrintWriter pw, Object o) {
pw.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
xStream.alias(ClassUtils.getShortClassName(o, null),
o.getClass());
xStream.toXML(o, pw);
}
So I changed it to this:
protected void createXML(XStream xStream, PrintWriter pw, Object o, Class c) {
pw.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
xStream.alias(ClassUtils.getShortClassName(c), c);
xStream.toXML(o, pw);
}
Not a big change, but it is something..
was (Author: mjuchems):
So I put it all together in 1.5:
String sArray[] = new String[2];
sArray[0] = "mark";
sArray[1] = "is cool";
sArray.getClass().getSimpleName();
this returns: String[]
I guess the java team has spoken. I still think I would rather have just the
name and no brackets, however. For my use I would have to do some additional
editing.
I suggest deleting since 1.5 has an alternative...
> ClassUtils.getShortClassName() will not work with an array; it seems to add
> a semicolon to the end.
> ----------------------------------------------------------------------------------------------------
>
> Key: LANG-535
> URL: https://issues.apache.org/jira/browse/LANG-535
> Project: Commons Lang
> Issue Type: Bug
> Affects Versions: 2.4
> Environment: Java 1.4.2
> Reporter: mark juchems
> Priority: Minor
> Fix For: 3.0
>
>
> A semicolon is introduced into the class name at the end for all arrays...
> String sArray[] = new String[2];
> sArray[0] = "mark";
> sArray[1] = "is cool";
> String simpleString = "chris";
>
> assertEquals("String", ClassUtils.getShortClassName(simpleString, null));
> assertEquals("String;", ClassUtils.getShortClassName(sArray, null));
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.