You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2015/12/28 14:38:09 UTC

svn commit: r1721916 - in /sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper: JspCompilationContext.java compiler/Compiler.java compiler/Generator.java compiler/Node.java compiler/TagFileProcessor.java

Author: cziegeler
Date: Mon Dec 28 13:38:08 2015
New Revision: 1721916

URL: http://svn.apache.org/viewvc?rev=1721916&view=rev
Log:
SLING-5404 : Recursive taglibs overwrite generated java/class file

Modified:
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Node.java
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java?rev=1721916&r1=1721915&r2=1721916&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java (original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java Mon Dec 28 13:38:08 2015
@@ -304,10 +304,6 @@ public class JspCompilationContext {
         return className;
     }
 
-    public void setServletClassName(String className) {
-        this.className = className;
-    }
-
     /**
      * Path of the JSP URI. Note that this is not a file name. This is
      * the context rooted URI of the JSP file.
@@ -388,13 +384,6 @@ public class JspCompilationContext {
     }
 
     /**
-     * The package name into which the servlet class is generated.
-     */
-    public void setServletPackageName(String servletPackageName) {
-        this.basePackageName = servletPackageName;
-    }
-
-    /**
      * Full path name of the Java file into which the servlet is being
      * generated.
      */

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java?rev=1721916&r1=1721915&r2=1721916&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java (original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java Mon Dec 28 13:38:08 2015
@@ -253,12 +253,7 @@ public abstract class Compiler {
             smapStr = SmapUtil.generateSmap(ctxt, pageNodes);
         }
 
-        // If any proto type .java and .class files was generated,
-        // the prototype .java may have been replaced by the current
-        // compilation (if the tag file is self referencing), but the
-        // .class file need to be removed, to make sure that javac would
-        // generate .class again from the new .java file just generated.
-        tfp.removeProtoTypeFiles(ctxt.getClassFileName());
+        tfp.removeProtoTypeFiles();
 
         return smapStr;
     }
@@ -313,7 +308,7 @@ public abstract class Compiler {
             }
         } finally {
             if (tfp != null) {
-                tfp.removeProtoTypeFiles(null);
+                tfp.removeProtoTypeFiles();
             }
             // Make sure these object which are only used during the
             // generation and compilation of the JSP page get
@@ -398,13 +393,14 @@ public abstract class Compiler {
         }
 
     }
-    
+
     protected boolean getDefaultIsSession() {
         return defaultIsSession;
     }
 
     private static final class CleanVisitor extends Node.Visitor {
 
+        @Override
         public void visit(final CustomTag n) throws JasperException {
             n.clean();
             visitBody(n);

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java?rev=1721916&r1=1721915&r2=1721916&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java (original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java Mon Dec 28 13:38:08 2015
@@ -195,6 +195,7 @@ class Generator {
              * contains more than one page directive with an 'info' attribute,
              * their values match.
              */
+            @Override
             public void visit(Node.PageDirective n) throws JasperException {
 
                 if (getServletInfoGenerated) {
@@ -217,6 +218,7 @@ class Generator {
                 out.println();
             }
 
+            @Override
             public void visit(Node.Declaration n) throws JasperException {
                 n.setBeginJavaLine(out.getJavaLine());
                 out.printMultiLn(new String(n.getText()));
@@ -225,6 +227,7 @@ class Generator {
             }
 
             // Custom Tags may contain declarations from tag plugins.
+            @Override
             public void visit(Node.CustomTag n) throws JasperException {
                 if (n.useTagPlugin()) {
                     if (n.getAtSTag() != null) {
@@ -268,6 +271,7 @@ class Generator {
              * and adds it to the list of tag handler pool names unless it is
              * already contained in it.
              */
+            @Override
             public void visit(Node.CustomTag n) throws JasperException {
 
                 if (!n.implementsSimpleTag()) {
@@ -324,6 +328,7 @@ class Generator {
                 vars = new Vector();
             }
 
+            @Override
             public void visit(Node.CustomTag n) throws JasperException {
 
                 if (n.getCustomNestingLevel() > 0) {
@@ -853,6 +858,7 @@ class Generator {
                     this.separator = separator;
                 }
 
+                @Override
                 public void visit(Node.ParamAction n) throws JasperException {
 
                     out.print(" + ");
@@ -880,6 +886,7 @@ class Generator {
             }
         }
 
+        @Override
         public void visit(Node.Expression n) throws JasperException {
             n.setBeginJavaLine(out.getJavaLine());
             out.printin("out.print(");
@@ -888,6 +895,7 @@ class Generator {
             n.setEndJavaLine(out.getJavaLine());
         }
 
+        @Override
         public void visit(Node.Scriptlet n) throws JasperException {
             n.setBeginJavaLine(out.getJavaLine());
             out.printMultiLn(n.getText());
@@ -895,6 +903,7 @@ class Generator {
             n.setEndJavaLine(out.getJavaLine());
         }
 
+        @Override
         public void visit(Node.ELExpression n) throws JasperException {
             n.setBeginJavaLine(out.getJavaLine());
             if (!pageInfo.isELIgnored() && (n.getEL() != null)) {
@@ -909,6 +918,7 @@ class Generator {
             n.setEndJavaLine(out.getJavaLine());
         }
 
+        @Override
         public void visit(Node.IncludeAction n) throws JasperException {
 
             String flush = n.getTextAttribute("flush");
@@ -1000,6 +1010,7 @@ class Generator {
             return result;
         }
 
+        @Override
         public void visit(Node.ForwardAction n) throws JasperException {
             Node.JspAttribute page = n.getPage();
 
@@ -1044,6 +1055,7 @@ class Generator {
             // XXX Not sure if we can eliminate dead codes after this.
         }
 
+        @Override
         public void visit(Node.GetProperty n) throws JasperException {
             String name = n.getTextAttribute("name");
             String property = n.getTextAttribute("property");
@@ -1081,6 +1093,7 @@ class Generator {
             n.setEndJavaLine(out.getJavaLine());
         }
 
+        @Override
         public void visit(Node.SetProperty n) throws JasperException {
             String name = n.getTextAttribute("name");
             String property = n.getTextAttribute("property");
@@ -1172,6 +1185,7 @@ class Generator {
             n.setEndJavaLine(out.getJavaLine());
         }
 
+        @Override
         public void visit(Node.UseBean n) throws JasperException {
 
             String name = n.getTextAttribute("id");
@@ -1370,6 +1384,7 @@ class Generator {
             return " " + attr + "=\"" + value + '\"';
         }
 
+        @Override
         public void visit(Node.PlugIn n) throws JasperException {
 
             /**
@@ -1383,6 +1398,7 @@ class Generator {
                     this.ie = ie;
                 }
 
+                @Override
                 public void visit(Node.ParamAction n) throws JasperException {
 
                     String name = n.getTextAttribute("name");
@@ -1605,10 +1621,12 @@ class Generator {
             n.setEndJavaLine(out.getJavaLine());
         }
 
+        @Override
         public void visit(Node.NamedAttribute n) throws JasperException {
             // Don't visit body of this tag - we already did earlier.
         }
 
+        @Override
         public void visit(Node.CustomTag n) throws JasperException {
 
             // Use plugin to generate more efficient code if there is one.
@@ -1754,6 +1772,7 @@ class Generator {
 
         private static final String DOUBLE_QUOTE = "\\\"";
 
+        @Override
         public void visit(Node.UninterpretedTag n) throws JasperException {
 
             n.setBeginJavaLine(out.getJavaLine());
@@ -1822,6 +1841,7 @@ class Generator {
             n.setEndJavaLine(out.getJavaLine());
         }
 
+        @Override
         public void visit(Node.JspElement n) throws JasperException {
 
             n.setBeginJavaLine(out.getJavaLine());
@@ -1889,6 +1909,7 @@ class Generator {
             }
         }
 
+        @Override
         public void visit(Node.TemplateText n) throws JasperException {
 
             String text = n.getText();
@@ -1997,6 +2018,7 @@ class Generator {
             n.setEndJavaLine(out.getJavaLine());
         }
 
+        @Override
         public void visit(Node.JspBody n) throws JasperException {
             if (n.getBody() != null) {
                 if (isSimpleTagHandler) {
@@ -2010,6 +2032,7 @@ class Generator {
             }
         }
 
+        @Override
         public void visit(Node.InvokeAction n) throws JasperException {
 
             n.setBeginJavaLine(out.getJavaLine());
@@ -2059,6 +2082,7 @@ class Generator {
             n.setEndJavaLine(out.getJavaLine());
         }
 
+        @Override
         public void visit(Node.DoBodyAction n) throws JasperException {
 
             n.setBeginJavaLine(out.getJavaLine());
@@ -2105,6 +2129,7 @@ class Generator {
             n.setEndJavaLine(out.getJavaLine());
         }
 
+        @Override
         public void visit(Node.AttributeGenerator n) throws JasperException {
             Node.CustomTag tag = n.getTag();
             Node.JspAttribute[] attrs = tag.getJspAttributes();
@@ -2128,7 +2153,7 @@ class Generator {
             TagHandlerInfo handlerInfo = (TagHandlerInfo) handlerInfosByShortName
                     .get(n.getLocalName());
             if (handlerInfo == null) {
-                handlerInfo = new TagHandlerInfo(n, n.getTagHandlerClass(), err);
+                handlerInfo = new TagHandlerInfo(n, n.getTagHandlerClass(), err, n.getTagHandlerClassName());
                 handlerInfosByShortName.put(n.getLocalName(), handlerInfo);
             }
             return handlerInfo;
@@ -2149,7 +2174,7 @@ class Generator {
                 String tagEvalVar, String tagPushBodyCountVar)
                 throws JasperException {
 
-            Class tagHandlerClass = handlerInfo.getTagHandlerClass();
+//            Class tagHandlerClass = handlerInfo.getTagHandlerClass();
 
             out.printin("//  ");
             out.println(n.getQName());
@@ -2159,8 +2184,7 @@ class Generator {
             declareScriptingVars(n, VariableInfo.AT_BEGIN);
             saveScriptingVars(n, VariableInfo.AT_BEGIN);
 
-            String tagHandlerClassName = JspUtil
-                    .getCanonicalName(tagHandlerClass);
+            String tagHandlerClassName = handlerInfo.getTagHandlerClassName();
             out.printin(tagHandlerClassName);
             out.print(" ");
             out.print(tagHandlerVar);
@@ -2398,7 +2422,7 @@ class Generator {
                 TagHandlerInfo handlerInfo, String tagHandlerVar)
                 throws JasperException {
 
-            Class tagHandlerClass = handlerInfo.getTagHandlerClass();
+//            Class tagHandlerClass = handlerInfo.getTagHandlerClass();
 
             n.setBeginJavaLine(out.getJavaLine());
             out.printin("//  ");
@@ -2408,8 +2432,7 @@ class Generator {
             declareScriptingVars(n, VariableInfo.AT_BEGIN);
             saveScriptingVars(n, VariableInfo.AT_BEGIN);
 
-            String tagHandlerClassName = JspUtil
-                    .getCanonicalName(tagHandlerClass);
+            String tagHandlerClassName = handlerInfo.getTagHandlerClassName();
             out.printin(tagHandlerClassName);
             out.print(" ");
             out.print(tagHandlerVar);
@@ -3828,7 +3851,7 @@ class Generator {
 
         private Hashtable propertyEditorMaps;
 
-        private Class tagHandlerClass;
+        private String tagHandlerClassName;
 
         /**
          * Constructor.
@@ -3841,9 +3864,9 @@ class Generator {
          * @param err
          *            Error dispatcher
          */
-        TagHandlerInfo(Node n, Class tagHandlerClass, ErrorDispatcher err)
+        TagHandlerInfo(Node n, Class tagHandlerClass, ErrorDispatcher err, String tagHandlerClassName)
                 throws JasperException {
-            this.tagHandlerClass = tagHandlerClass;
+            this.tagHandlerClassName = tagHandlerClassName;
             this.methodMaps = new Hashtable();
             this.propertyEditorMaps = new Hashtable();
 
@@ -3887,8 +3910,8 @@ class Generator {
         /**
          * XXX
          */
-        public Class getTagHandlerClass() {
-            return tagHandlerClass;
+        public String getTagHandlerClassName() {
+            return tagHandlerClassName;
         }
     }
 
@@ -3930,6 +3953,7 @@ class Generator {
             return out;
         }
 
+        @Override
         public String toString() {
             return charWriter.toString();
         }
@@ -3949,10 +3973,12 @@ class Generator {
                 try {
                     body.visit(new Node.Visitor() {
 
+                        @Override
                         public void doVisit(Node n) {
                             adjustJavaLine(n, offset);
                         }
 
+                        @Override
                         public void visit(Node.CustomTag n)
                                 throws JasperException {
                             Node.Nodes b = n.getBody();
@@ -4163,6 +4189,7 @@ class Generator {
             out.popIndent();
         }
 
+        @Override
         public String toString() {
             return classBuffer.toString();
         }

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Node.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Node.java?rev=1721916&r1=1721915&r2=1721916&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Node.java (original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Node.java Mon Dec 28 13:38:08 2015
@@ -485,6 +485,7 @@ abstract class Node implements TagConsta
             parentRoot = (Node.Root) r;
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -562,6 +563,7 @@ abstract class Node implements TagConsta
                     start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -586,6 +588,7 @@ abstract class Node implements TagConsta
             imports = new Vector();
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -634,6 +637,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -649,6 +653,7 @@ abstract class Node implements TagConsta
                     start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -672,6 +677,7 @@ abstract class Node implements TagConsta
             imports = new Vector();
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -721,6 +727,7 @@ abstract class Node implements TagConsta
                     nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -743,6 +750,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -764,6 +772,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -785,6 +794,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -799,6 +809,7 @@ abstract class Node implements TagConsta
             super(null, null, text, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -829,6 +840,7 @@ abstract class Node implements TagConsta
          *
          * @return The text string
          */
+        @Override
         public String getText() {
             String ret = text;
             if ((ret == null) && (body != null)) {
@@ -845,6 +857,7 @@ abstract class Node implements TagConsta
          * For the same reason as above, the source line information in the
          * contained TemplateText node should be used.
          */
+        @Override
         public Mark getStart() {
             if (text == null && body != null && body.size() > 0) {
                 return body.getNode(0).getStart();
@@ -870,6 +883,7 @@ abstract class Node implements TagConsta
                     start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -891,6 +905,7 @@ abstract class Node implements TagConsta
                     start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -911,6 +926,7 @@ abstract class Node implements TagConsta
                     start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -931,6 +947,7 @@ abstract class Node implements TagConsta
             this.type = type;
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -966,6 +983,7 @@ abstract class Node implements TagConsta
                     start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -994,6 +1012,7 @@ abstract class Node implements TagConsta
                     start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1014,6 +1033,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1037,6 +1057,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1068,6 +1089,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1097,6 +1119,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1120,6 +1143,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1151,6 +1175,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1184,6 +1209,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1219,6 +1245,7 @@ abstract class Node implements TagConsta
                     start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1252,6 +1279,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1291,6 +1319,7 @@ abstract class Node implements TagConsta
                     taglibAttrs, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1384,6 +1413,8 @@ abstract class Node implements TagConsta
 
         private Class tagHandlerClass;
 
+        private String tagHandlerClassName;
+
         private VariableInfo[] varInfos;
 
         private int customNestingLevel;
@@ -1450,6 +1481,7 @@ abstract class Node implements TagConsta
             this.prefix = prefix;
             this.tagInfo = tagInfo;
             this.tagHandlerClass = tagHandlerClass;
+            this.tagHandlerClassName = JspUtil.getCanonicalName(tagHandlerClass);
             this.customNestingLevel = makeCustomNestingLevel();
             this.childInfo = new ChildInfo();
 
@@ -1503,6 +1535,7 @@ abstract class Node implements TagConsta
             this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes();
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1590,6 +1623,20 @@ abstract class Node implements TagConsta
             tagHandlerClass = hc;
         }
 
+        public String getTagHandlerClassName() {
+            if ( this.tagHandlerClassName != null ) {
+                return tagHandlerClassName;
+            }
+            if ( this.tagHandlerClass != null ) {
+                return JspUtil.getCanonicalName(this.tagHandlerClass);
+            }
+            return null;
+        }
+
+        public void setTagHandlerClassName(String hc) {
+            tagHandlerClassName = hc;
+        }
+
         public boolean implementsIterationTag() {
             return implementsIterationTag;
         }
@@ -1788,6 +1835,7 @@ abstract class Node implements TagConsta
         }
 
         public void clean() {
+            tagHandlerClassName = null;
             tagHandlerClass = null;
             jspAttrs = null;
             tagData = null;
@@ -1816,6 +1864,7 @@ abstract class Node implements TagConsta
             this.tag = tag;
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1840,6 +1889,7 @@ abstract class Node implements TagConsta
                     start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1891,6 +1941,7 @@ abstract class Node implements TagConsta
             }
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -1899,6 +1950,7 @@ abstract class Node implements TagConsta
             return this.name;
         }
 
+        @Override
         public String getLocalName() {
             return this.localName;
         }
@@ -1931,11 +1983,13 @@ abstract class Node implements TagConsta
          * Since this method is only for attributes that are not rtexpr, we can
          * assume the body of the jsp:attribute is a template text.
          */
+        @Override
         public String getText() {
 
             class AttributeVisitor extends Visitor {
                 String attrValue = null;
 
+                @Override
                 public void visit(TemplateText txt) {
                     attrValue = new String(txt.getText());
                 }
@@ -1980,6 +2034,7 @@ abstract class Node implements TagConsta
             this.childInfo = new ChildInfo();
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }
@@ -2000,6 +2055,7 @@ abstract class Node implements TagConsta
             super(null, null, text, start, parent);
         }
 
+        @Override
         public void accept(Visitor v) throws JasperException {
             v.visit(this);
         }

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java?rev=1721916&r1=1721915&r2=1721916&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java (original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java Mon Dec 28 13:38:08 2015
@@ -48,7 +48,7 @@ import org.apache.sling.scripting.jsp.ja
 
 class TagFileProcessor {
 
-    private Vector tempVector;
+    private Vector<Compiler> tempVector;
 
     /**
      * A visitor the tag file
@@ -143,6 +143,7 @@ class TagFileProcessor {
             variableVector = new Vector();
         }
 
+        @Override
         public void visit(Node.TagDirective n) throws JasperException {
 
             JspUtil.checkAttributes("Tag directive", n, tagDirectiveAttrs, err);
@@ -185,6 +186,7 @@ class TagFileProcessor {
             return result;
         }
 
+        @Override
         public void visit(Node.AttributeDirective n) throws JasperException {
 
             JspUtil.checkAttributes("Attribute directive", n,
@@ -284,6 +286,7 @@ class TagFileProcessor {
             checkUniqueName(attrName, ATTR_NAME, n, tagAttributeInfo);
         }
 
+        @Override
         public void visit(Node.VariableDirective n) throws JasperException {
 
             JspUtil.checkAttributes("Variable directive", n,
@@ -528,8 +531,8 @@ class TagFileProcessor {
     /**
      * Compiles and loads a tagfile.
      */
-    private Class loadTagFile(Compiler compiler, String tagFilePath,
-            TagInfo tagInfo, PageInfo parentPageInfo) throws JasperException {
+    private void loadTagFile(Compiler compiler, String tagFilePath,
+            Node.CustomTag n, PageInfo parentPageInfo) throws JasperException {
 
         JspCompilationContext ctxt = compiler.getCompilationContext();
         JspRuntimeContext rctxt = ctxt.getRuntimeContext();
@@ -541,7 +544,7 @@ class TagFileProcessor {
 
             if (wrapper == null) {
                 wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt
-                      .getOptions(), tagFilePath, tagInfo, ctxt
+                      .getOptions(), tagFilePath, n.getTagInfo(), ctxt
                       .getRuntimeContext(), compiler.getDefaultIsSession(),
                       ctxt.getTagFileJarUrl(tagFilePath));
                 wrapper = rctxt.addWrapper(tagFilePath, wrapper);
@@ -554,26 +557,48 @@ class TagFileProcessor {
                 // for the tag file. TagInfo instance was created the last
                 // time the tag file was scanned for directives, and the tag
                 // file may have been modified since then.
-                wrapper.getJspEngineContext().setTagInfo(tagInfo);
+                wrapper.getJspEngineContext().setTagInfo(n.getTagInfo());
             }
 
             Class tagClazz;
             int tripCount = wrapper.incTripCount();
             try {
                 if (tripCount > 0) {
+                    final String postfix = "_" + String.valueOf(tripCount);
                     // When tripCount is greater than zero, a circular
                     // dependency exists. The circularily dependant tag
                     // file is compiled in prototype mode, to avoid infinite
                     // recursion.
-
-                    JspServletWrapper tempWrapper = new JspServletWrapper(ctxt
-                          .getServletContext(), ctxt.getOptions(),
-                          tagFilePath, tagInfo, ctxt.getRuntimeContext(),
+                    final String tempTagFilePath = tagFilePath + postfix;
+                    final TagInfo tempTagInfo = new JasperTagInfo(
+                            n.getTagInfo().getTagName(),
+                            n.getTagInfo().getTagClassName() + postfix,
+                            n.getTagInfo().getBodyContent(),
+                            n.getTagInfo().getInfoString(),
+                            n.getTagInfo().getTagLibrary(),
+                            n.getTagInfo().getTagExtraInfo(),
+                            n.getTagInfo().getAttributes(),
+                            n.getTagInfo().getDisplayName(),
+                            n.getTagInfo().getSmallIcon(),
+                            n.getTagInfo().getLargeIcon(),
+                            n.getTagInfo().getTagVariableInfos(),
+                            ((JasperTagInfo)n.getTagInfo()).getDynamicAttributesMapName());
+
+                    JspServletWrapper tempWrapper = new JspServletWrapper(
+                            ctxt.getServletContext(),
+                            ctxt.getOptions(),
+                            tagFilePath,
+                          tempTagInfo,
+                          ctxt.getRuntimeContext(),
                           compiler.getDefaultIsSession(),
-                          ctxt.getTagFileJarUrl(tagFilePath));
+                          ctxt.getTagFileJarUrl(tempTagFilePath));
                     tagClazz = tempWrapper.loadTagFilePrototype();
-                    tempVector.add(tempWrapper.getJspEngineContext()
-                          .getCompiler());
+                    tempVector.add(tempWrapper.getJspEngineContext().getCompiler());
+                    String name = JspUtil.getCanonicalName(tagClazz);
+                    final int underscorePos = name.lastIndexOf(postfix);
+                    if ( underscorePos > -1 ) {
+                        n.setTagHandlerClassName(name.substring(0, underscorePos));
+                    }
                 } else {
                     tagClazz = wrapper.loadTagFile();
                 }
@@ -597,7 +622,7 @@ class TagFileProcessor {
                 // ignore errors
             }
 
-            return tagClazz;
+            n.setTagHandlerClass(tagClazz);
 
         } finally {
             rctxt.unlockTagFileLoading(tagFilePath);
@@ -620,6 +645,7 @@ class TagFileProcessor {
             this.pageInfo = compiler.getPageInfo();
         }
 
+        @Override
         public void visit(Node.CustomTag n) throws JasperException {
             TagFileInfo tagFileInfo = n.getTagFileInfo();
             if (tagFileInfo != null) {
@@ -629,9 +655,8 @@ class TagFileProcessor {
                     // Omit tag file dependency info on jar files for now.
                     pageInfo.addDependant(tagFilePath);
                 }
-                Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
-                        pageInfo);
-                n.setTagHandlerClass(c);
+                loadTagFile(compiler, tagFilePath, n, pageInfo);
+
             }
             visitBody(n);
         }
@@ -640,35 +665,28 @@ class TagFileProcessor {
     /**
      * Implements a phase of the translation that compiles (if necessary) the
      * tag files used in a JSP files. The directives in the tag files are
-     * assumed to have been proccessed and encapsulated as TagFileInfo in the
+     * assumed to have been processed and encapsulated as TagFileInfo in the
      * CustomTag nodes.
      */
     public void loadTagFiles(Compiler compiler, Node.Nodes page)
             throws JasperException {
 
-        tempVector = new Vector();
+        tempVector = new Vector<Compiler>();
         page.visit(new TagFileLoaderVisitor(compiler));
     }
 
     /**
-     * Removed the java and class files for the tag prototype generated from the
+     * Removed the java files for the tag prototype generated from the
      * current compilation.
      *
-     * @param classFileName
-     *            If non-null, remove only the class file with with this name.
      */
-    public void removeProtoTypeFiles(String classFileName) {
-        Iterator iter = tempVector.iterator();
+    public void removeProtoTypeFiles() {
+        final Iterator<Compiler> iter = tempVector.iterator();
         while (iter.hasNext()) {
-            Compiler c = (Compiler) iter.next();
-            if (classFileName == null) {
-                c.removeGeneratedClassFiles();
-            } else if (classFileName.equals(c.getCompilationContext()
-                    .getClassFileName())) {
-                c.removeGeneratedClassFiles();
-                tempVector.remove(c);
-                return;
-            }
+            final Compiler c = iter.next();
+            c.removeGeneratedFiles();
+            // we don't remove the .class file as this is already loaded by the class loader
         }
+        tempVector.clear();
     }
 }