[
https://issues.apache.org/jira/browse/LANG-1214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15295834#comment-15295834
]
ASF GitHub Bot commented on LANG-1214:
--------------------------------------
GitHub user henryptung opened a pull request:
https://github.com/apache/commons-lang/pull/155
LANG-1214 Handle "void" in ClassUtils.getClass()
`getClass()` previously deferred to an array type to get the class,
but this fails for `void`, which lacks an array type.
Instead, map explicitly from primitive name to primitive class.
Added unit test line fails before change, passes after change.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/henryptung/commons-lang
lang-1214-getclass-void
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-lang/pull/155.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #155
----
commit 792f75436b81e9941bcd30b31dc3ad4424de602a
Author: Henry Tung <[email protected]>
Date: 2016-05-23T01:45:49Z
LANG-1214 Handle "void" in ClassUtils.getClass()
getClass() previously deferred to an array type to get the class,
but this fails for void, which lacks an array type.
Instead, map explicitly from primitive name to primitive class.
----
> ClassUtils.getClass(ClassLoader, String) fails for "void"
> ---------------------------------------------------------
>
> Key: LANG-1214
> URL: https://issues.apache.org/jira/browse/LANG-1214
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.*
> Affects Versions: 3.4
> Environment: Mac OS X
> java version "1.8.0_66"
> Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
> Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
> Reporter: Henry Tung
> Original Estimate: 10m
> Remaining Estimate: 10m
>
> ClassUtils.getClass(ClassUtils.class.getClassLoader(), "void") throws
> "ClassNotFoundException: [V".
> Root cause: ClassUtils contains an abbreviationMap for use in dealing with
> abbreviated primitive types like "[I" and "[J". However, [this
> commit|https://git-wip-us.apache.org/repos/asf?p=commons-lang.git;a=blobdiff;f=src/main/java/org/apache/commons/lang3/ClassUtils.java;h=c15636ed99af1913d8436a2761d2e3e45b0c8b1a;hp=2492182dd6a383bbec970be3c58799bf89929ccf;hb=1d6ab5b8c0bcc69fe5984b882374e856ec198d0e;hpb=609319df2216e00d8f158e5fc5ce7756134b7cb0]
> introduces a "void -> V" mapping for "completeness".
> This seems wholly erroneous, since the maps are used only for [primitive
> array
> abbreviations|http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29],
> and "void/V" is not among them.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)