Author: markt
Date: Fri Jan 27 14:36:36 2017
New Revision: 1780563
URL: http://svn.apache.org/viewvc?rev=1780563&view=rev
Log:
Revert r1780530
Moving setters into a separate method didn't work if attribute values used
scriplets.
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/Generator.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=1780563&r1=1780562&r2=1780563&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Generator.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Fri Jan 27
14:36:36 2017
@@ -1796,8 +1796,7 @@ class Generator {
// to a method.
ServletWriter outSave = null;
Node.ChildInfo ci = n.getChildInfo();
- boolean hasNoScriptingElement = ci.isScriptless() &&
!ci.hasScriptingVars();
- if (hasNoScriptingElement) {
+ if (ci.isScriptless() && !ci.hasScriptingVars()) {
// The tag handler and its body code can reside in a separate
// method if it is scriptless and does not have any scripting
// variable defined.
@@ -1892,14 +1891,14 @@ class Generator {
if (n.implementsSimpleTag()) {
- generateCustomDoTag(n, handlerInfo, tagHandlerVar,
hasNoScriptingElement);
+ generateCustomDoTag(n, handlerInfo, tagHandlerVar);
} else {
/*
* Classic tag handler: Generate code for start element, body,
* and end element
*/
generateCustomStart(n, handlerInfo, tagHandlerVar, tagEvalVar,
- tagPushBodyCountVar, hasNoScriptingElement);
+ tagPushBodyCountVar);
// visit body
String tmpParent = parent;
@@ -1927,7 +1926,7 @@ class Generator {
tagPushBodyCountVar);
}
- if (hasNoScriptingElement) {
+ if (ci.isScriptless() && !ci.hasScriptingVars()) {
// Generate end of method
if (methodNesting > 0) {
out.printil("return false;");
@@ -2367,9 +2366,10 @@ class Generator {
}
}
- private void generateCustomStart(Node.CustomTag n, TagHandlerInfo
handlerInfo,
- String tagHandlerVar, String tagEvalVar, String
tagPushBodyCountVar,
- boolean hasNoScriptingElement) throws JasperException {
+ private void generateCustomStart(Node.CustomTag n,
+ TagHandlerInfo handlerInfo, String tagHandlerVar,
+ String tagEvalVar, String tagPushBodyCountVar)
+ throws JasperException {
Class<?> tagHandlerClass =
handlerInfo.getTagHandlerClass();
@@ -2407,7 +2407,7 @@ class Generator {
out.pushIndent();
// includes setting the context
- generateSetters(n, tagHandlerVar, handlerInfo, false,
hasNoScriptingElement);
+ generateSetters(n, tagHandlerVar, handlerInfo, false);
if (n.implementsTryCatchFinally()) {
out.printin("int[] ");
@@ -2625,8 +2625,9 @@ class Generator {
restoreScriptingVars(n, VariableInfo.AT_BEGIN);
}
- private void generateCustomDoTag(Node.CustomTag n, TagHandlerInfo
handlerInfo,
- String tagHandlerVar, boolean hasNoScriptingElement) throws
JasperException {
+ private void generateCustomDoTag(Node.CustomTag n,
+ TagHandlerInfo handlerInfo, String tagHandlerVar)
+ throws JasperException {
Class<?> tagHandlerClass =
handlerInfo.getTagHandlerClass();
@@ -2642,7 +2643,7 @@ class Generator {
String tagHandlerClassName = tagHandlerClass.getCanonicalName();
writeNewInstance(tagHandlerVar, tagHandlerClassName);
- generateSetters(n, tagHandlerVar, handlerInfo, true,
hasNoScriptingElement);
+ generateSetters(n, tagHandlerVar, handlerInfo, true);
// Set the body
if (findJspBody(n) == null) {
@@ -3148,55 +3149,9 @@ class Generator {
}
private void generateSetters(Node.CustomTag n, String tagHandlerVar,
- TagHandlerInfo handlerInfo, boolean simpleTag, boolean
hasNoScriptingElement)
+ TagHandlerInfo handlerInfo, boolean simpleTag)
throws JasperException {
- ServletWriter outSave = null;
- // If the tag contains scripting elements, the setters can still be
- // generated in a separate method. This reduces the amount of code
- // required in the _jspService() method
- if (!hasNoScriptingElement) {
- outSave = out;
-
- // Might be better to pass the baseVar
- String tagSetterMethod = "_jspx_meth_set_" +
tagHandlerVar.substring(9);
-
- // Generate a call to the setter method
- out.printin(tagSetterMethod);
- out.print("(");
- out.print(tagHandlerVar);
- out.print(", _jspx_page_context");
- if (parent != null) {
- out.print(", ");
- out.print(parent);
- }
- out.println(");");
-
- // Setup new buffer for the method
- GenBuffer genBuffer = new GenBuffer(n, null);
- methodsBuffered.add(genBuffer);
- out = genBuffer.getOut();
-
- // Generate code for method declaration
- out.println();
- out.pushIndent();
- out.printin("private void ");
- out.print(tagSetterMethod);
- out.print("(");
- out.print(handlerInfo.getTagHandlerClass().getCanonicalName());
- out.print(" ");
- out.print(tagHandlerVar);
- out.print(", javax.servlet.jsp.PageContext
_jspx_page_context");
- if (parent != null) {
- out.print(", ");
- out.print("javax.servlet.jsp.tagext.JspTag ");
- out.print(parent);
- }
- out.println(")");
- out.printil(" throws java.lang.Throwable {");
- out.pushIndent();
- }
-
// Set context
if (simpleTag) {
// Generate alias map
@@ -3292,15 +3247,6 @@ class Generator {
out.print(createJspId());
out.println("\");");
}
-
- if (!hasNoScriptingElement) {
- out.popIndent();
- out.printil("}");
- out.popIndent();
-
- // restore previous writer
- out = outSave;
- }
}
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]