cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
luehe 2005/03/29 10:33:21 Modified:jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: Simplified the loading of class resources in JasperLoader. There is no reason for it to use different classloaders depending on whether security is on (classloader returned by Thread.currentThread().getContextClassLoader()) or off (parent classloader). I think we have been using different classloaders for historical reasons, because JspC.java didn't use to set thread context classloader until the fix for Bugzilla 20155 required it to do so. Instead, we should use parent classloader consistently, which always corresponds to the URLClassLoader with access to WEB-INF/lib[classes]: 1. In JspC.java, we construct URLClassLoader and set it as the parent of JasperLoader. 2. When invoked from JspServlet, we acquire the context classloader (which corresponds to WebappClassLoader) inside the constructor of JspRuntimeContext (no need for doing this inside a privileged block there) and set it as the parent of JasperLoader. Ran all TCKs and jsp-examples with and without security enabled. Let me know if you see anything wrong. Revision ChangesPath 1.18 +3 -31 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java Index: JasperLoader.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- JasperLoader.java 17 Dec 2004 14:55:30 - 1.17 +++ JasperLoader.java 29 Mar 2005 18:33:21 - 1.18 @@ -44,7 +44,6 @@ private String className; private ClassLoader parent; private SecurityManager securityManager; -private PrivilegedLoadClass privLoadClass; public JasperLoader(URL[] urls, ClassLoader parent, PermissionCollection permissionCollection, @@ -53,7 +52,6 @@ this.permissionCollection = permissionCollection; this.codeSource = codeSource; this.parent = parent; -this.privLoadClass = new PrivilegedLoadClass(); this.securityManager = System.getSecurityManager(); } @@ -127,29 +125,10 @@ } } - // Class is in a package, delegate to thread context class loader if( !name.startsWith(Constants.JSP_PACKAGE_NAME) ) { - if (securityManager != null) { -final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged(privLoadClass); -try{ -clazz = (Class)AccessController.doPrivileged(new PrivilegedExceptionAction(){ -public Object run() throws Exception{ -return classLoader.loadClass(name); -} -}); -} catch(PrivilegedActionException ex){ -Exception rootCause = ex.getException(); -if (rootCause instanceof ClassNotFoundException) { -throw (ClassNotFoundException) rootCause; -} else { -throw new ClassNotFoundException(JasperLoader, - rootCause); -} -} -} else { -clazz = parent.loadClass(name); -} - +// Class is not in org.apache.jsp, therefore, have our +// parent load it +clazz = parent.loadClass(name); if( resolve ) resolveClass(clazz); return clazz; @@ -193,11 +172,4 @@ public final PermissionCollection getPermissions(CodeSource codeSource) { return permissionCollection; } - -private class PrivilegedLoadClass implements PrivilegedAction { - -public Object run() { -return Thread.currentThread().getContextClassLoader(); -} -} } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
remm2004/12/17 06:55:30 Modified:jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: - Override getResourceAsStream to prevent locking. - Based on a patch submitted by Dominik Drzewiecki. Revision ChangesPath 1.17 +24 -2 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java Index: JasperLoader.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- JasperLoader.java 22 Nov 2004 16:35:52 - 1.16 +++ JasperLoader.java 17 Dec 2004 14:55:30 - 1.17 @@ -16,6 +16,8 @@ package org.apache.jasper.servlet; +import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.net.URLClassLoader; import java.security.AccessController; @@ -27,8 +29,6 @@ import org.apache.jasper.Constants; -import org.apache.jasper.security.SecurityUtil; - /** * Class loader for loading servlet class files (corresponding to JSP files) * and tag handler class files (corresponding to tag files). @@ -158,6 +158,28 @@ return findClass(name); } + +/** + * Delegate to parent + * + * @see java.lang.ClassLoader#getResourceAsStream(java.lang.String) + */ +public InputStream getResourceAsStream(String name) { +InputStream is = parent.getResourceAsStream(name); +if (is == null) { +URL url = findResource(name); +if (url != null) { +try { +is = url.openStream(); +} catch (IOException e) { +is = null; +} +} +} +return is; +} + + /** * Get the Permissions for a CodeSource. * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
[EMAIL PROTECTED] wrote: remm2004/12/17 06:55:30 Modified:jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: - Override getResourceAsStream to prevent locking. - Based on a patch submitted by Dominik Drzewiecki. Revision ChangesPath 1.17 +24 -2 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperL oader.java FYI, it works for me. No nasty JAR locking anymore! /dd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
Dominik Drzewiecki wrote: [EMAIL PROTECTED] wrote: remm2004/12/17 06:55:30 Modified:jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: - Override getResourceAsStream to prevent locking. - Based on a patch submitted by Dominik Drzewiecki. Revision ChangesPath 1.17 +24 -2 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperL oader.java FYI, it works for me. No nasty JAR locking anymore! That's good. It ended being very similar to your patch, as I had forgotten local repository lookup was needed for tag files. Rmy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
jfarcand2004/11/18 14:14:42 Modified:jasper2/src/share/org/apache/jasper/runtime Tag: TOMCAT_5_0 JspWriterImpl.java PageContextImpl.java ProtectedFunctionMapper.java jasper2/src/share/org/apache/jasper/servlet Tag: TOMCAT_5_0 JasperLoader.java Added: jasper2/src/share/org/apache/jasper/security Tag: TOMCAT_5_0 SecurityUtil.java Log: When the package protection is not used, do not create the doPrivileged objects so we don't suffer the performance hit (15% faster with trade2 and this change). Also fixed a memory leak when security manager is turned on. Revision ChangesPath No revision No revision 1.12.2.2 +2 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspWriterImpl.java Index: JspWriterImpl.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspWriterImpl.java,v retrieving revision 1.12.2.1 retrieving revision 1.12.2.2 diff -u -r1.12.2.1 -r1.12.2.2 --- JspWriterImpl.java5 Oct 2004 14:49:43 - 1.12.2.1 +++ JspWriterImpl.java18 Nov 2004 22:14:41 - 1.12.2.2 @@ -26,6 +26,7 @@ import org.apache.jasper.Constants; import org.apache.jasper.compiler.Localizer; +import org.apache.jasper.security.SecurityUtil; /** * Write text to a character-output stream, buffering characters so as @@ -125,7 +126,7 @@ } private String getLocalizeMessage(final String message){ -if (System.getSecurityManager() != null){ +if (SecurityUtil.isPackageProtectionEnabled()){ return (String)AccessController.doPrivileged(new PrivilegedAction(){ public Object run(){ return Localizer.getMessage(message); 1.60.2.2 +14 -13 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java Index: PageContextImpl.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java,v retrieving revision 1.60.2.1 retrieving revision 1.60.2.2 diff -u -r1.60.2.1 -r1.60.2.2 --- PageContextImpl.java 20 Sep 2004 18:07:22 - 1.60.2.1 +++ PageContextImpl.java 18 Nov 2004 22:14:41 - 1.60.2.2 @@ -49,6 +49,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.jasper.Constants; import org.apache.jasper.compiler.Localizer; +import org.apache.jasper.security.SecurityUtil; /** * Implementation of the PageContext class from the JSP spec. @@ -216,7 +217,7 @@ Localizer.getMessage(jsp.error.attribute.null_name)); } -if (System.getSecurityManager() != null){ +if (SecurityUtil.isPackageProtectionEnabled()){ return AccessController.doPrivileged(new PrivilegedAction(){ public Object run(){ return doGetAttribute(name); @@ -239,7 +240,7 @@ Localizer.getMessage(jsp.error.attribute.null_name)); } -if (System.getSecurityManager() != null){ +if (SecurityUtil.isPackageProtectionEnabled()){ return AccessController.doPrivileged(new PrivilegedAction(){ public Object run(){ return doGetAttribute(name, scope); @@ -281,7 +282,7 @@ Localizer.getMessage(jsp.error.attribute.null_name)); } -if (System.getSecurityManager() != null){ +if (SecurityUtil.isPackageProtectionEnabled()){ AccessController.doPrivileged(new PrivilegedAction(){ public Object run(){ doSetAttribute(name, attribute); @@ -308,7 +309,7 @@ Localizer.getMessage(jsp.error.attribute.null_name)); } -if (System.getSecurityManager() != null){ +if (SecurityUtil.isPackageProtectionEnabled()){ AccessController.doPrivileged(new PrivilegedAction(){ public Object run(){ doSetAttribute(name, o, scope); @@ -358,7 +359,7 @@ throw new NullPointerException( Localizer.getMessage(jsp.error.attribute.null_name)); } -if (System.getSecurityManager() != null){ +if (SecurityUtil.isPackageProtectionEnabled()){ AccessController.doPrivileged(new PrivilegedAction(){ public Object run(){ doRemoveAttribute(name, scope); @@ -404,7 +405,7 @@ Localizer.getMessage(jsp.error.attribute.null_name)); } -
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java JspCServletContext.java JspServlet.java JspServletWrapper.java ServletEngine.java TomcatServletEngine.java
markt 2004/08/25 13:55:29 Modified:jasper2/src/share/org/apache/jasper/logging Tag: tomcat_4_branch DefaultLogger.java JasperLogger.java LogAware.java Logger.java jasper2/src/share/org/apache/jasper/servlet Tag: tomcat_4_branch JasperLoader.java JspCServletContext.java JspServlet.java JspServletWrapper.java ServletEngine.java TomcatServletEngine.java Log: Update TC4 branch to Apache License 2.0. Revision ChangesPath No revision No revision 1.1.1.1.2.3 +12 -53 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/logging/Attic/DefaultLogger.java Index: DefaultLogger.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/logging/Attic/DefaultLogger.java,v retrieving revision 1.1.1.1.2.2 retrieving revision 1.1.1.1.2.3 diff -u -r1.1.1.1.2.2 -r1.1.1.1.2.3 --- DefaultLogger.java22 Aug 2004 12:35:59 - 1.1.1.1.2.2 +++ DefaultLogger.java25 Aug 2004 20:55:25 - 1.1.1.1.2.3 @@ -1,58 +1,17 @@ /* - * + * Copyright 1999,2004 The Apache Software Foundation. * - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - *notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - *notice, this list of conditions and the following disclaimer in - *the documentation and/or other materials provided with the - *distribution. - * - * 3. The end-user documentation included with the redistribution, if - *any, must include the following acknowlegement: - * This product includes software developed by the - *Apache Software Foundation (http://www.apache.org/). - *Alternately, this acknowlegement may appear in the software itself, - *if and wherever such third-party acknowlegements normally appear. - * - * 4. The names The Jakarta Project, Tomcat, and Apache Software - *Foundation must not be used to endorse or promote products derived - *from this software without prior written permission. For written - *permission, please contact [EMAIL PROTECTED] - * - * 5. Products derived from this software may not be called Apache - *nor may Apache appear in their names without prior written - *permission of the Apache Group. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * http://www.apache.org/. - * + * Licensed 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.jasper.logging; 1.2.2.3 +12 -53 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/logging/Attic/JasperLogger.java Index: JasperLogger.java
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
markt 2004/07/25 13:50:22 Modified:jasper2/src/share/org/apache/jasper/servlet Tag: tomcat_4_branch JasperLoader.java Log: Replacing tabs with 8 spaces. Should be no functional change. Revision ChangesPath No revision No revision 1.3.2.2 +42 -42 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java Index: JasperLoader.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -r1.3.2.1 -r1.3.2.2 --- JasperLoader.java 5 Feb 2004 22:19:08 - 1.3.2.1 +++ JasperLoader.java 25 Jul 2004 20:50:21 - 1.3.2.2 @@ -99,15 +99,15 @@ private PrivilegedLoadClass privLoadClass = null; public JasperLoader(URL [] urls, String className, ClassLoader parent, - PermissionCollection permissionCollection, - CodeSource codeSource) { - super(urls,parent); - this.permissionCollection = permissionCollection; - this.codeSource = codeSource; - this.className = className; - this.parent = parent; +PermissionCollection permissionCollection, +CodeSource codeSource) { +super(urls,parent); +this.permissionCollection = permissionCollection; +this.codeSource = codeSource; +this.className = className; +this.parent = parent; this.privLoadClass = new PrivilegedLoadClass(); - this.securityManager = System.getSecurityManager(); +this.securityManager = System.getSecurityManager(); } /** @@ -165,7 +165,7 @@ } // (.5) Permission to access this class when using a SecurityManager - int dot = name.lastIndexOf('.'); +int dot = name.lastIndexOf('.'); if (System.getSecurityManager() != null) { if (dot = 0) { try { @@ -179,42 +179,42 @@ } } - // Class is in a package, delegate to thread context class loader - if( !name.startsWith(Constants.JSP_PACKAGE_NAME) ) { +// Class is in a package, delegate to thread context class loader +if( !name.startsWith(Constants.JSP_PACKAGE_NAME) ) { ClassLoader classLoader = null; - if (System.getSecurityManager() != null) { +if (System.getSecurityManager() != null) { classLoader = (ClassLoader)AccessController.doPrivileged(privLoadClass); } else { - classLoader = Thread.currentThread().getContextClassLoader(); +classLoader = Thread.currentThread().getContextClassLoader(); } clazz = classLoader.loadClass(name); - if( resolve ) - resolveClass(clazz); - return clazz; - } - - // Only load classes for this JSP page - if( name.startsWith(className) ) { - String classFile = name.substring(Constants.JSP_PACKAGE_NAME.length()+1) + - .class; - byte [] cdata = loadClassDataFromFile(classFile); - if( cdata == null ) - throw new ClassNotFoundException(name); - if( System.getSecurityManager() != null ) { - ProtectionDomain pd = new ProtectionDomain( - codeSource,permissionCollection); - clazz = defineClass(name,cdata,0,cdata.length,pd); - } else { - clazz = defineClass(name,cdata,0,cdata.length); - } - if( clazz != null ) { - if( resolve ) - resolveClass(clazz); - return clazz; - } - } +if( resolve ) +resolveClass(clazz); +return clazz; +} - throw new ClassNotFoundException(name); +// Only load classes for this JSP page +if( name.startsWith(className) ) { +String classFile = name.substring(Constants.JSP_PACKAGE_NAME.length()+1) + +.class; +byte [] cdata = loadClassDataFromFile(classFile); +if( cdata == null ) +throw new ClassNotFoundException(name); +if( System.getSecurityManager() != null ) { +ProtectionDomain pd = new ProtectionDomain( +codeSource,permissionCollection); +clazz = defineClass(name,cdata,0,cdata.length,pd); +} else { +clazz = defineClass(name,cdata,0,cdata.length); +} +
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
markt 2004/07/25 14:01:39 Modified:jasper2/src/share/org/apache/jasper/servlet Tag: tomcat_4_branch JasperLoader.java Log: Fix bug 30306. Port Jan's security manager patch from TC5 branch (1.4 - 1.5). Only ported changes related to this bug. Revision ChangesPath No revision No revision 1.3.2.3 +3 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java Index: JasperLoader.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java,v retrieving revision 1.3.2.2 retrieving revision 1.3.2.3 diff -u -r1.3.2.2 -r1.3.2.3 --- JasperLoader.java 25 Jul 2004 20:50:21 - 1.3.2.2 +++ JasperLoader.java 25 Jul 2004 21:01:38 - 1.3.2.3 @@ -166,7 +166,7 @@ // (.5) Permission to access this class when using a SecurityManager int dot = name.lastIndexOf('.'); -if (System.getSecurityManager() != null) { +if (securityManager != null) { if (dot = 0) { try { securityManager.checkPackageAccess(name.substring(0,dot)); @@ -182,7 +182,7 @@ // Class is in a package, delegate to thread context class loader if( !name.startsWith(Constants.JSP_PACKAGE_NAME) ) { ClassLoader classLoader = null; -if (System.getSecurityManager() != null) { +if (securityManager != null) { classLoader = (ClassLoader)AccessController.doPrivileged(privLoadClass); } else { classLoader = Thread.currentThread().getContextClassLoader(); @@ -200,7 +200,7 @@ byte [] cdata = loadClassDataFromFile(classFile); if( cdata == null ) throw new ClassNotFoundException(name); -if( System.getSecurityManager() != null ) { +if( securityManager != null ) { ProtectionDomain pd = new ProtectionDomain( codeSource,permissionCollection); clazz = defineClass(name,cdata,0,cdata.length,pd); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
luehe 2004/02/17 15:24:09 Modified:jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: When security is on, propagate potential ClassNotFoundException instead of swallowing it and just dumping its stack trace. This is consistent with the non-secure case. Revision ChangesPath 1.14 +7 -2 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java Index: JasperLoader.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- JasperLoader.java 5 Feb 2004 23:02:18 - 1.13 +++ JasperLoader.java 17 Feb 2004 23:24:09 - 1.14 @@ -177,8 +177,13 @@ } }); } catch(PrivilegedActionException ex){ -ex.getException().printStackTrace(); - +Exception rootCause = ex.getException(); +if (rootCause instanceof ClassNotFoundException) { +throw (ClassNotFoundException) rootCause; +} else { +throw new ClassNotFoundException(JasperLoader, + rootCause); +} } } else { clazz = parent.loadClass(name); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
luehe 2004/02/05 15:02:18 Modified:jasper2/src/share/org/apache/jasper Options.java jasper2/src/share/org/apache/jasper/compiler JspRuntimeContext.java jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: Minor correction to the editorial changes Mark just committed. Thanks a lot, Mark Revision ChangesPath 1.21 +5 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Options.java Index: Options.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Options.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- Options.java 5 Feb 2004 22:16:47 - 1.20 +++ Options.java 5 Feb 2004 23:02:18 - 1.21 @@ -122,7 +122,8 @@ public boolean isSmapSuppressed(); /** - * Indicates that SMAP info for JSR45 debugging should be dumped to a file. + * Indicates whether SMAP info for JSR45 debugging should be dumped to a + * file. * Ignored is suppressSmap() is true */ public boolean isSmapDumped(); 1.19 +6 -6 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspRuntimeContext.java Index: JspRuntimeContext.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspRuntimeContext.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- JspRuntimeContext.java5 Feb 2004 22:16:47 - 1.18 +++ JspRuntimeContext.java5 Feb 2004 23:02:18 - 1.19 @@ -215,7 +215,7 @@ /** * Add a new JspServletWrapper. * - * @param jspUri of JSP + * @param jspUri JSP URI * @param jsw Servlet wrapper for JSP */ public void addWrapper(String jspUri, JspServletWrapper jsw) { @@ -236,7 +236,7 @@ /** * Remove a JspServletWrapper. * - * @param jspUri of JspServletWrapper to remove + * @param jspUri JSP URI of JspServletWrapper to remove */ public void removeWrapper(String jspUri) { jsps.remove(jspUri); 1.13 +1 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java Index: JasperLoader.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- JasperLoader.java 5 Feb 2004 22:16:47 - 1.12 +++ JasperLoader.java 5 Feb 2004 23:02:18 - 1.13 @@ -199,7 +199,7 @@ * a web application context, we just return our preset * PermissionCollection for the web app context. * - * @param codeSource where the code was loaded from + * @param codeSource Code source where the code was loaded from * @return PermissionCollection for CodeSource */ public final PermissionCollection getPermissions(CodeSource codeSource) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
jfclere 2003/07/30 02:20:47 Modified:jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: Put the dot in the if. Revision ChangesPath 1.10 +1 -1 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java Index: JasperLoader.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- JasperLoader.java 11 Apr 2003 22:41:58 - 1.9 +++ JasperLoader.java 30 Jul 2003 09:20:47 - 1.10 @@ -153,8 +153,8 @@ } // (.5) Permission to access this class when using a SecurityManager - int dot = name.lastIndexOf('.'); if (securityManager != null) { +int dot = name.lastIndexOf('.'); if (dot = 0) { try { // Do not call the security manager since by default, we grant that package. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
kinman 2003/02/27 14:51:38 Modified:jasper2/src/share/org/apache/jasper JspC.java JspCompilationContext.java jasper2/src/share/org/apache/jasper/compiler Compiler.java jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: - Fixes to make Jspc work: * Make sure the correct classloader is used. * Mangle package names if they contain Java keywords. Revision ChangesPath 1.35 +46 -15 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java Index: JspC.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- JspC.java 26 Feb 2003 16:36:13 - 1.34 +++ JspC.java 27 Feb 2003 22:51:38 - 1.35 @@ -573,17 +573,12 @@ Compiler clc = clctxt.createCompiler(); this.setOutputDir( baseDir ); -if( compile ) { -// Generate both .class and .java -if( clc.isOutDated() ) { -clc.compile(); -} -} else { -// Only generate .java, compilation is separated -// Don't compile if the .class file is newer than the .jsp file -if( clc.isOutDated(false) ) { -clc.generateJava(); -} +// If compile is set, generate both .java and .class, if +// .jsp file is newer than .class file; +// Otherwise only generate .java, if .jsp file is newer than +// the .java file +if( clc.isOutDated(compile) ) { +clc.compile(compile); } // Generate mapping @@ -983,17 +978,25 @@ StringBuffer modifiedPackageName = new StringBuffer(); int iSep = jspUri.lastIndexOf('/'); // Start after the first slash +int nameStart = 1; for (int i = 1; i iSep; i++) { char ch = jspUri.charAt(i); if (Character.isJavaIdentifierPart(ch)) { modifiedPackageName.append(ch); } else if (ch == '/') { +if (isJavaKeyword(jspUri.substring(nameStart, i))) { +modifiedPackageName.append('_'); +} +nameStart = i+1; modifiedPackageName.append('.'); } else { modifiedPackageName.append(mangleChar(ch)); } } +if (nameStart iSep isJavaKeyword(jspUri.substring(nameStart, iSep))) { +modifiedPackageName.append('_'); +} return modifiedPackageName.toString(); } @@ -1018,6 +1021,34 @@ return new String(result); } - +static final String javaKeywords[] = { + abstract, boolean, break, byte, case, + catch, char, class, const, continue, + default, do, double, else, extends, + final, finally, float, for, goto, + if, implements, import, instanceof, int, + interface, long, native, new, package, + private, protected, public, return, short, + static, strictfp, super, switch, synchronized, + this, throws, transient, try, void, + volatile, while }; + +static private boolean isJavaKeyword(String key) { + int i = 0; + int j = javaKeywords.length; + while (i j) { + int k = (i+j)/2; + int result = javaKeywords[k].compareTo(key); + if (result == 0) { + return true; + } + if (result 0) { + i = k+1; + } else { + j = k; + } + } + return false; +} } 1.35 +4 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java Index: JspCompilationContext.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- JspCompilationContext.java21 Feb 2003 18:23:14 - 1.34 +++ JspCompilationContext.java27 Feb 2003 22:51:38 - 1.35 @@ -589,7 +589,7 @@ jspLoader = new JasperLoader (outUrls, getServletPackageName() + . + getServletClassName(), - rctxt.getParentClassLoader(), + getClassLoader(), rctxt.getPermissionCollection(), rctxt.getCodeSource()); 1.58 +15 -4
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java JspServletWrapper.java
luehe 2002/11/27 20:18:08 Modified:jasper2/src/share/org/apache/jasper Constants.java EmbededServletOptions.java JspCompilationContext.java jasper2/src/share/org/apache/jasper/compiler Compiler.java Generator.java ImplicitTagLibraryInfo.java JspRuntimeContext.java JspUtil.java Node.java TagFileProcessor.java TagLibraryInfoImpl.java jasper2/src/share/org/apache/jasper/servlet JasperLoader.java JspServletWrapper.java Log: Avoid conflicts between tag files that are located in different directories and therefore are considered to belong to different implicit tag libraries. The path of a tag file is now reflected in the directory in which the corresponding tag handler is stored, and in the name of the package to which the tag handler is assigned. This change also avoids conflicts between tag files with the same name and path under /META-INF/tags/ and /WEB-INF/tags/, by adding meta or web, respectively, to the directory and package names of the respective tag handlers. Revision ChangesPath 1.10 +1 -2 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Constants.java Index: Constants.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/Constants.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Constants.java16 Nov 2002 04:20:09 - 1.9 +++ Constants.java28 Nov 2002 04:18:07 - 1.10 @@ -158,8 +158,7 @@ /** * The default package name for tag handlers generated from tag files */ -public static final String TAG_FILE_PACKAGE_NAME - = org.apache.jsp.tagfile; +public static final String TAG_FILE_PACKAGE_NAME = org.apache.jsp.tag; /** * Servlet context and request attributes that the JSP engine 1.13 +10 -9 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/EmbededServletOptions.java Index: EmbededServletOptions.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/EmbededServletOptions.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- EmbededServletOptions.java16 Nov 2002 04:20:09 - 1.12 +++ EmbededServletOptions.java28 Nov 2002 04:18:07 - 1.13 @@ -435,12 +435,14 @@ if (classpath != null) this.classpath = classpath; + /* + * scratchdir + */ String dir = config.getInitParameter(scratchdir); - -if (dir != null) +if (dir != null) { scratchDir = new File(dir); -else { -// First we try the Servlet 2.2 javax.servlet.context.tempdir property +} else { +// First try the Servlet 2.2 javax.servlet.context.tempdir property scratchDir = (File) context.getAttribute(Constants.TMP_DIR); if (scratchDir == null) { // Not running in a Servlet 2.2 container. @@ -449,8 +451,7 @@ if (dir != null) scratchDir = new File(dir); } -} - +} if (this.scratchDir == null) { Constants.message(jsp.error.no.scratch.dir, Logger.FATAL); return; 1.25 +68 -54 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java Index: JspCompilationContext.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- JspCompilationContext.java28 Oct 2002 18:16:19 - 1.24 +++ JspCompilationContext.java28 Nov 2002 04:18:07 - 1.25 @@ -91,7 +91,7 @@ private Hashtable tagFileJars; private boolean isPackagedTagFile; -private String servletClassName; +private String className; private String jspUri; private boolean isErrPage; private String servletPackageName; @@ -301,40 +301,45 @@ */ public String getServletClassName() { - if (isTagFile) { - return tagInfo.getTagName(); - } - -if (servletClassName != null) { -return servletClassName; +if (className != null) { +return className; } -int iSep = jspUri.lastIndexOf('/') + 1; -int iEnd = jspUri.length(); -StringBuffer modifiedClassName = -
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
jfarcand2002/11/07 13:13:06 Modified:jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: Securize the package so it can work under the SecurityManager whenthe org.apache.jasper s protected. Fix bugs when the JSP 2.0 examples were executed under the SecurityManager. Revision ChangesPath 1.6 +38 -12 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java Index: JasperLoader.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JasperLoader.java 21 Oct 2002 18:44:00 - 1.5 +++ JasperLoader.java 7 Nov 2002 21:13:05 - 1.6 -66,6 +66,8 import java.security.CodeSource; import java.security.PermissionCollection; import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import java.security.ProtectionDomain; import javax.servlet.http.*; -79,6 +81,7 * * author Anil K. Vijendran * author Harish Prabandham + * author Jean-Francois Arcand */ public class JasperLoader extends URLClassLoader { -140,7 +143,7 * * exception ClassNotFoundException if the class was not found */ -public Class loadClass(String name, boolean resolve) +public Class loadClass(final String name, boolean resolve) throws ClassNotFoundException { Class clazz = null; -157,12 +160,15 int dot = name.lastIndexOf('.'); if (securityManager != null) { if (dot = 0) { -try { -securityManager.checkPackageAccess(name.substring(0,dot)); +try { +// Do not call the security manager since by default, we grant that package. +if (!org.apache.jasper.runtime.equalsIgnoreCase(name.substring(0,dot))){ +securityManager.checkPackageAccess(name.substring(0,dot)); +} } catch (SecurityException se) { String error = Security Violation, attempt to use + Restricted Class: + name; -System.out.println(error); +se.printStackTrace(); throw new ClassNotFoundException(error); } } -170,13 +176,22 // Class is in a package, delegate to thread context class loader if( !name.startsWith(Constants.JSP_PACKAGE_NAME) ) { -ClassLoader classLoader = null; if (securityManager != null) { - classLoader = (ClassLoader)AccessController.doPrivileged(privLoadClass); -} else { - classLoader = Thread.currentThread().getContextClassLoader(); -} -clazz = classLoader.loadClass(name); +final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged(privLoadClass); +try{ +clazz = (Class)AccessController.doPrivileged(new PrivilegedExceptionAction(){ +public Object run() throws Exception{ +return classLoader.loadClass(name); +} +}); +} catch(PrivilegedActionException ex){ +ex.getException().printStackTrace(); + +} + } else { +clazz = Thread.currentThread().getContextClassLoader().loadClass(name); + } + if( resolve ) resolveClass(clazz); return clazz; -228,10 +243,21 /* * Load JSP class data from file. */ -private byte[] loadClassDataFromFile(String fileName) { +private byte[] loadClassDataFromFile(final String fileName) { byte[] classBytes = null; try { -InputStream in = getResourceAsStream(fileName); +InputStream in = null; + +if (System.getSecurityManager() != null){ +in = (InputStream)AccessController.doPrivileged(new PrivilegedAction(){ +public Object run(){ +return getResourceAsStream(fileName); +} +}); +} else { +in = getResourceAsStream(fileName); +} + if (in == null) {
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java
luehe 2002/10/21 11:44:01 Modified:jasper2/src/share/org/apache/jasper JspC.java JspCompilationContext.java jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: Reduced visibility of fields/methods where appropriate Revision ChangesPath 1.16 +3 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java Index: JspC.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- JspC.java 10 Oct 2002 00:49:21 - 1.15 +++ JspC.java 21 Oct 2002 18:44:00 - 1.16 -69,7 +69,6 import org.apache.jasper.compiler.Compiler; import org.apache.jasper.compiler.TldLocationsCache; -import org.apache.jasper.servlet.JasperLoader; import org.apache.jasper.servlet.JspCServletContext; import org.apache.jasper.logging.Logger; 1.23 +38 -36 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java Index: JspCompilationContext.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- JspCompilationContext.java10 Oct 2002 00:49:21 - 1.22 +++ JspCompilationContext.java21 Oct 2002 18:44:00 - 1.23 -91,38 +91,38 private Hashtable tagFileJars; private boolean isPackagedTagFile; -protected String servletClassName; -protected String jspUri; +private String servletClassName; +private String jspUri; private boolean isErrPage; -protected String servletPackageName = Constants.JSP_PACKAGE_NAME; -protected String servletJavaFileName; -protected String jspPath; -protected String classFileName; -protected String contentType; -protected ServletWriter writer; -protected Options options; -protected JspServletWrapper jsw; -protected Compiler jspCompiler; -protected String classPath; - -protected String baseURI; -protected String outputDir; -protected ServletContext context; -protected URLClassLoader loader; +private String servletPackageName; +private String servletJavaFileName; +private String jspPath; +private String classFileName; +private String contentType; +private ServletWriter writer; +private Options options; +private JspServletWrapper jsw; +private Compiler jspCompiler; +private String classPath; + +private String baseURI; +private String outputDir; +private ServletContext context; +private URLClassLoader loader; -protected JspRuntimeContext rctxt; +private JspRuntimeContext rctxt; -protected int removed = 0; -protected boolean reload = true; +private int removed = 0; +private boolean reload = true; -protected URLClassLoader jspLoader; -protected URL[] outUrls = new URL[2]; -protected Class servletClass; - -protected boolean isTagFile; -protected boolean protoTypeMode; -protected TagInfo tagInfo; -protected TagData tagData; +private URLClassLoader jspLoader; +private URL[] outUrls; +private Class servletClass; + +private boolean isTagFile; +private boolean protoTypeMode; +private TagInfo tagInfo; +private TagData tagData; // jspURI _must_ be relative to the context public JspCompilationContext(String jspUri, -134,10 +134,10 this.jspUri = canonicalURI(jspUri); this.isErrPage = isErrPage; -this.options=options; -this.jsw=jsw; -this.context=context; - +this.options = options; +this.jsw = jsw; +this.context = context; + this.baseURI = jspUri.substring(0, jspUri.lastIndexOf('/') + 1); // hack fix for resolveRelativeURI if (baseURI == null) { -150,9 +150,11 if (baseURI.charAt(baseURI.length() - 1) != '/') { baseURI += '/'; } -this.rctxt=rctxt; +this.rctxt = rctxt; this.tagFileJars = new Hashtable(); +this.servletPackageName = Constants.JSP_PACKAGE_NAME; + this.outUrls = new URL[2]; } public JspCompilationContext(String tagfile, 1.5 +28 -40 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java Index: JasperLoader.java === RCS file:
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet JasperLoader.java JspServlet.java JspServletWrapper.java
glenn 02/05/05 21:33:16 Modified:jasper2/src/share/org/apache/jasper EmbededServletOptions.java JspC.java JspEngineContext.java Options.java jasper2/src/share/org/apache/jasper/compiler Compiler.java Generator.java JspCompiler.java PageInfo.java ParserController.java jasper2/src/share/org/apache/jasper/resources messages.properties jasper2/src/share/org/apache/jasper/runtime HttpJspBase.java jasper2/src/share/org/apache/jasper/servlet JasperLoader.java JspServlet.java JspServletWrapper.java Added: jasper2/src/share/org/apache/jasper/compiler JspRuntimeContext.java Log: Reduced amount of code within the JspServlet synchronized block, should improve performance slightly. Added ability to remove the JspServletWrapper and the class file for its JSP when a JSP file no longer exists. Added removal of JSP java source file to Compiler.removeGeneratedFiles(). Moved the normalizing of the java class output directory from JspServletWrapper to JspEngineContext where it belongs. Moved obtaining the parentClassLoader, codeSource, classpath, and permissionCollection from the JspServlet to JspDependency. The servlet init method for the JSP was not getting called on the first load of the JSP page if the page were already compiled. This has been fixed. Refactored the code in JspServletWrapper for loadJSP to remove nested try/catch blocks and the overhead from several method calls. The outdated check for recompile now includes checking of compile time included files using %@ include file=... %. The data about what pages were compile time includes is generated as part of the Servlet code for the JSP. This is alot cleaner than my original proposal of storing the data in a separate file. Added the JspRuntimeContext background thread. It checks for changes to the JSP file and compile time included files. If changed, it recompiles the JSP in the background. This will allow the previous compiled JSP class to be used until the page has been recompiled and the new class is available. This will remove any request latency seen due to JSP recompiles. The background thread is only started if the web application context is a directory, reloading is enabled, and development is false. If the webapp is running directly from a war file there is no need to check for recompiles. Added two Jasper init parameters: development - set to true to force an outdated check on each page request instead of using background thread. checkInterval - Number of seconds background thread should wait before checking if JSP's are out dated. Passes all jsp watchdog tests except for the broken test case. Revision ChangesPath 1.3 +51 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/EmbededServletOptions.java Index: EmbededServletOptions.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/EmbededServletOptions.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- EmbededServletOptions.java29 Apr 2002 22:39:46 - 1.2 +++ EmbededServletOptions.java6 May 2002 04:33:15 - 1.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/EmbededServletOptions.java,v 1.2 2002/04/29 22:39:46 remm Exp $ - * $Revision: 1.2 $ - * $Date: 2002/04/29 22:39:46 $ + * $Header: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/EmbededServletOptions.java,v 1.3 2002/05/06 04:33:15 glenn Exp $ + * $Revision: 1.3 $ + * $Date: 2002/05/06 04:33:15 $ * * * @@ -78,6 +78,12 @@ * @author Pierre Delisle */ public final class EmbededServletOptions implements Options { + +/** + * Is Jasper being used in development mode? + */ +public boolean development = false; + /** * Do you want to keep the generated Java files around? */ @@ -111,6 +117,11 @@ public boolean classDebugInfo = false; /** + * Background compile thread check interval in seconds. + */ +public int checkInterval = 300; + +/** * JSP reloading check ? */ public boolean reloading = true; @@ -190,6 +201,20 @@ } /** + * Background JSP compile thread check intervall + */ +public int getCheckInterval() { +return checkInterval; +} + +/**