<div dir="ltr">The javadocs for the class java.security.BasicPermission says, that the naming convention for BasicPermission names follows the hierarchical property naming convention with possible wildcards. AFAIU, *hierarchical property naming convention* assumes that you specify either a simple identifier like <i>user</i>, or a sequence of dot-separated identifiers like <i><a href="http://user.group.id">user.group.id</a> - </i>so what is the purpose for names like <i>user. </i>with a dot at the end? It seems like it contradicts the documentation and has no purpose. </div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 29, 2013 at 8:16 PM, Tom Hawtin <span dir="ltr"><<a href="mailto:tom.hawtin@oracle.com" target="_blank">tom.hawtin@oracle.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 29/11/2013 15:46, Alex Yursha wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
// make sure ap.path is longer so a.b.* doesn't imply a.b<br>
</blockquote></div>
^.<br>
Somebody has removed the full stop from the sentence fragment. I'll give you that this class API docs should be better.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
return (that.path.length() > this.path.length()) &&<br>
that.path.startsWith(this.<u></u>path);<br>
</blockquote>
<br>
</div><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
As the highlighted comment states, the length comparison check is<br>
performed in order to prevent such cases where "a.b.*" would imply<br>
"a.b". But the contract for java.lang.String.startsWith() is such that<br>
if the prefix length is greater than the string length than that test<br>
will fail. So it seems like java.security.BasicPermission.<u></u>implies()<br>
tries to duplicate the check that is performed by<br>
java.lang.String.startswith() out of the box.<br>
</blockquote>
<br></div>
So, suppose we had permissions with names "a.b.*" and "a.b.". These have paths "a.b." and "a.b." (respectively, or not). startsWith will return true, but the length comparison false.<br>
<br>
So<br>
<br>
- the check is not redundant<br>
- a.b. is not implied by a.b.*<br>
- BasicPermission does not correctly specify behaviour of wildcards<br>
(should probably have a CR)<span class="HOEnZb"><font color="#888888"><br>
<br>
Tom<br>
</font></span></blockquote></div><br></div>