This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit f5977377e738ae03954f01cd2e7568c31d722d5b Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Oct 19 11:59:29 2022 +0100 Remove deprecated code - follow-up to JSP 4.0 changes --- java/org/apache/jasper/el/ELResolverImpl.java | 126 --------------------- .../apache/jasper/el/ExpressionEvaluatorImpl.java | 62 ---------- java/org/apache/jasper/el/ExpressionImpl.java | 44 ------- java/org/apache/jasper/el/FunctionMapperImpl.java | 37 ------ .../org/apache/jasper/el/VariableResolverImpl.java | 37 ------ .../apache/jasper/runtime/JspContextWrapper.java | 28 +---- .../org/apache/jasper/runtime/PageContextImpl.java | 23 +--- .../jasper/runtime/ProtectedFunctionMapper.java | 6 +- test/jakarta/servlet/jsp/TesterPageContext.java | 15 --- 9 files changed, 3 insertions(+), 375 deletions(-) diff --git a/java/org/apache/jasper/el/ELResolverImpl.java b/java/org/apache/jasper/el/ELResolverImpl.java deleted file mode 100644 index e2c389f30f..0000000000 --- a/java/org/apache/jasper/el/ELResolverImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.jasper.el; - -import java.util.Iterator; -import java.util.Objects; - -import jakarta.el.ELContext; -import jakarta.el.ELException; -import jakarta.el.ELResolver; -import jakarta.el.ExpressionFactory; -import jakarta.el.PropertyNotWritableException; -import jakarta.servlet.jsp.el.VariableResolver; - -@Deprecated -public final class ELResolverImpl extends ELResolver { - - private final VariableResolver variableResolver; - private final ELResolver elResolver; - - public ELResolverImpl(VariableResolver variableResolver, - ExpressionFactory factory) { - this.variableResolver = variableResolver; - this.elResolver = ELContextImpl.getDefaultResolver(factory); - } - - @Override - public Object getValue(ELContext context, Object base, Object property) { - Objects.requireNonNull(context); - - if (base == null) { - context.setPropertyResolved(base, property); - if (property != null) { - try { - return this.variableResolver.resolveVariable(property - .toString()); - } catch (jakarta.servlet.jsp.el.ELException e) { - throw new ELException(e.getMessage(), e.getCause()); - } - } - } - - if (!context.isPropertyResolved()) { - return elResolver.getValue(context, base, property); - } - return null; - } - - @Override - public Class<?> getType(ELContext context, Object base, Object property) { - Objects.requireNonNull(context); - - if (base == null) { - context.setPropertyResolved(base, property); - if (property != null) { - try { - Object obj = this.variableResolver.resolveVariable(property - .toString()); - return (obj != null) ? obj.getClass() : null; - } catch (jakarta.servlet.jsp.el.ELException e) { - throw new ELException(e.getMessage(), e.getCause()); - } - } - } - - if (!context.isPropertyResolved()) { - return elResolver.getType(context, base, property); - } - return null; - } - - @Override - public void setValue(ELContext context, Object base, Object property, - Object value) { - Objects.requireNonNull(context); - - if (base == null) { - context.setPropertyResolved(base, property); - throw new PropertyNotWritableException( - "Legacy VariableResolver wrapped, not writable"); - } - - if (!context.isPropertyResolved()) { - elResolver.setValue(context, base, property, value); - } - } - - @Override - public boolean isReadOnly(ELContext context, Object base, Object property) { - Objects.requireNonNull(context); - - if (base == null) { - context.setPropertyResolved(base, property); - return true; - } - - return elResolver.isReadOnly(context, base, property); - } - - @Override - public Iterator<java.beans.FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { - return elResolver.getFeatureDescriptors(context, base); - } - - @Override - public Class<?> getCommonPropertyType(ELContext context, Object base) { - if (base == null) { - return String.class; - } - return elResolver.getCommonPropertyType(context, base); - } -} diff --git a/java/org/apache/jasper/el/ExpressionEvaluatorImpl.java b/java/org/apache/jasper/el/ExpressionEvaluatorImpl.java deleted file mode 100644 index 0a9aa985ae..0000000000 --- a/java/org/apache/jasper/el/ExpressionEvaluatorImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.jasper.el; - -import jakarta.el.ExpressionFactory; -import jakarta.el.ValueExpression; -import jakarta.servlet.jsp.el.ELException; -import jakarta.servlet.jsp.el.ELParseException; -import jakarta.servlet.jsp.el.Expression; -import jakarta.servlet.jsp.el.ExpressionEvaluator; -import jakarta.servlet.jsp.el.FunctionMapper; -import jakarta.servlet.jsp.el.VariableResolver; - -@Deprecated -public final class ExpressionEvaluatorImpl extends ExpressionEvaluator { - - private final ExpressionFactory factory; - - public ExpressionEvaluatorImpl(ExpressionFactory factory) { - this.factory = factory; - } - - @Override - public Expression parseExpression(String expression, - @SuppressWarnings("rawtypes") Class expectedType, - FunctionMapper fMapper) throws ELException { - try { - ELContextImpl ctx = - new ELContextImpl(ELContextImpl.getDefaultResolver(factory)); - if (fMapper != null) { - ctx.setFunctionMapper(new FunctionMapperImpl(fMapper)); - } - ValueExpression ve = this.factory.createValueExpression(ctx, expression, expectedType); - return new ExpressionImpl(ve, factory); - } catch (jakarta.el.ELException e) { - throw new ELParseException(e.getMessage()); - } - } - - @Override - public Object evaluate(String expression, - @SuppressWarnings("rawtypes") Class expectedType, - VariableResolver vResolver, FunctionMapper fMapper) - throws ELException { - return this.parseExpression(expression, expectedType, fMapper).evaluate(vResolver); - } - -} diff --git a/java/org/apache/jasper/el/ExpressionImpl.java b/java/org/apache/jasper/el/ExpressionImpl.java deleted file mode 100644 index cf0e8fe74d..0000000000 --- a/java/org/apache/jasper/el/ExpressionImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.jasper.el; - -import jakarta.el.ELContext; -import jakarta.el.ExpressionFactory; -import jakarta.el.ValueExpression; -import jakarta.servlet.jsp.el.ELException; -import jakarta.servlet.jsp.el.Expression; -import jakarta.servlet.jsp.el.VariableResolver; - -@Deprecated -public final class ExpressionImpl extends Expression { - - private final ValueExpression ve; - private final ExpressionFactory factory; - - - public ExpressionImpl(ValueExpression ve, ExpressionFactory factory) { - this.ve = ve; - this.factory = factory; - } - - @Override - public Object evaluate(VariableResolver vResolver) throws ELException { - ELContext ctx = - new ELContextImpl(new ELResolverImpl(vResolver, factory)); - return ve.getValue(ctx); - } -} diff --git a/java/org/apache/jasper/el/FunctionMapperImpl.java b/java/org/apache/jasper/el/FunctionMapperImpl.java deleted file mode 100644 index 490d488f24..0000000000 --- a/java/org/apache/jasper/el/FunctionMapperImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.jasper.el; - -import java.lang.reflect.Method; - -import jakarta.servlet.jsp.el.FunctionMapper; - -@Deprecated -public final class FunctionMapperImpl extends jakarta.el.FunctionMapper { - - private final FunctionMapper fnMapper; - - public FunctionMapperImpl(FunctionMapper fnMapper) { - this.fnMapper = fnMapper; - } - - @Override - public Method resolveFunction(String prefix, String localName) { - return this.fnMapper.resolveFunction(prefix, localName); - } - -} diff --git a/java/org/apache/jasper/el/VariableResolverImpl.java b/java/org/apache/jasper/el/VariableResolverImpl.java deleted file mode 100644 index 18bd48c89e..0000000000 --- a/java/org/apache/jasper/el/VariableResolverImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.jasper.el; - -import jakarta.el.ELContext; -import jakarta.servlet.jsp.el.ELException; -import jakarta.servlet.jsp.el.VariableResolver; - -@Deprecated -public final class VariableResolverImpl implements VariableResolver { - - private final ELContext ctx; - - public VariableResolverImpl(ELContext ctx) { - this.ctx = ctx; - } - - @Override - public Object resolveVariable(String pName) throws ELException { - return this.ctx.getELResolver().getValue(this.ctx, null, pName); - } - -} diff --git a/java/org/apache/jasper/runtime/JspContextWrapper.java b/java/org/apache/jasper/runtime/JspContextWrapper.java index 9601d8161c..205739262d 100644 --- a/java/org/apache/jasper/runtime/JspContextWrapper.java +++ b/java/org/apache/jasper/runtime/JspContextWrapper.java @@ -46,10 +46,7 @@ import jakarta.servlet.jsp.JspContext; import jakarta.servlet.jsp.JspFactory; import jakarta.servlet.jsp.JspWriter; import jakarta.servlet.jsp.PageContext; -import jakarta.servlet.jsp.el.ELException; -import jakarta.servlet.jsp.el.ExpressionEvaluator; import jakarta.servlet.jsp.el.NotFoundELResolver; -import jakarta.servlet.jsp.el.VariableResolver; import jakarta.servlet.jsp.tagext.BodyContent; import jakarta.servlet.jsp.tagext.JspTag; import jakarta.servlet.jsp.tagext.VariableInfo; @@ -68,8 +65,7 @@ import org.apache.jasper.compiler.Localizer; * @author Jan Luehe * @author Jacob Hookom */ -@SuppressWarnings("deprecation") // Have to support old JSP EL API -public class JspContextWrapper extends PageContext implements VariableResolver { +public class JspContextWrapper extends PageContext{ private final JspTag jspTag; @@ -338,12 +334,6 @@ public class JspContextWrapper extends PageContext implements VariableResolver { invokingJspCtxt.include(relativeUrlPath, false); } - @Override - @Deprecated - public VariableResolver getVariableResolver() { - return this; - } - @Override public BodyContent pushBody() { return invokingJspCtxt.pushBody(); @@ -359,12 +349,6 @@ public class JspContextWrapper extends PageContext implements VariableResolver { return invokingJspCtxt.popBody(); } - @Override - @Deprecated - public ExpressionEvaluator getExpressionEvaluator() { - return invokingJspCtxt.getExpressionEvaluator(); - } - @Override public void handlePageException(Exception ex) throws IOException, ServletException { @@ -379,16 +363,6 @@ public class JspContextWrapper extends PageContext implements VariableResolver { invokingJspCtxt.handlePageException(t); } - /** - * VariableResolver interface - */ - @Override - @Deprecated - public Object resolveVariable(String pName) throws ELException { - ELContext ctx = this.getELContext(); - return ctx.getELResolver().getValue(ctx, null, pName); - } - /** * Synchronize variables at begin of tag file */ diff --git a/java/org/apache/jasper/runtime/PageContextImpl.java b/java/org/apache/jasper/runtime/PageContextImpl.java index 30476ab09a..d2d7e90692 100644 --- a/java/org/apache/jasper/runtime/PageContextImpl.java +++ b/java/org/apache/jasper/runtime/PageContextImpl.java @@ -496,13 +496,6 @@ public class PageContextImpl extends PageContext { JspRuntimeLibrary.include(request, response, relativeUrlPath, out, flush); } - @Override - @Deprecated - public jakarta.servlet.jsp.el.VariableResolver getVariableResolver() { - return new org.apache.jasper.el.VariableResolverImpl( - this.getELContext()); - } - @Override public void forward(final String relativeUrlPath) throws ServletException, IOException { // JSP.4.5 If the buffer was flushed, throw IllegalStateException @@ -574,18 +567,6 @@ public class PageContextImpl extends PageContext { return out; } - /** - * Provides programmatic access to the ExpressionEvaluator. The JSP - * Container must return a valid instance of an ExpressionEvaluator that can - * parse EL expressions. - */ - @Override - @Deprecated - public jakarta.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator() { - return new org.apache.jasper.el.ExpressionEvaluatorImpl( - this.applicationContext.getExpressionFactory()); - } - @Override public void handlePageException(Exception ex) throws IOException, ServletException { @@ -595,7 +576,6 @@ public class PageContextImpl extends PageContext { } @Override - @SuppressWarnings("deprecation") // Still have to support old JSP EL public void handlePageException(final Throwable t) throws IOException, ServletException { if (t == null) { throw new NullPointerException(Localizer.getMessage("jsp.error.page.nullThrowable")); @@ -655,8 +635,7 @@ public class PageContextImpl extends PageContext { } Throwable rootCause = null; - if (t instanceof JspException || t instanceof ELException || - t instanceof jakarta.servlet.jsp.el.ELException) { + if (t instanceof JspException || t instanceof ELException) { rootCause = t.getCause(); } diff --git a/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java b/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java index 31739b2fb0..0d18844363 100644 --- a/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java +++ b/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java @@ -19,8 +19,6 @@ package org.apache.jasper.runtime; import java.lang.reflect.Method; import java.util.HashMap; -import jakarta.servlet.jsp.el.FunctionMapper; - /** * Maps EL functions to their Java method counterparts. Keeps the actual Method * objects protected so that JSP pages can't indirectly do reflection. @@ -28,9 +26,7 @@ import jakarta.servlet.jsp.el.FunctionMapper; * @author Mark Roth * @author Kin-man Chung */ -@SuppressWarnings("deprecation") // Have to support old JSP EL API -public final class ProtectedFunctionMapper extends jakarta.el.FunctionMapper - implements FunctionMapper { +public final class ProtectedFunctionMapper extends jakarta.el.FunctionMapper { /** * Maps "prefix:name" to java.lang.Method objects. diff --git a/test/jakarta/servlet/jsp/TesterPageContext.java b/test/jakarta/servlet/jsp/TesterPageContext.java index 59814ca097..e9d722a07d 100644 --- a/test/jakarta/servlet/jsp/TesterPageContext.java +++ b/test/jakarta/servlet/jsp/TesterPageContext.java @@ -172,24 +172,9 @@ public class TesterPageContext extends PageContext { return null; } - @Override - @Deprecated - public jakarta.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator() { - // NO-OP - return null; - } - @Override public ELContext getELContext() { // NO-OP return null; } - - @Override - @Deprecated - public jakarta.servlet.jsp.el.VariableResolver getVariableResolver() { - // NO-OP - return null; - } - } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org