FXMLLoader <?import?> checking code conventions too much?
Jim Graham
james.graham at oracle.com
Thu Jun 5 20:58:43 UTC 2014
In that code "i < n" is a tautology. It's purpose seems to be to
prevent the following "i+1"s from overflowing the string length, but
then it should be "i < n-1" or "n" should just be initialized to
name.length()-1 (and be called "max" or something to make its purpose
clear)...
...jim
On 6/5/14 9:05 AM, Guillaume Anctil wrote:
> Hi,
>
> on a project I work on, the code convention does not follow the Java
> standard and class names start with a lower case 'c': "cSomeClass.java"
>
> In the <?import ?> parsing of the FXMLLoader, the loadType function looks
> like this:
>
> int i = name.indexOf('.');
> int n = name.length();
> while (i != -1
> && i < n
> && Character.isLowerCase(name.charAt(i + 1))) {
> i = name.indexOf('.', i + 1);
> }
>
> if (i == -1 || i == n) {
> throw new ClassNotFoundException();
> }
>
> String packageName = name.substring(0, i);
> String className = name.substring(i + 1);
>
>
> This causes a ClassNotFoundException on our custom controls because of the
> lowercase check.
>
> I was wondering if a simple:
>
> int i = name.lastIndexOf('.');
>
> Instead of the lowercase check could be viable. The ClassNotFoundException
> would still be thrown later on, when trying to actually load the class.
>
> Is there a reason that I don't see why the convention _must_ be upheld in
> this case?
>
> Thanks.
>
More information about the openjfx-dev
mailing list