Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

@SuppressWarnings(value="unchecked") & javac <identifier> expected messages

843810May 11 2008 — edited Jan 28 2009
Hi folks
I thought I'd add a suppress warning annotation to my code to stop getting this compiler message:
javac -Xlint LegacyAdapterRequestWrapper.java
LegacyAdapterRequestWrapper.java:16: warning: [unchecked] unchecked call to put(
K,V) as a member of the raw type java.util.Map
    tmpMap.put("DEPT", myDept);
              ^
1 warning
Here is my modified code:
package com.apress.projsp;

import java.util.Map;
import javax.servlet.http.*;

public class LegacyAdapterRequestWrapper extends HttpServletRequestWrapper {
  String myDept = null;

  public LegacyAdapterRequestWrapper(HttpServletRequest inReq, String deptString) {
    super(inReq);
    myDept = deptString;
  }

  public Map getParameterMap() {
    Map tmpMap = super.getParameterMap();
    @SuppressWarnings(value="unchecked")
    tmpMap.put("DEPT", myDept);
    return tmpMap;
  }

  public String[] getParameterValues(String paramName) {
    if (paramName.equalsIgnoreCase("DEPT")) {
      String[] tpAry = new String[1];
      tpAry[0] = myDept;
      return tpAry;
    } else {
      return super.getParameterValues(paramName);
    }
  }

  public String getParameter(String paramName) {
    if (paramName.equalsIgnoreCase("DEPT")) {
      return myDept;
    } else {
      return super.getParameter(paramName);
    }
  }
}
Can't quite understand what the compiler is telling me with these message. So was wondering if someone can clarify for me??

Compiler spews out following messages:
LegacyAdapterRequestWrapper.java:17: <identifier> expected
    tmpMap.put("DEPT", myDept);
              ^
LegacyAdapterRequestWrapper.java:17: not a statement
    tmpMap.put("DEPT", myDept);
               ^
LegacyAdapterRequestWrapper.java:17: ';' expected
    tmpMap.put("DEPT", myDept);
                     ^
LegacyAdapterRequestWrapper.java:17: not a statement
    tmpMap.put("DEPT", myDept);
                       ^
LegacyAdapterRequestWrapper.java:17: ';' expected
    tmpMap.put("DEPT", myDept);
                             ^
5 errors
BTW: java -version gives me this:
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 25 2009
Added on May 11 2008
6 comments
777 views