New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrected class name validation to no longer fail for Kotlin classes on class path containing special characters #1884
Corrected class name validation to no longer fail for Kotlin classes on class path containing special characters #1884
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one mandatory request exists in isValidBinaryClassName()
methods, to follow the definition in the JVMS.
Other feedback are just my 2 cents. Thanks for your PR!
return className.startsWith("[") && | ||
(isValidArrayFieldDescriptor(className.substring(1))) || | ||
isValidClassFieldDescriptor(className.substring(1)) || | ||
isValidBaseTypeFieldDescriptor(className.substring(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just my personal and unreasonable motivation. JIT could be enough.
return className.startsWith("[") && | |
(isValidArrayFieldDescriptor(className.substring(1))) || | |
isValidClassFieldDescriptor(className.substring(1)) || | |
isValidBaseTypeFieldDescriptor(className.substring(1)); | |
String tail = className.substring(1); | |
return className.startsWith("[") && | |
(isValidArrayFieldDescriptor(tail)) || | |
isValidClassFieldDescriptor(tail) || | |
isValidBaseTypeFieldDescriptor(tail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually thinks this improves readability too, so this might be a good change. 👍
However, I am concerned about the possibility of throwing an IndexOutOfBoundsException
if this is called with an empty string (instead of returning false). I have added an isEmpty()
check in the caller and documentation to mitigate this concern.
return isValidBinaryClassName(className) || | ||
isValidDottedClassName(className) || | ||
isValidArrayFieldDescriptor(className) || | ||
isValidClassFieldDescriptor(className); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Confirmed that all descriptions listed in the JVMS are covered.
Thanks for your quick and thorough review. I've attempted to address the comments you've raised and will be happy to make any further changes as necessary. 😄 |
Also added logic to allow existing cases where a field descriptor or dotted class name is provided instead of a slashed (binary) class name.
* Documented private methods in class name validity checker with links to JVM spec. * Cleaned up array type checking code. * Added test to ensure that empty class names are rejected.
7ba6ff1
to
0cfd02c
Compare
I am very sorry to be difficult, but one final review is required, if possible. |
Closes #1883.
Make sure these boxes are checked before submitting your PR -- thank you!
CHANGELOG.md
if you have changed SpotBugs code