From c9376dc2cf4bef702537795007cd4c227313a805 Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 27 Nov 2008 21:54:36 +0000 Subject: [PATCH] Generics changes for remainder of Jasper. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@721289 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/jasper/runtime/HttpJspBase.java | 1 - .../jasper/runtime/JspApplicationContextImpl.java | 5 +- .../apache/jasper/runtime/JspContextWrapper.java | 29 ++++++----- java/org/apache/jasper/runtime/JspFactoryImpl.java | 16 +++--- .../apache/jasper/runtime/JspRuntimeLibrary.java | 41 +++++++-------- java/org/apache/jasper/runtime/JspWriterImpl.java | 4 +- .../org/apache/jasper/runtime/PageContextImpl.java | 60 ++++++++++++---------- .../jasper/runtime/PerThreadTagHandlerPool.java | 22 ++++---- .../jasper/runtime/ProtectedFunctionMapper.java | 38 +++++++------- java/org/apache/jasper/runtime/TagHandlerPool.java | 6 +-- java/org/apache/jasper/servlet/JasperLoader.java | 6 +-- .../apache/jasper/servlet/JspCServletContext.java | 22 ++++---- java/org/apache/jasper/servlet/JspServlet.java | 13 +++-- .../apache/jasper/servlet/JspServletWrapper.java | 8 +-- java/org/apache/jasper/util/Enumerator.java | 20 ++++---- 15 files changed, 151 insertions(+), 140 deletions(-) diff --git a/java/org/apache/jasper/runtime/HttpJspBase.java b/java/org/apache/jasper/runtime/HttpJspBase.java index a1b6413aa..4acc0e470 100644 --- a/java/org/apache/jasper/runtime/HttpJspBase.java +++ b/java/org/apache/jasper/runtime/HttpJspBase.java @@ -25,7 +25,6 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.HttpJspPage; -import javax.servlet.jsp.JspFactory; import org.apache.jasper.compiler.Localizer; diff --git a/java/org/apache/jasper/runtime/JspApplicationContextImpl.java b/java/org/apache/jasper/runtime/JspApplicationContextImpl.java index 1ea649aa6..a6431d344 100644 --- a/java/org/apache/jasper/runtime/JspApplicationContextImpl.java +++ b/java/org/apache/jasper/runtime/JspApplicationContextImpl.java @@ -106,8 +106,9 @@ public class JspApplicationContextImpl implements JspApplicationContext { if (this.resolver == null) { CompositeELResolver r = new CompositeELResolver(); r.add(new ImplicitObjectELResolver()); - for (Iterator itr = this.resolvers.iterator(); itr.hasNext();) { - r.add((ELResolver) itr.next()); + for (Iterator itr = this.resolvers.iterator(); + itr.hasNext();) { + r.add(itr.next()); } r.add(new MapELResolver()); r.add(new ResourceBundleELResolver()); diff --git a/java/org/apache/jasper/runtime/JspContextWrapper.java b/java/org/apache/jasper/runtime/JspContextWrapper.java index 05f663836..11a3b2136 100644 --- a/java/org/apache/jasper/runtime/JspContextWrapper.java +++ b/java/org/apache/jasper/runtime/JspContextWrapper.java @@ -65,20 +65,21 @@ public class JspContextWrapper extends PageContext implements VariableResolver { private transient HashMap pageAttributes; // ArrayList of NESTED scripting variables - private ArrayList nestedVars; + private ArrayList nestedVars; // ArrayList of AT_BEGIN scripting variables - private ArrayList atBeginVars; + private ArrayList atBeginVars; // ArrayList of AT_END scripting variables - private ArrayList atEndVars; + private ArrayList atEndVars; - private Map aliases; + private Map aliases; private HashMap originalNestedVars; - public JspContextWrapper(JspContext jspContext, ArrayList nestedVars, - ArrayList atBeginVars, ArrayList atEndVars, Map aliases) { + public JspContextWrapper(JspContext jspContext, + ArrayList nestedVars, ArrayList atBeginVars, + ArrayList atEndVars, Map aliases) { this.invokingJspCtxt = (PageContext) jspContext; this.nestedVars = nestedVars; this.atBeginVars = atBeginVars; @@ -222,7 +223,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver { public Enumeration getAttributeNamesInScope(int scope) { if (scope == PAGE_SCOPE) { - return new Enumerator(pageAttributes.keySet().iterator()); + return new Enumerator(pageAttributes.keySet().iterator()); } return invokingJspCtxt.getAttributeNamesInScope(scope); @@ -351,7 +352,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver { * variable scope (one of NESTED, AT_BEGIN, or AT_END) */ private void copyTagToPageScope(int scope) { - Iterator iter = null; + Iterator iter = null; switch (scope) { case VariableInfo.NESTED: @@ -372,7 +373,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver { } while ((iter != null) && iter.hasNext()) { - String varName = (String) iter.next(); + String varName = iter.next(); Object obj = getAttribute(varName); varName = findAlias(varName); if (obj != null) { @@ -389,9 +390,9 @@ public class JspContextWrapper extends PageContext implements VariableResolver { */ private void saveNestedVariables() { if (nestedVars != null) { - Iterator iter = nestedVars.iterator(); + Iterator iter = nestedVars.iterator(); while (iter.hasNext()) { - String varName = (String) iter.next(); + String varName = iter.next(); varName = findAlias(varName); Object obj = invokingJspCtxt.getAttribute(varName); if (obj != null) { @@ -406,9 +407,9 @@ public class JspContextWrapper extends PageContext implements VariableResolver { */ private void restoreNestedVariables() { if (nestedVars != null) { - Iterator iter = nestedVars.iterator(); + Iterator iter = nestedVars.iterator(); while (iter.hasNext()) { - String varName = (String) iter.next(); + String varName = iter.next(); varName = findAlias(varName); Object obj = originalNestedVars.get(varName); if (obj != null) { @@ -434,7 +435,7 @@ public class JspContextWrapper extends PageContext implements VariableResolver { if (aliases == null) return varName; - String alias = (String) aliases.get(varName); + String alias = aliases.get(varName); if (alias == null) { return varName; } diff --git a/java/org/apache/jasper/runtime/JspFactoryImpl.java b/java/org/apache/jasper/runtime/JspFactoryImpl.java index f9852b3f9..241517538 100644 --- a/java/org/apache/jasper/runtime/JspFactoryImpl.java +++ b/java/org/apache/jasper/runtime/JspFactoryImpl.java @@ -56,9 +56,9 @@ public class JspFactoryImpl extends JspFactory { if( Constants.IS_SECURITY_ENABLED ) { PrivilegedGetPageContext dp = new PrivilegedGetPageContext( - (JspFactoryImpl)this, servlet, request, response, errorPageURL, + this, servlet, request, response, errorPageURL, needsSession, bufferSize, autoflush); - return (PageContext)AccessController.doPrivileged(dp); + return AccessController.doPrivileged(dp); } else { return internalGetPageContext(servlet, request, response, errorPageURL, needsSession, @@ -71,7 +71,7 @@ public class JspFactoryImpl extends JspFactory { return; if( Constants.IS_SECURITY_ENABLED ) { PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext( - (JspFactoryImpl)this,pc); + this,pc); AccessController.doPrivileged(dp); } else { internalReleasePageContext(pc); @@ -121,7 +121,8 @@ public class JspFactoryImpl extends JspFactory { } } - private class PrivilegedGetPageContext implements PrivilegedAction { + private class PrivilegedGetPageContext + implements PrivilegedAction { private JspFactoryImpl factory; private Servlet servlet; @@ -145,13 +146,14 @@ public class JspFactoryImpl extends JspFactory { this.autoflush = autoflush; } - public Object run() { + public PageContext run() { return factory.internalGetPageContext(servlet, request, response, errorPageURL, needsSession, bufferSize, autoflush); } } - private class PrivilegedReleasePageContext implements PrivilegedAction { + private class PrivilegedReleasePageContext + implements PrivilegedAction { private JspFactoryImpl factory; private PageContext pageContext; @@ -162,7 +164,7 @@ public class JspFactoryImpl extends JspFactory { this.pageContext = pageContext; } - public Object run() { + public Void run() { factory.internalReleasePageContext(pageContext); return null; } diff --git a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java index e5644f3c0..9308cb643 100644 --- a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java +++ b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java @@ -61,7 +61,7 @@ public class JspRuntimeLibrary { = "javax.servlet.jsp.jspException"; protected static class PrivilegedIntrospectHelper - implements PrivilegedExceptionAction { + implements PrivilegedExceptionAction { private Object bean; private String prop; @@ -82,7 +82,7 @@ public class JspRuntimeLibrary { this.ignoreMethodNF = ignoreMethodNF; } - public Object run() throws JasperException { + public Void run() throws JasperException { internalIntrospecthelper( bean,prop,value,request,param,ignoreMethodNF); return null; @@ -175,7 +175,7 @@ public class JspRuntimeLibrary { return Long.valueOf(s).longValue(); } - public static Object coerce(String s, Class target) { + public static Object coerce(String s, Class target) { boolean isNullOrEmpty = (s == null || s.length() == 0); @@ -225,8 +225,8 @@ public class JspRuntimeLibrary { } // __begin convertMethod - public static Object convert(String propertyName, String s, Class t, - Class propertyEditorClass) + public static Object convert(String propertyName, String s, Class t, + Class propertyEditorClass) throws JasperException { try { @@ -279,9 +279,9 @@ public class JspRuntimeLibrary { public static void introspect(Object bean, ServletRequest request) throws JasperException { - Enumeration e = request.getParameterNames(); + Enumeration e = request.getParameterNames(); while ( e.hasMoreElements() ) { - String name = (String) e.nextElement(); + String name = e.nextElement(); String value = request.getParameter(name); introspecthelper(bean, name, value, request, name, true); } @@ -316,8 +316,8 @@ public class JspRuntimeLibrary { throws JasperException { Method method = null; - Class type = null; - Class propertyEditorClass = null; + Class type = null; + Class propertyEditorClass = null; try { java.beans.BeanInfo info = java.beans.Introspector.getBeanInfo(bean.getClass()); @@ -339,7 +339,7 @@ public class JspRuntimeLibrary { throw new JasperException( Localizer.getMessage("jsp.error.beans.setproperty.noindexset")); } - Class t = type.getComponentType(); + Class t = type.getComponentType(); String[] values = request.getParameterValues(param); //XXX Please check. if(values == null) return; @@ -428,8 +428,8 @@ public class JspRuntimeLibrary { Object bean, Method method, String[] values, - Class t, - Class propertyEditorClass) + Class t, + Class propertyEditorClass) throws JasperException { try { @@ -764,10 +764,10 @@ public class JspRuntimeLibrary { } } - public static Method getWriteMethod(Class beanClass, String prop) + public static Method getWriteMethod(Class beanClass, String prop) throws JasperException { Method method = null; - Class type = null; + Class type = null; try { java.beans.BeanInfo info = java.beans.Introspector.getBeanInfo(beanClass); @@ -807,11 +807,11 @@ public class JspRuntimeLibrary { return method; } - public static Method getReadMethod(Class beanClass, String prop) + public static Method getReadMethod(Class beanClass, String prop) throws JasperException { Method method = null; - Class type = null; + Class type = null; try { java.beans.BeanInfo info = java.beans.Introspector.getBeanInfo(beanClass); @@ -853,12 +853,13 @@ public class JspRuntimeLibrary { // PropertyEditor Support public static Object getValueFromBeanInfoPropertyEditor( - Class attrClass, String attrName, String attrValue, - Class propertyEditorClass) + Class attrClass, String attrName, String attrValue, + Class propertyEditorClass) throws JasperException { try { - PropertyEditor pe = (PropertyEditor)propertyEditorClass.newInstance(); + PropertyEditor pe = + (PropertyEditor)propertyEditorClass.newInstance(); pe.setAsText(attrValue); return pe.getValue(); } catch (Exception ex) { @@ -870,7 +871,7 @@ public class JspRuntimeLibrary { } public static Object getValueFromPropertyEditorManager( - Class attrClass, String attrName, String attrValue) + Class attrClass, String attrName, String attrValue) throws JasperException { try { diff --git a/java/org/apache/jasper/runtime/JspWriterImpl.java b/java/org/apache/jasper/runtime/JspWriterImpl.java index cf7a44383..823b6f5cc 100644 --- a/java/org/apache/jasper/runtime/JspWriterImpl.java +++ b/java/org/apache/jasper/runtime/JspWriterImpl.java @@ -128,8 +128,8 @@ public class JspWriterImpl extends JspWriter { private String getLocalizeMessage(final String message){ if (SecurityUtil.isPackageProtectionEnabled()){ - return (String)AccessController.doPrivileged(new PrivilegedAction(){ - public Object run(){ + return AccessController.doPrivileged(new PrivilegedAction(){ + public String run(){ return Localizer.getMessage(message); } }); diff --git a/java/org/apache/jasper/runtime/PageContextImpl.java b/java/org/apache/jasper/runtime/PageContextImpl.java index fb2bc10f9..67e8fb367 100644 --- a/java/org/apache/jasper/runtime/PageContextImpl.java +++ b/java/org/apache/jasper/runtime/PageContextImpl.java @@ -214,7 +214,8 @@ public class PageContextImpl extends PageContext { } if (SecurityUtil.isPackageProtectionEnabled()) { - return AccessController.doPrivileged(new PrivilegedAction() { + return AccessController.doPrivileged( + new PrivilegedAction() { public Object run() { return doGetAttribute(name); } @@ -237,7 +238,8 @@ public class PageContextImpl extends PageContext { } if (SecurityUtil.isPackageProtectionEnabled()) { - return AccessController.doPrivileged(new PrivilegedAction() { + return AccessController.doPrivileged( + new PrivilegedAction() { public Object run() { return doGetAttribute(name, scope); } @@ -279,8 +281,8 @@ public class PageContextImpl extends PageContext { } if (SecurityUtil.isPackageProtectionEnabled()) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { doSetAttribute(name, attribute); return null; } @@ -306,8 +308,8 @@ public class PageContextImpl extends PageContext { } if (SecurityUtil.isPackageProtectionEnabled()) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { doSetAttribute(name, o, scope); return null; } @@ -356,8 +358,8 @@ public class PageContextImpl extends PageContext { .getMessage("jsp.error.attribute.null_name")); } if (SecurityUtil.isPackageProtectionEnabled()) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { doRemoveAttribute(name, scope); return null; } @@ -402,9 +404,9 @@ public class PageContextImpl extends PageContext { } if (SecurityUtil.isPackageProtectionEnabled()) { - return ((Integer) AccessController - .doPrivileged(new PrivilegedAction() { - public Object run() { + return (AccessController + .doPrivileged(new PrivilegedAction() { + public Integer run() { return new Integer(doGetAttributeScope(name)); } })).intValue(); @@ -433,7 +435,8 @@ public class PageContextImpl extends PageContext { public Object findAttribute(final String name) { if (SecurityUtil.isPackageProtectionEnabled()) { - return AccessController.doPrivileged(new PrivilegedAction() { + return AccessController.doPrivileged( + new PrivilegedAction() { public Object run() { if (name == null) { throw new NullPointerException(Localizer @@ -474,9 +477,9 @@ public class PageContextImpl extends PageContext { public Enumeration getAttributeNamesInScope(final int scope) { if (SecurityUtil.isPackageProtectionEnabled()) { - return (Enumeration) AccessController - .doPrivileged(new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged( + new PrivilegedAction>() { + public Enumeration run() { return doGetAttributeNamesInScope(scope); } }); @@ -485,10 +488,10 @@ public class PageContextImpl extends PageContext { } } - private Enumeration doGetAttributeNamesInScope(int scope) { + private Enumeration doGetAttributeNamesInScope(int scope) { switch (scope) { case PAGE_SCOPE: - return new Enumerator(attributes.keySet().iterator()); + return new Enumerator(attributes.keySet().iterator()); case REQUEST_SCOPE: return request.getAttributeNames(); @@ -516,8 +519,8 @@ public class PageContextImpl extends PageContext { } if (SecurityUtil.isPackageProtectionEnabled()) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { doRemoveAttribute(name); return null; } @@ -616,8 +619,9 @@ public class PageContextImpl extends PageContext { throws ServletException, IOException { if (SecurityUtil.isPackageProtectionEnabled()) { try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws Exception { doInclude(relativeUrlPath, flush); return null; } @@ -649,8 +653,9 @@ public class PageContextImpl extends PageContext { IOException { if (SecurityUtil.isPackageProtectionEnabled()) { try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws Exception { doForward(relativeUrlPath); return null; } @@ -763,8 +768,9 @@ public class PageContextImpl extends PageContext { if (SecurityUtil.isPackageProtectionEnabled()) { try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { + AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Void run() throws Exception { doHandlePageException(t); return null; } @@ -893,7 +899,7 @@ public class PageContextImpl extends PageContext { * @return The result of the evaluation */ public static Object proprietaryEvaluate(final String expression, - final Class expectedType, final PageContext pageContext, + final Class expectedType, final PageContext pageContext, final ProtectedFunctionMapper functionMap, final boolean escape) throws ELException { Object retValue; @@ -901,7 +907,7 @@ public class PageContextImpl extends PageContext { if (SecurityUtil.isPackageProtectionEnabled()) { try { retValue = AccessController - .doPrivileged(new PrivilegedExceptionAction() { + .doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { ELContextImpl ctx = (ELContextImpl) pageContext.getELContext(); diff --git a/java/org/apache/jasper/runtime/PerThreadTagHandlerPool.java b/java/org/apache/jasper/runtime/PerThreadTagHandlerPool.java index 58640efcf..2d0892f11 100644 --- a/java/org/apache/jasper/runtime/PerThreadTagHandlerPool.java +++ b/java/org/apache/jasper/runtime/PerThreadTagHandlerPool.java @@ -37,9 +37,9 @@ public class PerThreadTagHandlerPool extends TagHandlerPool { private int maxSize; // For cleanup - private Vector perThreadDataVector; + private Vector perThreadDataVector; - private ThreadLocal perThread; + private ThreadLocal perThread; private static class PerThreadData { Tag handlers[]; @@ -51,7 +51,7 @@ public class PerThreadTagHandlerPool extends TagHandlerPool { */ public PerThreadTagHandlerPool() { super(); - perThreadDataVector = new Vector(); + perThreadDataVector = new Vector(); } protected void init(ServletConfig config) { @@ -64,8 +64,8 @@ public class PerThreadTagHandlerPool extends TagHandlerPool { } } - perThread = new ThreadLocal() { - protected Object initialValue() { + perThread = new ThreadLocal() { + protected PerThreadData initialValue() { PerThreadData ptd = new PerThreadData(); ptd.handlers = new Tag[maxSize]; ptd.current = -1; @@ -85,13 +85,13 @@ public class PerThreadTagHandlerPool extends TagHandlerPool { * * @throws JspException if a tag handler cannot be instantiated */ - public Tag get(Class handlerClass) throws JspException { - PerThreadData ptd = (PerThreadData)perThread.get(); + public Tag get(Class handlerClass) throws JspException { + PerThreadData ptd = perThread.get(); if(ptd.current >=0 ) { return ptd.handlers[ptd.current--]; } else { try { - return (Tag) handlerClass.newInstance(); + return handlerClass.newInstance(); } catch (Exception e) { throw new JspException(e.getMessage(), e); } @@ -106,7 +106,7 @@ public class PerThreadTagHandlerPool extends TagHandlerPool { * @param handler Tag handler to add to this tag handler pool */ public void reuse(Tag handler) { - PerThreadData ptd=(PerThreadData)perThread.get(); + PerThreadData ptd = perThread.get(); if (ptd.current < (ptd.handlers.length - 1)) { ptd.handlers[++ptd.current] = handler; } else { @@ -118,9 +118,9 @@ public class PerThreadTagHandlerPool extends TagHandlerPool { * Calls the release() method of all tag handlers in this tag handler pool. */ public void release() { - Enumeration enumeration = perThreadDataVector.elements(); + Enumeration enumeration = perThreadDataVector.elements(); while (enumeration.hasMoreElements()) { - PerThreadData ptd = (PerThreadData)enumeration.nextElement(); + PerThreadData ptd = enumeration.nextElement(); if (ptd.handlers != null) { for (int i=ptd.current; i>=0; i--) { if (ptd.handlers[i] != null) { diff --git a/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java b/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java index 309e21135..8a1d14146 100644 --- a/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java +++ b/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java @@ -40,7 +40,7 @@ public final class ProtectedFunctionMapper extends javax.el.FunctionMapper /** * Maps "prefix:name" to java.lang.Method objects. */ - private HashMap fnmap = null; + private HashMap fnmap = null; /** * If there is only one function in the map, this is the Method for it. @@ -64,16 +64,16 @@ public final class ProtectedFunctionMapper extends javax.el.FunctionMapper public static ProtectedFunctionMapper getInstance() { ProtectedFunctionMapper funcMapper; if (SecurityUtil.isPackageProtectionEnabled()) { - funcMapper = (ProtectedFunctionMapper) AccessController - .doPrivileged(new PrivilegedAction() { - public Object run() { + funcMapper = AccessController.doPrivileged( + new PrivilegedAction() { + public ProtectedFunctionMapper run() { return new ProtectedFunctionMapper(); } }); } else { funcMapper = new ProtectedFunctionMapper(); } - funcMapper.fnmap = new java.util.HashMap(); + funcMapper.fnmap = new HashMap(); return funcMapper; } @@ -92,15 +92,14 @@ public final class ProtectedFunctionMapper extends javax.el.FunctionMapper * @throws RuntimeException * if no method with the given signature could be found. */ - public void mapFunction(String fnQName, final Class c, - final String methodName, final Class[] args) { + public void mapFunction(String fnQName, final Class c, + final String methodName, final Class[] args) { java.lang.reflect.Method method; if (SecurityUtil.isPackageProtectionEnabled()) { try { - method = (java.lang.reflect.Method) AccessController - .doPrivileged(new PrivilegedExceptionAction() { - - public Object run() throws Exception { + method = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Method run() throws Exception { return c.getDeclaredMethod(methodName, args); } }); @@ -139,22 +138,21 @@ public final class ProtectedFunctionMapper extends javax.el.FunctionMapper * if no method with the given signature could be found. */ public static ProtectedFunctionMapper getMapForFunction(String fnQName, - final Class c, final String methodName, final Class[] args) { + final Class c, final String methodName, final Class[] args) { java.lang.reflect.Method method; ProtectedFunctionMapper funcMapper; if (SecurityUtil.isPackageProtectionEnabled()) { - funcMapper = (ProtectedFunctionMapper) AccessController - .doPrivileged(new PrivilegedAction() { - public Object run() { + funcMapper = AccessController.doPrivileged( + new PrivilegedAction() { + public ProtectedFunctionMapper run() { return new ProtectedFunctionMapper(); } }); try { - method = (java.lang.reflect.Method) AccessController - .doPrivileged(new PrivilegedExceptionAction() { - - public Object run() throws Exception { + method = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Method run() throws Exception { return c.getDeclaredMethod(methodName, args); } }); @@ -189,7 +187,7 @@ public final class ProtectedFunctionMapper extends javax.el.FunctionMapper */ public Method resolveFunction(String prefix, String localName) { if (this.fnmap != null) { - return (Method) this.fnmap.get(prefix + ":" + localName); + return this.fnmap.get(prefix + ":" + localName); } return theMethod; } diff --git a/java/org/apache/jasper/runtime/TagHandlerPool.java b/java/org/apache/jasper/runtime/TagHandlerPool.java index b9b32907e..7974c4de9 100644 --- a/java/org/apache/jasper/runtime/TagHandlerPool.java +++ b/java/org/apache/jasper/runtime/TagHandlerPool.java @@ -50,7 +50,7 @@ public class TagHandlerPool { String tpClassName=getOption( config, OPTION_TAGPOOL, null); if( tpClassName != null ) { try { - Class c=Class.forName( tpClassName ); + Class c=Class.forName( tpClassName ); result=(TagHandlerPool)c.newInstance(); } catch (Exception e) { e.printStackTrace(); @@ -110,7 +110,7 @@ public class TagHandlerPool { * * @throws JspException if a tag handler cannot be instantiated */ - public Tag get(Class handlerClass) throws JspException { + public Tag get(Class handlerClass) throws JspException { Tag handler; synchronized( this ) { if (current >= 0) { @@ -125,7 +125,7 @@ public class TagHandlerPool { if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) { return (Tag) instanceManager.newInstance(handlerClass.getName(), handlerClass.getClassLoader()); } else { - Tag instance = (Tag) handlerClass.newInstance(); + Tag instance = handlerClass.newInstance(); instanceManager.newInstance(instance); return instance; } diff --git a/java/org/apache/jasper/servlet/JasperLoader.java b/java/org/apache/jasper/servlet/JasperLoader.java index 6180119a6..c04db180a 100644 --- a/java/org/apache/jasper/servlet/JasperLoader.java +++ b/java/org/apache/jasper/servlet/JasperLoader.java @@ -61,7 +61,7 @@ public class JasperLoader extends URLClassLoader { * * @exception ClassNotFoundException if the class was not found */ - public Class loadClass(String name) throws ClassNotFoundException { + public Class loadClass(String name) throws ClassNotFoundException { return (loadClass(name, false)); } @@ -91,10 +91,10 @@ public class JasperLoader extends URLClassLoader { * * @exception ClassNotFoundException if the class was not found */ - public Class loadClass(final String name, boolean resolve) + public Class loadClass(final String name, boolean resolve) throws ClassNotFoundException { - Class clazz = null; + Class clazz = null; // (0) Check our previously loaded class cache clazz = findLoadedClass(name); diff --git a/java/org/apache/jasper/servlet/JspCServletContext.java b/java/org/apache/jasper/servlet/JspCServletContext.java index d0f324911..d7bf26ff8 100644 --- a/java/org/apache/jasper/servlet/JspCServletContext.java +++ b/java/org/apache/jasper/servlet/JspCServletContext.java @@ -51,7 +51,7 @@ public class JspCServletContext implements ServletContext { /** * Servlet context attributes. */ - protected Hashtable myAttributes; + protected Hashtable myAttributes; /** @@ -77,7 +77,7 @@ public class JspCServletContext implements ServletContext { */ public JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL) { - myAttributes = new Hashtable(); + myAttributes = new Hashtable(); myLogWriter = aLogWriter; myResourceBaseURL = aResourceBaseURL; @@ -102,7 +102,7 @@ public class JspCServletContext implements ServletContext { /** * Return an enumeration of context attribute names. */ - public Enumeration getAttributeNames() { + public Enumeration getAttributeNames() { return (myAttributes.keys()); @@ -147,9 +147,9 @@ public class JspCServletContext implements ServletContext { * Return an enumeration of the names of context initialization * parameters. */ - public Enumeration getInitParameterNames() { + public Enumeration getInitParameterNames() { - return (new Vector().elements()); + return (new Vector().elements()); } @@ -289,9 +289,9 @@ public class JspCServletContext implements ServletContext { * * @param path Context-relative base path */ - public Set getResourcePaths(String path) { + public Set getResourcePaths(String path) { - Set thePaths = new HashSet(); + Set thePaths = new HashSet(); if (!path.endsWith("/")) path += "/"; String basePath = getRealPath(path); @@ -352,9 +352,9 @@ public class JspCServletContext implements ServletContext { * * @deprecated This method has been deprecated with no replacement */ - public Enumeration getServletNames() { + public Enumeration getServletNames() { - return (new Vector().elements()); + return (new Vector().elements()); } @@ -364,9 +364,9 @@ public class JspCServletContext implements ServletContext { * * @deprecated This method has been deprecated with no replacement */ - public Enumeration getServlets() { + public Enumeration getServlets() { - return (new Vector().elements()); + return (new Vector().elements()); } diff --git a/java/org/apache/jasper/servlet/JspServlet.java b/java/org/apache/jasper/servlet/JspServlet.java index 8ec102104..9f24cea6e 100644 --- a/java/org/apache/jasper/servlet/JspServlet.java +++ b/java/org/apache/jasper/servlet/JspServlet.java @@ -85,9 +85,12 @@ public class JspServlet extends HttpServlet implements PeriodicEventListener { try { ClassLoader loader = Thread.currentThread() .getContextClassLoader(); - Class engineOptionsClass = loader.loadClass(engineOptionsName); - Class[] ctorSig = { ServletConfig.class, ServletContext.class }; - Constructor ctor = engineOptionsClass.getConstructor(ctorSig); + Class engineOptionsClass = + loader.loadClass(engineOptionsName); + Class[] ctorSig = + { ServletConfig.class, ServletContext.class }; + Constructor ctor = + engineOptionsClass.getConstructor(ctorSig); Object[] args = { config, context }; options = (Options) ctor.newInstance(args); } catch (Throwable e) { @@ -255,9 +258,9 @@ public class JspServlet extends HttpServlet implements PeriodicEventListener { log.debug("\t RequestURI: " + request.getRequestURI()); log.debug("\t QueryString: " + request.getQueryString()); log.debug("\t Request Params: "); - Enumeration e = request.getParameterNames(); + Enumeration e = request.getParameterNames(); while (e.hasMoreElements()) { - String name = (String) e.nextElement(); + String name = e.nextElement(); log.debug("\t\t " + name + " = " + request.getParameter(name)); } diff --git a/java/org/apache/jasper/servlet/JspServletWrapper.java b/java/org/apache/jasper/servlet/JspServletWrapper.java index 0feef71cc..81a5f5088 100644 --- a/java/org/apache/jasper/servlet/JspServletWrapper.java +++ b/java/org/apache/jasper/servlet/JspServletWrapper.java @@ -69,7 +69,7 @@ public class JspServletWrapper { private Servlet theServlet; private String jspUri; - private Class tagHandlerClass; + private Class tagHandlerClass; private JspCompilationContext ctxt; private long available = 0L; private ServletConfig config; @@ -198,7 +198,7 @@ public class JspServletWrapper { /** * Compile (if needed) and load a tag file */ - public Class loadTagFile() throws JasperException { + public Class loadTagFile() throws JasperException { try { if (ctxt.isRemoved()) { @@ -232,7 +232,7 @@ public class JspServletWrapper { * (skeleton) with no dependencies on other other tag files is * generated and compiled. */ - public Class loadTagFilePrototype() throws JasperException { + public Class loadTagFilePrototype() throws JasperException { ctxt.setPrototypeMode(true); try { @@ -258,7 +258,7 @@ public class JspServletWrapper { target = getServlet(); } if (target != null && target instanceof JspSourceDependent) { - return ((java.util.List) ((JspSourceDependent) target).getDependants()); + return ((JspSourceDependent) target).getDependants(); } } catch (Throwable ex) { } diff --git a/java/org/apache/jasper/util/Enumerator.java b/java/org/apache/jasper/util/Enumerator.java index 8c6e7e35b..912a9bca4 100644 --- a/java/org/apache/jasper/util/Enumerator.java +++ b/java/org/apache/jasper/util/Enumerator.java @@ -38,7 +38,7 @@ import java.util.NoSuchElementException; * @version $Revision$ $Date$ */ -public final class Enumerator implements Enumeration { +public final class Enumerator implements Enumeration { // ----------------------------------------------------------- Constructors @@ -49,7 +49,7 @@ public final class Enumerator implements Enumeration { * * @param collection Collection whose values should be enumerated */ - public Enumerator(Collection collection) { + public Enumerator(Collection collection) { this(collection.iterator()); @@ -62,7 +62,7 @@ public final class Enumerator implements Enumeration { * @param collection Collection whose values should be enumerated * @param clone true to clone iterator */ - public Enumerator(Collection collection, boolean clone) { + public Enumerator(Collection collection, boolean clone) { this(collection.iterator(), clone); @@ -75,7 +75,7 @@ public final class Enumerator implements Enumeration { * * @param iterator Iterator to be wrapped */ - public Enumerator(Iterator iterator) { + public Enumerator(Iterator iterator) { super(); this.iterator = iterator; @@ -90,13 +90,13 @@ public final class Enumerator implements Enumeration { * @param iterator Iterator to be wrapped * @param clone true to clone iterator */ - public Enumerator(Iterator iterator, boolean clone) { + public Enumerator(Iterator iterator, boolean clone) { super(); if (!clone) { this.iterator = iterator; } else { - List list = new ArrayList(); + List list = new ArrayList(); while (iterator.hasNext()) { list.add(iterator.next()); } @@ -111,7 +111,7 @@ public final class Enumerator implements Enumeration { * * @param map Map whose values should be enumerated */ - public Enumerator(Map map) { + public Enumerator(Map map) { this(map.values().iterator()); @@ -124,7 +124,7 @@ public final class Enumerator implements Enumeration { * @param map Map whose values should be enumerated * @param clone true to clone iterator */ - public Enumerator(Map map, boolean clone) { + public Enumerator(Map map, boolean clone) { this(map.values().iterator(), clone); @@ -138,7 +138,7 @@ public final class Enumerator implements Enumeration { * The Iterator over which the Enumeration * represented by this class actually operates. */ - private Iterator iterator = null; + private Iterator iterator = null; // --------------------------------------------------------- Public Methods @@ -166,7 +166,7 @@ public final class Enumerator implements Enumeration { * * @exception NoSuchElementException if no more elements exist */ - public Object nextElement() throws NoSuchElementException { + public T nextElement() throws NoSuchElementException { return (iterator.next()); -- 2.11.0