Author: remy.maucherat(a)jboss.com
Date: 2011-01-04 04:04:39 -0500 (Tue, 04 Jan 2011)
New Revision: 1630
Modified:
branches/3.0.x/java/org/apache/el/lang/ExpressionBuilder.java
branches/3.0.x/java/org/apache/el/util/ConcurrentCache.java
branches/3.0.x/java/org/apache/jasper/compiler/Compiler.java
branches/3.0.x/java/org/apache/jasper/compiler/ELFunctionMapper.java
branches/3.0.x/java/org/apache/jasper/compiler/JDTCompiler.java
branches/3.0.x/java/org/apache/jasper/compiler/JspDocumentParser.java
branches/3.0.x/java/org/apache/jasper/compiler/ParserController.java
branches/3.0.x/java/org/apache/jasper/compiler/TagFileProcessor.java
branches/3.0.x/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
branches/3.0.x/java/org/apache/jasper/el/ELContextImpl.java
branches/3.0.x/java/org/apache/jasper/el/ELResolverImpl.java
branches/3.0.x/java/org/apache/jasper/resources/LocalStrings.properties
branches/3.0.x/webapps/docs/changelog.xml
Log:
- Rebase Jasper from the 7 branch's Jasper to pull in all fixes.
Modified: branches/3.0.x/java/org/apache/el/lang/ExpressionBuilder.java
===================================================================
--- branches/3.0.x/java/org/apache/el/lang/ExpressionBuilder.java 2011-01-03 14:39:30 UTC
(rev 1629)
+++ branches/3.0.x/java/org/apache/el/lang/ExpressionBuilder.java 2011-01-04 09:04:39 UTC
(rev 1630)
@@ -19,6 +19,9 @@
import java.io.StringReader;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.concurrent.ConcurrentHashMap;
import javax.el.ELContext;
import javax.el.ELException;
@@ -50,8 +53,36 @@
*/
public final class ExpressionBuilder implements NodeVisitor {
- private static final ConcurrentCache cache = new ConcurrentCache(5000);
+ private static final int CACHE_SIZE;
+ private static final String CACHE_SIZE_PROP =
+ "org.apache.el.lang.ExpressionBuilder.CACHE_SIZE";
+ static {
+ if (System.getSecurityManager() == null) {
+ CACHE_SIZE = Integer.parseInt(
+ System.getProperty(CACHE_SIZE_PROP, "-1"));
+ } else {
+ CACHE_SIZE = AccessController.doPrivileged(
+ new PrivilegedAction<Integer>() {
+ @Override
+ public Integer run() {
+ return Integer.valueOf(
+ System.getProperty(CACHE_SIZE_PROP, "-1"));
+ }
+ }).intValue();
+ }
+ if (CACHE_SIZE > 0) {
+ unlimitedCache = null;
+ cache = new ConcurrentCache<String, Node>(CACHE_SIZE);
+ } else {
+ cache = null;
+ unlimitedCache = new ConcurrentHashMap<String, Node>(1024);
+ }
+ }
+
+ private static final ConcurrentCache<String, Node> cache;
+ private static final ConcurrentHashMap<String, Node> unlimitedCache;
+
private FunctionMapper fnMapper;
private VariableMapper varMapper;
@@ -87,7 +118,7 @@
throw new ELException(MessageFactory.get("error.null"));
}
- Node n = (Node) cache.get(expr);
+ Node n = (cache != null) ? cache.get(expr) : unlimitedCache.get(expr);
if (n == null) {
try {
n = (new ELParser(new StringReader(expr)))
@@ -120,7 +151,11 @@
|| n instanceof AstDynamicExpression) {
n = n.jjtGetChild(0);
}
- cache.put(expr, n);
+ if (cache != null) {
+ cache.put(expr, n);
+ } else {
+ unlimitedCache.put(expr, n);
+ }
} catch (ParseException pe) {
throw new ELException("Error Parsing: " + expr, pe);
}
Modified: branches/3.0.x/java/org/apache/el/util/ConcurrentCache.java
===================================================================
--- branches/3.0.x/java/org/apache/el/util/ConcurrentCache.java 2011-01-03 14:39:30 UTC
(rev 1629)
+++ branches/3.0.x/java/org/apache/el/util/ConcurrentCache.java 2011-01-04 09:04:39 UTC
(rev 1630)
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.el.util;
import java.util.Map;
@@ -6,34 +22,38 @@
public final class ConcurrentCache<K,V> {
- private final int size;
-
- private final Map<K,V> eden;
-
- private final Map<K,V> longterm;
-
- public ConcurrentCache(int size) {
- this.size = size;
- this.eden = new ConcurrentHashMap<K,V>(size);
- this.longterm = new WeakHashMap<K,V>(size);
- }
-
- public V get(K k) {
- V v = this.eden.get(k);
- if (v == null) {
- v = this.longterm.get(k);
- if (v != null) {
- this.eden.put(k, v);
- }
- }
- return v;
- }
-
- public void put(K k, V v) {
- if (this.eden.size() >= size) {
- this.longterm.putAll(this.eden);
- this.eden.clear();
- }
- this.eden.put(k, v);
- }
+ private final int size;
+
+ private final Map<K,V> eden;
+
+ private final Map<K,V> longterm;
+
+ public ConcurrentCache(int size) {
+ this.size = size;
+ this.eden = new ConcurrentHashMap<K,V>(size);
+ this.longterm = new WeakHashMap<K,V>(size);
+ }
+
+ public V get(K k) {
+ V v = this.eden.get(k);
+ if (v == null) {
+ synchronized (longterm) {
+ v = this.longterm.get(k);
+ }
+ if (v != null) {
+ this.eden.put(k, v);
+ }
+ }
+ return v;
+ }
+
+ public void put(K k, V v) {
+ if (this.eden.size() >= size) {
+ synchronized (longterm) {
+ this.longterm.putAll(this.eden);
+ }
+ this.eden.clear();
+ }
+ this.eden.put(k, v);
+ }
}
Modified: branches/3.0.x/java/org/apache/jasper/compiler/Compiler.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/Compiler.java 2011-01-03 14:39:30 UTC
(rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/Compiler.java 2011-01-04 09:04:39 UTC
(rev 1630)
@@ -139,9 +139,7 @@
pageInfo.setTrimDirectiveWhitespaces(JspUtil.booleanValue(jspProperty
.isTrimDirectiveWhitespaces()));
}
- if (jspProperty.getDefaultContentType() != null &&
pageInfo.getContentType() == null) {
- pageInfo.setContentType(jspProperty.getDefaultContentType());
- }
+ // Default ContentType processing is deferred until after the page has been
parsed
if (jspProperty.getBuffer() != null && pageInfo.getBufferValue() == null)
{
pageInfo.setBufferValue(jspProperty.getBuffer(), errDispatcher);
}
@@ -195,6 +193,10 @@
// Pass 2 - the whole translation unit
pageNodes = parserCtl.parse(ctxt.getJspFile());
+ if (jspProperty.getDefaultContentType() != null &&
pageInfo.getContentType() == null) {
+ pageInfo.setContentType(jspProperty.getDefaultContentType());
+ }
+
if (ctxt.isPrototypeMode()) {
// generate prototype .java file for the tag file
writer = setupContextWriter(javaFileName);
@@ -235,7 +237,7 @@
TextOptimizer.concatenate(this, pageNodes);
// Generate static function mapper codes.
- ELFunctionMapper.map(this, pageNodes);
+ ELFunctionMapper.map(pageNodes);
// generate servlet .java file
writer = setupContextWriter(javaFileName);
Modified: branches/3.0.x/java/org/apache/jasper/compiler/ELFunctionMapper.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/ELFunctionMapper.java 2011-01-03
14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/ELFunctionMapper.java 2011-01-04
09:04:39 UTC (rev 1630)
@@ -17,13 +17,19 @@
package org.apache.jasper.compiler;
-import java.util.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.HashMap;
+
import javax.servlet.jsp.tagext.FunctionInfo;
+
+import org.apache.jasper.Constants;
import org.apache.jasper.JasperException;
/**
* This class generates functions mappers for the EL expressions in the page.
- * Instead of a global mapper, a mapper is used for ecah call to EL
+ * Instead of a global mapper, a mapper is used for each call to EL
* evaluator, thus avoiding the prefix overlapping and redefinition
* issues.
*
@@ -38,25 +44,24 @@
/**
* Creates the functions mappers for all EL expressions in the JSP page.
*
- * @param compiler Current compiler, mainly for accessing error dispatcher.
* @param page The current compilation unit.
*/
- public static void map(Compiler compiler, Node.Nodes page)
- throws JasperException {
+ public static void map(Node.Nodes page)
+ throws JasperException {
- ELFunctionMapper map = new ELFunctionMapper();
- map.ds = new StringBuilder();
- map.ss = new StringBuilder();
+ ELFunctionMapper map = new ELFunctionMapper();
+ map.ds = new StringBuilder();
+ map.ss = new StringBuilder();
- page.visit(map.new ELFunctionVisitor());
+ page.visit(map.new ELFunctionVisitor());
- // Append the declarations to the root node
- String ds = map.ds.toString();
- if (ds.length() > 0) {
- Node root = page.getRoot();
- new Node.Declaration(map.ss.toString(), null, root);
- new Node.Declaration("static {\n" + ds + "}\n", null, root);
- }
+ // Append the declarations to the root node
+ String ds = map.ds.toString();
+ if (ds.length() > 0) {
+ Node root = page.getRoot();
+ new Node.Declaration(map.ss.toString(), null, root);
+ new Node.Declaration("static {\n" + ds + "}\n", null,
root);
+ }
}
/**
@@ -64,182 +69,194 @@
* for functions, and if found functions mappers are created.
*/
class ELFunctionVisitor extends Node.Visitor {
-
- /**
- * Use a global name map to facilitate reuse of function maps.
- * The key used is prefix:function:uri.
- */
- private HashMap gMap = new HashMap();
+
+ /**
+ * Use a global name map to facilitate reuse of function maps.
+ * The key used is prefix:function:uri.
+ */
+ private HashMap<String, String> gMap = new HashMap<String,
String>();
- public void visit(Node.ParamAction n) throws JasperException {
- doMap(n.getValue());
- visitBody(n);
- }
+ @Override
+ public void visit(Node.ParamAction n) throws JasperException {
+ doMap(n.getValue());
+ visitBody(n);
+ }
- public void visit(Node.IncludeAction n) throws JasperException {
- doMap(n.getPage());
- visitBody(n);
- }
+ @Override
+ public void visit(Node.IncludeAction n) throws JasperException {
+ doMap(n.getPage());
+ visitBody(n);
+ }
- public void visit(Node.ForwardAction n) throws JasperException {
- doMap(n.getPage());
- visitBody(n);
- }
+ @Override
+ public void visit(Node.ForwardAction n) throws JasperException {
+ doMap(n.getPage());
+ visitBody(n);
+ }
+ @Override
public void visit(Node.SetProperty n) throws JasperException {
- doMap(n.getValue());
- visitBody(n);
- }
+ doMap(n.getValue());
+ visitBody(n);
+ }
+ @Override
public void visit(Node.UseBean n) throws JasperException {
- doMap(n.getBeanName());
- visitBody(n);
- }
+ doMap(n.getBeanName());
+ visitBody(n);
+ }
+ @Override
public void visit(Node.PlugIn n) throws JasperException {
- doMap(n.getHeight());
- doMap(n.getWidth());
- visitBody(n);
- }
+ doMap(n.getHeight());
+ doMap(n.getWidth());
+ visitBody(n);
+ }
+ @Override
public void visit(Node.JspElement n) throws JasperException {
- Node.JspAttribute[] attrs = n.getJspAttributes();
- for (int i = 0; attrs != null && i < attrs.length; i++) {
- doMap(attrs[i]);
- }
- doMap(n.getNameAttribute());
- visitBody(n);
- }
+ Node.JspAttribute[] attrs = n.getJspAttributes();
+ for (int i = 0; attrs != null && i < attrs.length; i++) {
+ doMap(attrs[i]);
+ }
+ doMap(n.getNameAttribute());
+ visitBody(n);
+ }
+ @Override
public void visit(Node.UninterpretedTag n) throws JasperException {
- Node.JspAttribute[] attrs = n.getJspAttributes();
- for (int i = 0; attrs != null && i < attrs.length; i++) {
- doMap(attrs[i]);
- }
- visitBody(n);
- }
+ Node.JspAttribute[] attrs = n.getJspAttributes();
+ for (int i = 0; attrs != null && i < attrs.length; i++) {
+ doMap(attrs[i]);
+ }
+ visitBody(n);
+ }
+ @Override
public void visit(Node.CustomTag n) throws JasperException {
- Node.JspAttribute[] attrs = n.getJspAttributes();
- for (int i = 0; attrs != null && i < attrs.length; i++) {
- doMap(attrs[i]);
- }
- visitBody(n);
- }
+ Node.JspAttribute[] attrs = n.getJspAttributes();
+ for (int i = 0; attrs != null && i < attrs.length; i++) {
+ doMap(attrs[i]);
+ }
+ visitBody(n);
+ }
+ @Override
public void visit(Node.ELExpression n) throws JasperException {
- doMap(n.getEL());
- }
+ doMap(n.getEL());
+ }
- private void doMap(Node.JspAttribute attr)
- throws JasperException {
- if (attr != null) {
- doMap(attr.getEL());
- }
- }
+ private void doMap(Node.JspAttribute attr)
+ throws JasperException {
+ if (attr != null) {
+ doMap(attr.getEL());
+ }
+ }
/**
* Creates function mappers, if needed, from ELNodes
*/
- private void doMap(ELNode.Nodes el)
- throws JasperException {
+ private void doMap(ELNode.Nodes el)
+ throws JasperException {
// Only care about functions in ELNode's
- class Fvisitor extends ELNode.Visitor {
- ArrayList funcs = new ArrayList();
- HashMap keyMap = new HashMap();
- public void visit(ELNode.Function n) throws JasperException {
- String key = n.getPrefix() + ":" + n.getName();
- if (! keyMap.containsKey(key)) {
- keyMap.put(key,"");
- funcs.add(n);
- }
- }
- }
+ class Fvisitor extends ELNode.Visitor {
+ ArrayList<ELNode.Function> funcs =
+ new ArrayList<ELNode.Function>();
+ HashMap<String, String> keyMap = new HashMap<String,
String>();
+ @Override
+ public void visit(ELNode.Function n) throws JasperException {
+ String key = n.getPrefix() + ":" + n.getName();
+ if (! keyMap.containsKey(key)) {
+ keyMap.put(key,"");
+ funcs.add(n);
+ }
+ }
+ }
- if (el == null) {
- return;
- }
+ if (el == null) {
+ return;
+ }
- // First locate all unique functions in this EL
- Fvisitor fv = new Fvisitor();
- el.visit(fv);
- ArrayList functions = fv.funcs;
+ // First locate all unique functions in this EL
+ Fvisitor fv = new Fvisitor();
+ el.visit(fv);
+ ArrayList<ELNode.Function> functions = fv.funcs;
- if (functions.size() == 0) {
- return;
- }
+ if (functions.size() == 0) {
+ return;
+ }
- // Reuse a previous map if possible
- String decName = matchMap(functions);
- if (decName != null) {
- el.setMapName(decName);
- return;
- }
-
- // Generate declaration for the map statically
- decName = getMapName();
- ss.append("static private org.apache.jasper.runtime.ProtectedFunctionMapper
" + decName + ";\n");
+ // Reuse a previous map if possible
+ String decName = matchMap(functions);
+ if (decName != null) {
+ el.setMapName(decName);
+ return;
+ }
+
+ // Generate declaration for the map statically
+ decName = getMapName();
+ ss.append("static private
org.apache.jasper.runtime.ProtectedFunctionMapper " + decName + ";\n");
- ds.append(" " + decName + "= ");
- ds.append("org.apache.jasper.runtime.ProtectedFunctionMapper");
+ ds.append(" " + decName + "= ");
+ ds.append("org.apache.jasper.runtime.ProtectedFunctionMapper");
- // Special case if there is only one function in the map
- String funcMethod = null;
- if (functions.size() == 1) {
- funcMethod = ".getMapForFunction";
- } else {
- ds.append(".getInstance();\n");
- funcMethod = " " + decName + ".mapFunction";
- }
+ // Special case if there is only one function in the map
+ String funcMethod = null;
+ if (functions.size() == 1) {
+ funcMethod = ".getMapForFunction";
+ } else {
+ ds.append(".getInstance();\n");
+ funcMethod = " " + decName + ".mapFunction";
+ }
// Setup arguments for either getMapForFunction or mapFunction
- for (int i = 0; i < functions.size(); i++) {
- ELNode.Function f = (ELNode.Function)functions.get(i);
- FunctionInfo funcInfo = f.getFunctionInfo();
- String key = f.getPrefix()+ ":" + f.getName();
- ds.append(funcMethod + "(\"" + key + "\", " +
- funcInfo.getFunctionClass() + ".class, " +
- '\"' + f.getMethodName() + "\", " +
- "new Class[] {");
- String params[] = f.getParameters();
- for (int k = 0; k < params.length; k++) {
- if (k != 0) {
- ds.append(", ");
- }
- int iArray = params[k].indexOf('[');
- if (iArray < 0) {
- ds.append(params[k] + ".class");
- }
- else {
- String baseType = params[k].substring(0, iArray);
- ds.append("java.lang.reflect.Array.newInstance(");
- ds.append(baseType);
- ds.append(".class,");
+ for (int i = 0; i < functions.size(); i++) {
+ ELNode.Function f = functions.get(i);
+ FunctionInfo funcInfo = f.getFunctionInfo();
+ String key = f.getPrefix()+ ":" + f.getName();
+ ds.append(funcMethod + "(\"" + key + "\", "
+
+ getCanonicalName(funcInfo.getFunctionClass()) +
+ ".class, " + '\"' + f.getMethodName() +
"\", " +
+ "new Class[] {");
+ String params[] = f.getParameters();
+ for (int k = 0; k < params.length; k++) {
+ if (k != 0) {
+ ds.append(", ");
+ }
+ int iArray = params[k].indexOf('[');
+ if (iArray < 0) {
+ ds.append(params[k] + ".class");
+ }
+ else {
+ String baseType = params[k].substring(0, iArray);
+ ds.append("java.lang.reflect.Array.newInstance(");
+ ds.append(baseType);
+ ds.append(".class,");
- // Count the number of array dimension
- int aCount = 0;
- for (int jj = iArray; jj < params[k].length(); jj++ ) {
- if (params[k].charAt(jj) == '[') {
- aCount++;
- }
- }
- if (aCount == 1) {
- ds.append("0).getClass()");
- } else {
- ds.append("new int[" + aCount + "]).getClass()");
- }
- }
- }
- ds.append("});\n");
- // Put the current name in the global function map
- gMap.put(f.getPrefix() + ':' + f.getName() + ':' + f.getUri(),
- decName);
- }
- el.setMapName(decName);
- }
+ // Count the number of array dimension
+ int aCount = 0;
+ for (int jj = iArray; jj < params[k].length(); jj++ ) {
+ if (params[k].charAt(jj) == '[') {
+ aCount++;
+ }
+ }
+ if (aCount == 1) {
+ ds.append("0).getClass()");
+ } else {
+ ds.append("new int[" + aCount +
"]).getClass()");
+ }
+ }
+ }
+ ds.append("});\n");
+ // Put the current name in the global function map
+ gMap.put(f.getPrefix() + ':' + f.getName() + ':' +
f.getUri(),
+ decName);
+ }
+ el.setMapName(decName);
+ }
/**
* Find the name of the function mapper for an EL. Reuse a
@@ -249,32 +266,66 @@
* @return A previous generated function mapper name that can be used
* by this EL; null if none found.
*/
- private String matchMap(ArrayList functions) {
+ private String matchMap(ArrayList<ELNode.Function> functions) {
- String mapName = null;
- for (int i = 0; i < functions.size(); i++) {
- ELNode.Function f = (ELNode.Function)functions.get(i);
- String temName = (String) gMap.get(f.getPrefix() + ':' +
- f.getName() + ':' + f.getUri());
- if (temName == null) {
- return null;
- }
- if (mapName == null) {
- mapName = temName;
- } else if (!temName.equals(mapName)) {
- // If not all in the previous match, then no match.
- return null;
- }
- }
- return mapName;
- }
+ String mapName = null;
+ for (int i = 0; i < functions.size(); i++) {
+ ELNode.Function f = functions.get(i);
+ String temName = gMap.get(f.getPrefix() + ':' + f.getName() +
+ ':' + f.getUri());
+ if (temName == null) {
+ return null;
+ }
+ if (mapName == null) {
+ mapName = temName;
+ } else if (!temName.equals(mapName)) {
+ // If not all in the previous match, then no match.
+ return null;
+ }
+ }
+ return mapName;
+ }
/*
* @return An unique name for a function mapper.
*/
- private String getMapName() {
- return "_jspx_fnmap_" + currFunc++;
- }
+ private String getMapName() {
+ return "_jspx_fnmap_" + currFunc++;
+ }
+
+ /**
+ * Convert a binary class name into a canonical one that can be used
+ * when generating Java source code.
+ *
+ * @param className Binary class name
+ * @return Canonical equivalent
+ */
+ private String getCanonicalName(String className) throws JasperException {
+ Class<?> clazz;
+
+ ClassLoader tccl;
+ if (Constants.IS_SECURITY_ENABLED) {
+ PrivilegedAction<ClassLoader> pa = new PrivilegedGetTccl();
+ tccl = AccessController.doPrivileged(pa);
+ } else {
+ tccl = Thread.currentThread().getContextClassLoader();
+ }
+
+ try {
+ clazz = Class.forName(className, true, tccl);
+ } catch (ClassNotFoundException e) {
+ throw new JasperException(e);
+ }
+ return clazz.getCanonicalName();
+ }
}
+
+ private static class PrivilegedGetTccl
+ implements PrivilegedAction<ClassLoader> {
+
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ }
}
Modified: branches/3.0.x/java/org/apache/jasper/compiler/JDTCompiler.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/JDTCompiler.java 2011-01-03 14:39:30
UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/JDTCompiler.java 2011-01-04 09:04:39
UTC (rev 1630)
@@ -100,10 +100,10 @@
public char[] getContents() {
char[] result = null;
FileInputStream is = null;
+ Reader reader = null;
try {
is = new FileInputStream(sourceFile);
- Reader reader =
- new BufferedReader(new InputStreamReader(is,
ctxt.getOptions().getJavaEncoding()));
+ reader = new BufferedReader(new InputStreamReader(is,
ctxt.getOptions().getJavaEncoding()));
if (reader != null) {
char[] chars = new char[8192];
StringBuilder buf = new StringBuilder();
@@ -118,6 +118,13 @@
} catch (IOException e) {
log.error("Compilation error", e);
} finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException exc) {
+ // Ignore
+ }
+ }
if (is != null) {
try {
is.close();
Modified: branches/3.0.x/java/org/apache/jasper/compiler/JspDocumentParser.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/JspDocumentParser.java 2011-01-03
14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/JspDocumentParser.java 2011-01-04
09:04:39 UTC (rev 1630)
@@ -60,11 +60,6 @@
"http://xml.org/sax/properties/lexical-handler";
private static final String JSP_URI = "http://java.sun.com/JSP/Page";
- private static final EnableDTDValidationException ENABLE_DTD_VALIDATION_EXCEPTION =
- new EnableDTDValidationException(
- "jsp.error.enable_dtd_validation",
- null);
-
private ParserController parserController;
private JspCompilationContext ctxt;
private PageInfo pageInfo;
@@ -751,7 +746,7 @@
public void startDTD(String name, String publicId, String systemId)
throws SAXException {
if (!isValidating) {
- fatalError(ENABLE_DTD_VALIDATION_EXCEPTION);
+ fatalError(new
EnableDTDValidationException("jsp.error.enable_dtd_validation", null));
}
inDTD = true;
@@ -793,7 +788,7 @@
taglibInfo = getTaglibInfo(prefix, uri);
} catch (JasperException je) {
throw new SAXParseException(
- Localizer.getMessage("jsp.error.could.not.add.taglibraries"),
+ Localizer.getMessage("jsp.error.could.not.add.taglibraries",
je.getMessage()),
locator,
je);
}
@@ -1450,6 +1445,11 @@
EnableDTDValidationException(String message, Locator loc) {
super(message, loc);
}
+
+ public synchronized Throwable fillInStackTrace() {
+ // No stack trace
+ return this;
+ }
}
private static String getBodyType(Node.CustomTag custom) {
Modified: branches/3.0.x/java/org/apache/jasper/compiler/ParserController.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/ParserController.java 2011-01-03
14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/ParserController.java 2011-01-04
09:04:39 UTC (rev 1630)
@@ -612,10 +612,12 @@
&& Character.isWhitespace(root.charAt(index))) {
index++;
}
- if (index < root.length() && root.charAt(index++) ==
'"'
- && root.regionMatches(index, JSP_URI, 0,
- JSP_URI.length())) {
- return true;
+ if (index < root.length()
+ && (root.charAt(index) == '"' ||
root.charAt(index) == '\'')) {
+ index++;
+ if (root.regionMatches(index, JSP_URI, 0, JSP_URI.length())) {
+ return true;
+ }
}
}
Modified: branches/3.0.x/java/org/apache/jasper/compiler/TagFileProcessor.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/TagFileProcessor.java 2011-01-03
14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/TagFileProcessor.java 2011-01-04
09:04:39 UTC (rev 1630)
@@ -21,7 +21,6 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -596,8 +595,7 @@
rctxt.addWrapper(tagFileJarPath + tagFilePath, wrapper);
// Use same classloader and classpath for compiling tag files
- wrapper.getJspEngineContext().setClassLoader(
- (URLClassLoader) ctxt.getClassLoader());
+ wrapper.getJspEngineContext().setClassLoader(ctxt.getClassLoader());
wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
} else {
// Make sure that JspCompilationContext gets the latest TagInfo
@@ -620,6 +618,9 @@
.getServletContext(), ctxt.getOptions(),
tagFilePath, tagInfo, ctxt.getRuntimeContext(),
ctxt.getTagFileJarUrl(tagFilePath));
+ // Use same classloader and classpath for compiling tag files
+
tempWrapper.getJspEngineContext().setClassLoader(ctxt.getClassLoader());
+ tempWrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
tagClazz = tempWrapper.loadTagFilePrototype();
tempVector.add(tempWrapper.getJspEngineContext()
.getCompiler());
Modified: branches/3.0.x/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2011-01-03
14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2011-01-04
09:04:39 UTC (rev 1630)
@@ -301,8 +301,13 @@
e);
}
}
-
- return new TagInfo(tagInfo.getTagName(), tagInfo.getTagClassName(),
tagInfo.getBodyContent(),
+
+ String tagBodyContent = tagInfo.getBodyContent();
+ if (tagBodyContent == null) {
+ tagBodyContent = TagInfo.BODY_CONTENT_JSP;
+ }
+
+ return new TagInfo(tagInfo.getTagName(), tagInfo.getTagClassName(),
tagBodyContent,
tagInfo.getInfoString(), this, tei, attributeInfos.toArray(new
TagAttributeInfo[0]),
tagInfo.getDisplayName(), tagInfo.getSmallIcon(),
tagInfo.getLargeIcon(),
variableInfos.toArray(new TagVariableInfo[0]), dynamicAttributes);
Modified: branches/3.0.x/java/org/apache/jasper/el/ELContextImpl.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/el/ELContextImpl.java 2011-01-03 14:39:30 UTC
(rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/el/ELContextImpl.java 2011-01-04 09:04:39 UTC
(rev 1630)
@@ -69,7 +69,7 @@
public ELContextImpl() {
this(ELResolverImpl.getDefaultResolver());
- if (Constants.IS_SECURITY_ENABLED) {
+ if (ELResolverImpl.NEW_RESOLVER_INSTANCE &&
Constants.IS_SECURITY_ENABLED) {
functionMapper = new FunctionMapper() {
public Method resolveFunction(String prefix, String localName) {
return null;
Modified: branches/3.0.x/java/org/apache/jasper/el/ELResolverImpl.java
===================================================================
--- branches/3.0.x/java/org/apache/jasper/el/ELResolverImpl.java 2011-01-03 14:39:30 UTC
(rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/el/ELResolverImpl.java 2011-01-04 09:04:39 UTC
(rev 1630)
@@ -36,9 +36,12 @@
public final class ELResolverImpl extends ELResolver {
- /** @deprecated - Use getDefaultResolver(). Needs to be made private */
- public final static ELResolver DefaultResolver = new CompositeELResolver();
+ public static final boolean NEW_RESOLVER_INSTANCE =
+
Boolean.valueOf(System.getProperty("org.apache.jasper.el.ELResolverImpl.NEW_RESOLVER_INSTANCE",
"false")).booleanValue();
+
+ private final static ELResolver DefaultResolver = new CompositeELResolver();
+
static {
((CompositeELResolver) DefaultResolver).add(new MapELResolver());
((CompositeELResolver) DefaultResolver).add(new ResourceBundleELResolver());
@@ -147,7 +150,7 @@
}
public static ELResolver getDefaultResolver() {
- if (Constants.IS_SECURITY_ENABLED) {
+ if (NEW_RESOLVER_INSTANCE && Constants.IS_SECURITY_ENABLED) {
CompositeELResolver defaultResolver = new CompositeELResolver();
defaultResolver.add(new MapELResolver());
defaultResolver.add(new ResourceBundleELResolver());
Modified: branches/3.0.x/java/org/apache/jasper/resources/LocalStrings.properties
===================================================================
--- branches/3.0.x/java/org/apache/jasper/resources/LocalStrings.properties 2011-01-03
14:39:30 UTC (rev 1629)
+++ branches/3.0.x/java/org/apache/jasper/resources/LocalStrings.properties 2011-01-04
09:04:39 UTC (rev 1630)
@@ -344,7 +344,7 @@
jsp.error.coerce_to_type=Cannot coerce value ({2}) to type ({1}) for attribute {0}.
jsp.error.jspelement.missing.name=Mandatory XML-style \'name\' attribute missing
jsp.error.xmlns.redefinition.notimplemented=Internal error: Attempt to redefine
xmlns:{0}. Redefinition of namespaces is not implemented.
-jsp.error.could.not.add.taglibraries=Could not add one or more tag libraries.
+jsp.error.could.not.add.taglibraries=Could not add one or more tag libraries: {0}
jsp.error.duplicate.name.jspattribute=The attribute {0} specified in the standard or
custom action also appears as the value of the name attribute in the enclosed
jsp:attribute
jsp.error.not.in.template={0} not allowed in a template text body.
jsp.error.badStandardAction=Invalid standard action
Modified: branches/3.0.x/webapps/docs/changelog.xml
===================================================================
--- branches/3.0.x/webapps/docs/changelog.xml 2011-01-03 14:39:30 UTC (rev 1629)
+++ branches/3.0.x/webapps/docs/changelog.xml 2011-01-04 09:04:39 UTC (rev 1630)
@@ -16,6 +16,45 @@
<body>
+<section name="JBoss Web 3.0.0.CR2 (remm)">
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ <jboss-jira>JBAS-8579</jboss-jira>: Fix default for tag body content.
(remm)
+ </fix>
+ <fix>
+ <jira>185</jira>: Fix cache thread safety issue for EL expression
builder.
+ Patch submitted by Takayoshi Kimura. (remm)
+ </fix>
+ <fix>
+ <bug>50192</bug>: Fix regression getting the EL resolver. Tighter
security can
+ be enabled back. (remm)
+ </fix>
+ <fix>
+ <bug>49555</bug>: Fix use of static inner classes in taglibs.
(markt)
+ </fix>
+ <fix>
+ <bug>49726</bug>: Specifying a default content type via a JSP
property group
+ should not prevent a page from setting some other content type. (markt)
+ </fix>
+ <fix>
+ <bug>49998</bug>: Handle single quoted attributes in detection of
jsp:root
+ element in XML syntax JSP files. (markt)
+ </fix>
+ <fix>
+ <bug>50066</bug>: Fix building of recursive tag files when the file
depends on a JAR file.
+ Patch provided by Sylvain Laurent. (markt)
+ </fix>
+ <fix>
+ <bug>50105</bug>: Use Enum.name() rather than Enum.toString() in
composite expressions. (markt)
+ </fix>
+ <fix>
+ Close reader in JDT compiler. (markt)
+ </fix>
+ </changelog>
+ </subsection>
+</section>
+
<section name="JBoss Web 3.0.0.CR1 (remm)">
<subsection name="Catalina">
<changelog>