tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java JspUtil.java
Date Wed, 02 Mar 2005 20:56:03 GMT
markt       2005/03/02 12:56:03

  Modified:    jasper2/src/share/org/apache/jasper/compiler Tag:
                        tomcat_4_branch Generator.java JspUtil.java
  Log:
  Port fix for 22867 tag handlers can't be inner/nested classes from TC5
   - TC4 port provided by Steven Parkes in bug 24586
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.35.2.28 +14 -10    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
  
  Index: Generator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
  retrieving revision 1.35.2.27
  retrieving revision 1.35.2.28
  diff -u -r1.35.2.27 -r1.35.2.28
  --- Generator.java	22 Feb 2005 22:00:54 -0000	1.35.2.27
  +++ Generator.java	2 Mar 2005 20:56:02 -0000	1.35.2.28
  @@ -648,7 +648,7 @@
               if (beanInfo.checkVariable(name)) {
                   // Bean is defined using useBean, introspect at compile time
                   Class bean = beanInfo.getBeanType(name);
  -                String beanName = bean.getName();
  +                String beanName = JspUtil.getCanonicalName(bean);
                   java.lang.reflect.Method meth =
                       JspRuntimeLibrary.getReadMethod(bean, property);
                   String methodName = meth.getName();
  @@ -1293,21 +1293,23 @@
               declareScriptingVars(n, VariableInfo.AT_BEGIN);
               saveScriptingVars(n, VariableInfo.AT_BEGIN);
   
  -            out.printin(tagHandlerClass.getName());
  +            String tagHandlerClassName =
  +                JspUtil.getCanonicalName(tagHandlerClass);
  +            out.printin(tagHandlerClassName);
               out.print(" ");
               out.print(tagHandlerVar);
               out.print(" = ");
               if (ctxt.getOptions().isPoolingEnabled()) {
                   out.print("(");
  -                out.print(tagHandlerClass.getName());
  +                out.print(tagHandlerClassName);
                   out.print(") ");
                   out.print(n.getTagHandlerPoolName());
                   out.print(".get(");
  -                out.print(tagHandlerClass.getName());
  +                out.print(tagHandlerClassName);
                   out.println(".class);");
               } else {
                   out.print("new ");
  -                out.print(tagHandlerClass.getName());
  +                out.print(tagHandlerClassName);
                   out.println("();");
               }
   
  @@ -1750,11 +1752,12 @@
                       throws JasperException {
               
               if (propEditorClass != null) {
  -                return "(" + c.getName()
  +                String className = JspUtil.getCanonicalName(c);
  +                return "(" + className
                       + ")JspRuntimeLibrary.getValueFromBeanInfoPropertyEditor("
  -                    + c.getName() + ".class, \"" + attrName + "\", "
  +                    + className + ".class, \"" + attrName + "\", "
                       + quote(s) + ", "
  -                    + propEditorClass.getName() + ".class)";
  +                    + JspUtil.getCanonicalName(propEditorClass) + ".class)";
               } else if (c == String.class) {
                   return quote(s);
               } else if (c == boolean.class) {
  @@ -1808,9 +1811,10 @@
               } else if (c == Object.class) {
                   return "new String(" + quote(s) + ")";
               } else {
  -                return "(" + c.getName()
  +                String className = JspUtil.getCanonicalName(c);
  +                return "(" + className
                       + ")JspRuntimeLibrary.getValueFromPropertyEditorManager("
  -                    + c.getName() + ".class, \"" + attrName + "\", "
  +                    + className + ".class, \"" + attrName + "\", "
                       + quote(s) + ")";
               }
           }   
  
  
  
  1.4.2.4   +29 -0     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspUtil.java
  
  Index: JspUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspUtil.java,v
  retrieving revision 1.4.2.3
  retrieving revision 1.4.2.4
  diff -u -r1.4.2.3 -r1.4.2.4
  --- JspUtil.java	25 Aug 2004 20:53:31 -0000	1.4.2.3
  +++ JspUtil.java	2 Mar 2005 20:56:03 -0000	1.4.2.4
  @@ -423,6 +423,35 @@
           }
           return b;
       }
  +
  +    // javac -classpath ~mint/tomcat/common/lib/ant.jar:~mint/tomcat/common/endorsed/xml-apis.jar:~mint/tomcat/common/lib/servlet.jar
`find . -name \*.java ` 
  +
  +
  +    /**
  +     * Compute the canonical name from a Class instance.  Note that a
  +     * simple replacment of '$' with '.' of a binary name would not work,
  +     * as '$' is a legal Java Identifier character.
  +     * @param c A instance of java.lang.Class
  +     * @return  The canonical name of c.
  +     */
  +    public static String getCanonicalName(Class c) {
  +
  +        String binaryName = c.getName();
  +        c = c.getDeclaringClass();
  +
  +        if (c == null) {
  +            return binaryName;
  +        }
  +
  +        StringBuffer buf = new StringBuffer(binaryName);
  +        do {
  +            buf.setCharAt(c.getName().length(), '.');
  +            c = c.getDeclaringClass();
  +        } while ( c != null);
  +
  +        return buf.toString();
  +    }
  +
   }
   
   class MyEntityResolver implements EntityResolver {
  
  
  

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


Mime
View raw message