From 754439ed191d92d120353e9305bc885a1f59dc86 Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 7 Feb 2010 21:02:03 +0000 Subject: [PATCH] Get javax.servlet passing TCK API check Mainly removing generics and @Deprecated git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@907490 13f79535-47bb-0310-9956-ffa450edef68 --- java/javax/servlet/HttpConstraintElement.java | 2 +- .../javax/servlet/HttpMethodConstraintElement.java | 9 +++++++- java/javax/servlet/ServletContext.java | 24 ++++++++++---------- java/javax/servlet/ServletRequest.java | 5 +---- java/javax/servlet/ServletRequestWrapper.java | 6 ++--- java/javax/servlet/ServletResponseWrapper.java | 3 ++- java/javax/servlet/SingleThreadModel.java | 3 +-- java/javax/servlet/UnavailableException.java | 26 +++++++++------------- java/javax/servlet/annotation/HandlesTypes.java | 5 ++--- java/javax/servlet/annotation/MultipartConfig.java | 2 -- 10 files changed, 40 insertions(+), 45 deletions(-) diff --git a/java/javax/servlet/HttpConstraintElement.java b/java/javax/servlet/HttpConstraintElement.java index cb9ae8e98..f70ad74cb 100644 --- a/java/javax/servlet/HttpConstraintElement.java +++ b/java/javax/servlet/HttpConstraintElement.java @@ -28,7 +28,7 @@ import javax.servlet.annotation.ServletSecurity.TransportGuarantee; public class HttpConstraintElement { private static final String LSTRING_FILE = "javax.servlet.LocalStrings"; - protected static final ResourceBundle lStrings = + private static final ResourceBundle lStrings = ResourceBundle.getBundle(LSTRING_FILE); private EmptyRoleSemantic emptyRoleSemantic = EmptyRoleSemantic.PERMIT; diff --git a/java/javax/servlet/HttpMethodConstraintElement.java b/java/javax/servlet/HttpMethodConstraintElement.java index 025a5d617..4b016f8b6 100644 --- a/java/javax/servlet/HttpMethodConstraintElement.java +++ b/java/javax/servlet/HttpMethodConstraintElement.java @@ -16,12 +16,19 @@ */ package javax.servlet; +import java.util.ResourceBundle; + /** * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ public class HttpMethodConstraintElement extends HttpConstraintElement { - + + // Can't inherit from HttpConstraintElement as API does not allow it + private static final String LSTRING_FILE = "javax.servlet.LocalStrings"; + private static final ResourceBundle lStrings = + ResourceBundle.getBundle(LSTRING_FILE); + private String methodName; public HttpMethodConstraintElement(String methodName) { diff --git a/java/javax/servlet/ServletContext.java b/java/javax/servlet/ServletContext.java index 6afa6c1b1..71042bca7 100644 --- a/java/javax/servlet/ServletContext.java +++ b/java/javax/servlet/ServletContext.java @@ -353,10 +353,10 @@ public interface ServletContext { *

In lieu of this method, servlets can share information using the * ServletContext class and can perform shared business logic * by invoking methods on common non-servlet classes. - * + * + * @deprecated */ - - @Deprecated + @SuppressWarnings("dep-ann") // Spec API does not use dep-ann public Servlet getServlet(String name) throws ServletException; @@ -374,10 +374,10 @@ public interface ServletContext { * remains only to preserve binary compatibility. This method * will be permanently removed in a future version of the Java * Servlet API. - * + * + * @deprecated */ - - @Deprecated + @SuppressWarnings("dep-ann") // Spec API does not use dep-ann public Enumeration getServlets(); @@ -394,10 +394,10 @@ public interface ServletContext { * this method always returns an empty Enumeration and * remains only to preserve binary compatibility. This method will * be permanently removed in a future version of the Java Servlet API. - * + * + * @deprecated */ - - @Deprecated + @SuppressWarnings("dep-ann") // Spec API does not use dep-ann public Enumeration getServletNames(); @@ -430,10 +430,10 @@ public interface ServletContext { *

This method was originally defined to write an * exception's stack trace and an explanatory error message * to the servlet log file. - * + * + * @deprecated */ - - @Deprecated + @SuppressWarnings("dep-ann") // Spec API does not use dep-ann public void log(Exception exception, String msg); diff --git a/java/javax/servlet/ServletRequest.java b/java/javax/servlet/ServletRequest.java index 01c04ebec..eca0106b6 100644 --- a/java/javax/servlet/ServletRequest.java +++ b/java/javax/servlet/ServletRequest.java @@ -540,13 +540,10 @@ public interface ServletRequest { /** - * * @deprecated As of Version 2.1 of the Java Servlet API, * use {@link ServletContext#getRealPath} instead. - * */ - - @Deprecated + @SuppressWarnings("dep-ann") // Spec API does not use dep-ann public String getRealPath(String path); diff --git a/java/javax/servlet/ServletRequestWrapper.java b/java/javax/servlet/ServletRequestWrapper.java index 3c7e21f35..037195203 100644 --- a/java/javax/servlet/ServletRequestWrapper.java +++ b/java/javax/servlet/ServletRequestWrapper.java @@ -351,8 +351,7 @@ public class ServletRequestWrapper implements ServletRequest { * on the wrapped request object. * @deprecated As of Version 3.0 of the Java Servlet API */ - - @Deprecated + @SuppressWarnings("dep-ann") // Spec API does not use dep-ann public String getRealPath(String path) { return this.request.getRealPath(path); } @@ -493,7 +492,8 @@ public class ServletRequestWrapper implements ServletRequest { * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public boolean isWrapperFor(Class wrappedType) { + @SuppressWarnings("unchecked") // Spec API does not use generics + public boolean isWrapperFor(Class wrappedType) { if (wrappedType.isAssignableFrom(request.getClass())) { return true; } diff --git a/java/javax/servlet/ServletResponseWrapper.java b/java/javax/servlet/ServletResponseWrapper.java index f1442109d..47230e76d 100644 --- a/java/javax/servlet/ServletResponseWrapper.java +++ b/java/javax/servlet/ServletResponseWrapper.java @@ -231,7 +231,8 @@ public class ServletResponseWrapper implements ServletResponse { * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public boolean isWrapperFor(Class wrappedType) { + @SuppressWarnings("unchecked") // Spec API does not use generics + public boolean isWrapperFor(Class wrappedType) { if (wrappedType.isAssignableFrom(response.getClass())) { return true; } diff --git a/java/javax/servlet/SingleThreadModel.java b/java/javax/servlet/SingleThreadModel.java index 06051f0af..3cec4c2e0 100644 --- a/java/javax/servlet/SingleThreadModel.java +++ b/java/javax/servlet/SingleThreadModel.java @@ -44,8 +44,7 @@ package javax.servlet; * @deprecated As of Java Servlet API 2.4, with no direct * replacement. */ - -@Deprecated +@SuppressWarnings("dep-ann") // Spec API does not use dep-ann public interface SingleThreadModel { // No methods } diff --git a/java/javax/servlet/UnavailableException.java b/java/javax/servlet/UnavailableException.java index eb0d3f009..f3353effa 100644 --- a/java/javax/servlet/UnavailableException.java +++ b/java/javax/servlet/UnavailableException.java @@ -56,19 +56,16 @@ extends ServletException { private int seconds; // unavailability estimate /** - * - * @deprecated As of Java Servlet API 2.2, use {@link - * #UnavailableException(String)} instead. - * * @param servlet the Servlet instance that is * unavailable * * @param msg a String specifying the * descriptive message - * + * + * @deprecated As of Java Servlet API 2.2, use {@link + * #UnavailableException(String)} instead. */ - - @Deprecated + @SuppressWarnings("dep-ann") // Spec API does not use dep-ann public UnavailableException(Servlet servlet, String msg) { super(msg); this.servlet = servlet; @@ -76,8 +73,6 @@ extends ServletException { } /** - * @deprecated As of Java Servlet API 2.2, use {@link - * #UnavailableException(String, int)} instead. * * @param seconds an integer specifying the number of seconds * the servlet expects to be unavailable; if @@ -89,10 +84,11 @@ extends ServletException { * @param msg a String specifying the descriptive * message, which can be written to a log file or * displayed for the user. - * + * + * @deprecated As of Java Servlet API 2.2, use {@link + * #UnavailableException(String, int)} instead. */ - - @Deprecated + @SuppressWarnings("dep-ann") // Spec API does not use dep-ann public UnavailableException(int seconds, Servlet servlet, String msg) { super(msg); this.servlet = servlet; @@ -172,16 +168,14 @@ extends ServletException { } /** - * @deprecated As of Java Servlet API 2.2, with no replacement. - * * Returns the servlet that is reporting its unavailability. * * @return the Servlet object that is * throwing the UnavailableException * + * @deprecated As of Java Servlet API 2.2, with no replacement. */ - - @Deprecated + @SuppressWarnings("dep-ann") // Spec API does not use dep-ann public Servlet getServlet() { return servlet; } diff --git a/java/javax/servlet/annotation/HandlesTypes.java b/java/javax/servlet/annotation/HandlesTypes.java index d32c71e75..f0fc1df37 100644 --- a/java/javax/servlet/annotation/HandlesTypes.java +++ b/java/javax/servlet/annotation/HandlesTypes.java @@ -16,7 +16,6 @@ */ package javax.servlet.annotation; -import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -28,7 +27,7 @@ import java.lang.annotation.Target; */ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) -@Documented +@SuppressWarnings("unchecked") // Spec API does not use generics public @interface HandlesTypes { - Class[] value(); + Class[] value(); } diff --git a/java/javax/servlet/annotation/MultipartConfig.java b/java/javax/servlet/annotation/MultipartConfig.java index fe2ee1736..dbd19f571 100644 --- a/java/javax/servlet/annotation/MultipartConfig.java +++ b/java/javax/servlet/annotation/MultipartConfig.java @@ -16,7 +16,6 @@ */ package javax.servlet.annotation; -import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -28,7 +27,6 @@ import java.lang.annotation.Target; */ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) -@Documented public @interface MultipartConfig { String location() default ""; long maxFileSize() default -1L; -- 2.11.0