On 28/06/2011 12:21, Konstantin Kolinko wrote: > 2011/6/28 Mark Thomas <ma...@apache.org>: >> On 28/06/2011 11:38, Konstantin Kolinko wrote: >>> 2011/6/28 Mark Thomas <ma...@apache.org>: >>> >>> There is one more problem: you cannot introduce new variables that >>> will be seen by user's code, unless those are prefixed with reserved >>> prefix of "jsp_" ( "_jsp_") per JSP.9.1.2. That is because someone can >>> declare a local variable with the same name. >> >> JSP.9.1.2 certainly implies that but enforcing that would break the >> <%=attributeName%> usage. I'm happy not worrying about that for now. >> >>>> That said, I take the point regarding regressions. I'm sure lots of >>>> folks will have used <%=attributeName%> or ${attributeName} as a >>>> shortcut although I don't currently see anything to support that usage >>>> in the JSP specification. >> >> I was thinking along these lines: >> >> Index: java/org/apache/jasper/compiler/JspUtil.java >> =================================================================== >> --- java/org/apache/jasper/compiler/JspUtil.java (revision 1140509) >> +++ java/org/apache/jasper/compiler/JspUtil.java (working copy) >> @@ -810,10 +810,8 @@ >> } >> for (int i = 0; i < identifier.length(); i++) { >> char ch = identifier.charAt(i); >> - if (Character.isJavaIdentifierPart(ch) && ch != '_') { >> + if (Character.isJavaIdentifierPart(ch)) { >> modifiedIdentifier.append(ch); >> - } else if (ch == '.') { >> - modifiedIdentifier.append('_'); >> } else { >> modifiedIdentifier.append(mangleChar(ch)); >> } >> >> >> Essentially, no longer treat '.' as a special case. That removes the >> needs to escape _ which should prevent any regressions. However, I do >> wonder why '.' was treated as a special case in the first place. Time to >> do some testing...
It appears to be OK - at least for the unit tests. > IMHO it is '_' that was treated as special char, because mangleChar() > prepends '_' as well. Otherwise the mangling will be unreversible. Does that matter? Do we need to able to reverse this? > The use case of '.' is just to use shorter name for a frequent use case. > E.g. "index.jsp" -> "index_jsp.class". It would be nice to keep that. I suppose we could add a periodToUnderscore parameter to makeJavaIdentifier() and essnetially have both approaches. The current one for file names, the new one for variable names. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org