SLING-5404 : Recursive taglibs overwrite generated java/class file
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1721916 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
index 8ec6168..a8bea31 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
@@ -304,10 +304,6 @@
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 @@
}
/**
- * 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.
*/
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
index abf16c8..c2f9694 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
@@ -253,12 +253,7 @@
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 @@
}
} 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 @@
}
}
-
+
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);
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java
index e305510..bd55309 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java
@@ -195,6 +195,7 @@
* 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 @@
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 @@
}
// 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 @@
* 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 @@
vars = new Vector();
}
+ @Override
public void visit(Node.CustomTag n) throws JasperException {
if (n.getCustomNestingLevel() > 0) {
@@ -853,6 +858,7 @@
this.separator = separator;
}
+ @Override
public void visit(Node.ParamAction n) throws JasperException {
out.print(" + ");
@@ -880,6 +886,7 @@
}
}
+ @Override
public void visit(Node.Expression n) throws JasperException {
n.setBeginJavaLine(out.getJavaLine());
out.printin("out.print(");
@@ -888,6 +895,7 @@
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 @@
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 @@
n.setEndJavaLine(out.getJavaLine());
}
+ @Override
public void visit(Node.IncludeAction n) throws JasperException {
String flush = n.getTextAttribute("flush");
@@ -1000,6 +1010,7 @@
return result;
}
+ @Override
public void visit(Node.ForwardAction n) throws JasperException {
Node.JspAttribute page = n.getPage();
@@ -1044,6 +1055,7 @@
// 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 @@
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 @@
n.setEndJavaLine(out.getJavaLine());
}
+ @Override
public void visit(Node.UseBean n) throws JasperException {
String name = n.getTextAttribute("id");
@@ -1370,6 +1384,7 @@
return " " + attr + "=\"" + value + '\"';
}
+ @Override
public void visit(Node.PlugIn n) throws JasperException {
/**
@@ -1383,6 +1398,7 @@
this.ie = ie;
}
+ @Override
public void visit(Node.ParamAction n) throws JasperException {
String name = n.getTextAttribute("name");
@@ -1605,10 +1621,12 @@
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 @@
private static final String DOUBLE_QUOTE = "\\\"";
+ @Override
public void visit(Node.UninterpretedTag n) throws JasperException {
n.setBeginJavaLine(out.getJavaLine());
@@ -1822,6 +1841,7 @@
n.setEndJavaLine(out.getJavaLine());
}
+ @Override
public void visit(Node.JspElement n) throws JasperException {
n.setBeginJavaLine(out.getJavaLine());
@@ -1889,6 +1909,7 @@
}
}
+ @Override
public void visit(Node.TemplateText n) throws JasperException {
String text = n.getText();
@@ -1997,6 +2018,7 @@
n.setEndJavaLine(out.getJavaLine());
}
+ @Override
public void visit(Node.JspBody n) throws JasperException {
if (n.getBody() != null) {
if (isSimpleTagHandler) {
@@ -2010,6 +2032,7 @@
}
}
+ @Override
public void visit(Node.InvokeAction n) throws JasperException {
n.setBeginJavaLine(out.getJavaLine());
@@ -2059,6 +2082,7 @@
n.setEndJavaLine(out.getJavaLine());
}
+ @Override
public void visit(Node.DoBodyAction n) throws JasperException {
n.setBeginJavaLine(out.getJavaLine());
@@ -2105,6 +2129,7 @@
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 @@
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 @@
String tagEvalVar, String tagPushBodyCountVar)
throws JasperException {
- Class tagHandlerClass = handlerInfo.getTagHandlerClass();
+// Class tagHandlerClass = handlerInfo.getTagHandlerClass();
out.printin("// ");
out.println(n.getQName());
@@ -2159,8 +2184,7 @@
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 @@
TagHandlerInfo handlerInfo, String tagHandlerVar)
throws JasperException {
- Class tagHandlerClass = handlerInfo.getTagHandlerClass();
+// Class tagHandlerClass = handlerInfo.getTagHandlerClass();
n.setBeginJavaLine(out.getJavaLine());
out.printin("// ");
@@ -2408,8 +2432,7 @@
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 @@
private Hashtable propertyEditorMaps;
- private Class tagHandlerClass;
+ private String tagHandlerClassName;
/**
* Constructor.
@@ -3841,9 +3864,9 @@
* @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 @@
/**
* XXX
*/
- public Class getTagHandlerClass() {
- return tagHandlerClass;
+ public String getTagHandlerClassName() {
+ return tagHandlerClassName;
}
}
@@ -3930,6 +3953,7 @@
return out;
}
+ @Override
public String toString() {
return charWriter.toString();
}
@@ -3949,10 +3973,12 @@
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 @@
out.popIndent();
}
+ @Override
public String toString() {
return classBuffer.toString();
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Node.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Node.java
index 36d40c6..90d378a 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Node.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Node.java
@@ -485,6 +485,7 @@
parentRoot = (Node.Root) r;
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -562,6 +563,7 @@
start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -586,6 +588,7 @@
imports = new Vector();
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -634,6 +637,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -649,6 +653,7 @@
start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -672,6 +677,7 @@
imports = new Vector();
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -721,6 +727,7 @@
nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -743,6 +750,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -764,6 +772,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -785,6 +794,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -799,6 +809,7 @@
super(null, null, text, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -829,6 +840,7 @@
*
* @return The text string
*/
+ @Override
public String getText() {
String ret = text;
if ((ret == null) && (body != null)) {
@@ -845,6 +857,7 @@
* 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 @@
start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -891,6 +905,7 @@
start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -911,6 +926,7 @@
start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -931,6 +947,7 @@
this.type = type;
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -966,6 +983,7 @@
start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -994,6 +1012,7 @@
start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1014,6 +1033,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1037,6 +1057,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1068,6 +1089,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1097,6 +1119,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1120,6 +1143,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1151,6 +1175,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1184,6 +1209,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1219,6 +1245,7 @@
start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1252,6 +1279,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1291,6 +1319,7 @@
taglibAttrs, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1384,6 +1413,8 @@
private Class tagHandlerClass;
+ private String tagHandlerClassName;
+
private VariableInfo[] varInfos;
private int customNestingLevel;
@@ -1450,6 +1481,7 @@
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 @@
this.implementsDynamicAttributes = tagInfo.hasDynamicAttributes();
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1590,6 +1623,20 @@
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 @@
}
public void clean() {
+ tagHandlerClassName = null;
tagHandlerClass = null;
jspAttrs = null;
tagData = null;
@@ -1816,6 +1864,7 @@
this.tag = tag;
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1840,6 +1889,7 @@
start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1891,6 +1941,7 @@
}
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -1899,6 +1950,7 @@
return this.name;
}
+ @Override
public String getLocalName() {
return this.localName;
}
@@ -1931,11 +1983,13 @@
* 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 @@
this.childInfo = new ChildInfo();
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
@@ -2000,6 +2055,7 @@
super(null, null, text, start, parent);
}
+ @Override
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
index 3247086..ea5b729 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
@@ -48,7 +48,7 @@
class TagFileProcessor {
- private Vector tempVector;
+ private Vector<Compiler> tempVector;
/**
* A visitor the tag file
@@ -143,6 +143,7 @@
variableVector = new Vector();
}
+ @Override
public void visit(Node.TagDirective n) throws JasperException {
JspUtil.checkAttributes("Tag directive", n, tagDirectiveAttrs, err);
@@ -185,6 +186,7 @@
return result;
}
+ @Override
public void visit(Node.AttributeDirective n) throws JasperException {
JspUtil.checkAttributes("Attribute directive", n,
@@ -284,6 +286,7 @@
checkUniqueName(attrName, ATTR_NAME, n, tagAttributeInfo);
}
+ @Override
public void visit(Node.VariableDirective n) throws JasperException {
JspUtil.checkAttributes("Variable directive", n,
@@ -528,8 +531,8 @@
/**
* 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 @@
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 @@
// 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.
+ 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, tagInfo, ctxt.getRuntimeContext(),
+ 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 @@
// ignore errors
}
- return tagClazz;
+ n.setTagHandlerClass(tagClazz);
} finally {
rctxt.unlockTagFileLoading(tagFilePath);
@@ -620,6 +645,7 @@
this.pageInfo = compiler.getPageInfo();
}
+ @Override
public void visit(Node.CustomTag n) throws JasperException {
TagFileInfo tagFileInfo = n.getTagFileInfo();
if (tagFileInfo != null) {
@@ -629,9 +655,8 @@
// 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 @@
/**
* 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();
}
}