tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1140693 - in /tomcat/trunk/java/org/apache/jasper/compiler: Generator.java JspUtil.java
Date Tue, 28 Jun 2011 15:56:23 GMT
Author: markt
Date: Tue Jun 28 15:56:23 2011
New Revision: 1140693

URL: http://svn.apache.org/viewvc?rev=1140693&view=rev
Log:
Additional fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=36362 to address regression
for attributes with names that include underscores

Modified:
    tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
    tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java

Modified: tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Generator.java?rev=1140693&r1=1140692&r2=1140693&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Generator.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Tue Jun 28 15:56:23 2011
@@ -3675,7 +3675,8 @@ class Generator {
                 out.print(JspUtil.toJavaSourceType(attrInfos[i].getTypeName()));
                 out.print(" ");
             }
-            out.print(JspUtil.makeJavaIdentifier(attrInfos[i].getName()));
+            out.print(JspUtil.makeJavaIdentifier(
+                    attrInfos[i].getName(), false));
             out.println(";");
         }
         out.println();
@@ -3683,7 +3684,7 @@ class Generator {
         // Define attribute getter and setter methods
         for (int i = 0; i < attrInfos.length; i++) {
             String javaName =
-                JspUtil.makeJavaIdentifier(attrInfos[i].getName());
+                JspUtil.makeJavaIdentifier(attrInfos[i].getName(), false);
 
             // getter method
             out.printin("public ");

Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java?rev=1140693&r1=1140692&r2=1140693&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java Tue Jun 28 15:56:23 2011
@@ -804,15 +804,29 @@ public class JspUtil {
      * @return Legal Java identifier corresponding to the given identifier
      */
     public static final String makeJavaIdentifier(String identifier) {
+        return makeJavaIdentifier(identifier, true);
+    }
+    
+    /**
+     * Converts the given identifier to a legal Java identifier.
+     * 
+     * @param identifier
+     *            Identifier to convert
+     * 
+     * @return Legal Java identifier corresponding to the given identifier
+     */
+    public static final String makeJavaIdentifier(String identifier,
+            boolean periodToUnderscore) {
         StringBuilder modifiedIdentifier = new StringBuilder(identifier.length());
         if (!Character.isJavaIdentifierStart(identifier.charAt(0))) {
             modifiedIdentifier.append('_');
         }
         for (int i = 0; i < identifier.length(); i++) {
             char ch = identifier.charAt(i);
-            if (Character.isJavaIdentifierPart(ch) && ch != '_') {
+            if (Character.isJavaIdentifierPart(ch) &&
+                    (ch != '_' || !periodToUnderscore)) {
                 modifiedIdentifier.append(ch);
-            } else if (ch == '.') {
+            } else if (ch == '.' && periodToUnderscore) {
                 modifiedIdentifier.append('_');
             } else {
                 modifiedIdentifier.append(mangleChar(ch));



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message