6657909: javap has unchecked compilation warnings

Thu, 22 May 2008 16:06:00 -0700

author
jjg
date
Thu, 22 May 2008 16:06:00 -0700
changeset 37
b8c8259e0d2b
parent 36
58e352559a41
child 38
65a447c75d4b

6657909: javap has unchecked compilation warnings
Reviewed-by: mcimadamore

src/share/classes/sun/tools/javap/ClassData.java file | annotate | diff | comparison | revisions
src/share/classes/sun/tools/javap/FieldData.java file | annotate | diff | comparison | revisions
src/share/classes/sun/tools/javap/InnerClassData.java file | annotate | diff | comparison | revisions
src/share/classes/sun/tools/javap/JavapPrinter.java file | annotate | diff | comparison | revisions
src/share/classes/sun/tools/javap/Main.java file | annotate | diff | comparison | revisions
src/share/classes/sun/tools/javap/MethodData.java file | annotate | diff | comparison | revisions
src/share/classes/sun/tools/javap/Tables.java file | annotate | diff | comparison | revisions
src/share/classes/sun/tools/javap/TypeSignature.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/sun/tools/javap/ClassData.java	Thu May 22 15:51:41 2008 -0700
     1.2 +++ b/src/share/classes/sun/tools/javap/ClassData.java	Thu May 22 16:06:00 2008 -0700
     1.3 @@ -58,7 +58,7 @@
     1.4      private String superclassname;
     1.5      private int source_cpx=0;
     1.6      private byte tags[];
     1.7 -    private Hashtable indexHashAscii = new Hashtable();
     1.8 +    private Hashtable<Object,Integer> indexHashAscii = new Hashtable<Object,Integer>();
     1.9      private String pkgPrefix="";
    1.10      private int pkgPrefixLen=0;
    1.11  
    1.12 @@ -167,19 +167,19 @@
    1.13              switch(tags[i] = tag) {
    1.14              case CONSTANT_UTF8:
    1.15                  String str=in.readUTF();
    1.16 -                indexHashAscii.put(cpool[i] = str, new Integer(i));
    1.17 +                indexHashAscii.put(cpool[i] = str, i);
    1.18                  break;
    1.19              case CONSTANT_INTEGER:
    1.20 -                cpool[i] = new Integer(in.readInt());
    1.21 +                cpool[i] = Integer.valueOf(in.readInt());
    1.22                  break;
    1.23              case CONSTANT_FLOAT:
    1.24 -                cpool[i] = new Float(in.readFloat());
    1.25 +                cpool[i] = Float.valueOf(in.readFloat());
    1.26                  break;
    1.27              case CONSTANT_LONG:
    1.28 -                cpool[i++] = new Long(in.readLong());
    1.29 +                cpool[i++] = Long.valueOf(in.readLong());
    1.30                  break;
    1.31              case CONSTANT_DOUBLE:
    1.32 -                cpool[i++] = new Double(in.readDouble());
    1.33 +                cpool[i++] = Double.valueOf(in.readDouble());
    1.34                  break;
    1.35              case CONSTANT_CLASS:
    1.36              case CONSTANT_STRING:
    1.37 @@ -365,7 +365,7 @@
    1.38       * Returns the access of this class or interface.
    1.39       */
    1.40      public String[] getAccess(){
    1.41 -        Vector v = new Vector();
    1.42 +        Vector<String> v = new Vector<String>();
    1.43          if ((access & ACC_PUBLIC)   !=0) v.addElement("public");
    1.44          if ((access & ACC_FINAL)    !=0) v.addElement("final");
    1.45          if ((access & ACC_ABSTRACT) !=0) v.addElement("abstract");
     2.1 --- a/src/share/classes/sun/tools/javap/FieldData.java	Thu May 22 15:51:41 2008 -0700
     2.2 +++ b/src/share/classes/sun/tools/javap/FieldData.java	Thu May 22 16:06:00 2008 -0700
     2.3 @@ -45,7 +45,7 @@
     2.4      int value_cpx=0;
     2.5      boolean isSynthetic=false;
     2.6      boolean isDeprecated=false;
     2.7 -    Vector attrs;
     2.8 +    Vector<AttrData> attrs;
     2.9  
    2.10      public FieldData(ClassData cls){
    2.11          this.cls=cls;
    2.12 @@ -60,7 +60,7 @@
    2.13          descriptor_index = in.readUnsignedShort();
    2.14          // Read the attributes
    2.15          int attributes_count = in.readUnsignedShort();
    2.16 -        attrs=new Vector(attributes_count);
    2.17 +        attrs=new Vector<AttrData>(attributes_count);
    2.18          for (int i = 0; i < attributes_count; i++) {
    2.19              int attr_name_index=in.readUnsignedShort();
    2.20              if (cls.getTag(attr_name_index)!=CONSTANT_UTF8) continue;
    2.21 @@ -99,7 +99,7 @@
    2.22       * Returns access of a field.
    2.23       */
    2.24      public String[] getAccess(){
    2.25 -        Vector v = new Vector();
    2.26 +        Vector<String> v = new Vector<String>();
    2.27          if ((access & ACC_PUBLIC)   !=0) v.addElement("public");
    2.28          if ((access & ACC_PRIVATE)   !=0) v.addElement("private");
    2.29          if ((access & ACC_PROTECTED)   !=0) v.addElement("protected");
     3.1 --- a/src/share/classes/sun/tools/javap/InnerClassData.java	Thu May 22 15:51:41 2008 -0700
     3.2 +++ b/src/share/classes/sun/tools/javap/InnerClassData.java	Thu May 22 16:06:00 2008 -0700
     3.3 @@ -63,7 +63,7 @@
     3.4       * Returns the access of this class or interface.
     3.5       */
     3.6      public String[] getAccess(){
     3.7 -        Vector v = new Vector();
     3.8 +        Vector<String> v = new Vector<String>();
     3.9          if ((access & ACC_PUBLIC)   !=0) v.addElement("public");
    3.10          if ((access & ACC_FINAL)    !=0) v.addElement("final");
    3.11          if ((access & ACC_ABSTRACT) !=0) v.addElement("abstract");
     4.1 --- a/src/share/classes/sun/tools/javap/JavapPrinter.java	Thu May 22 15:51:41 2008 -0700
     4.2 +++ b/src/share/classes/sun/tools/javap/JavapPrinter.java	Thu May 22 16:06:00 2008 -0700
     4.3 @@ -653,7 +653,7 @@
     4.4          case CONSTANT_METHOD:
     4.5          case CONSTANT_INTERFACEMETHOD:
     4.6          case CONSTANT_FIELD: {
     4.7 -            CPX2 x = (CPX2)(cls.getCpoolEntry(cpx));
     4.8 +            CPX2 x = cls.getCpoolEntry(cpx);
     4.9              if (x.cpx1 == cls.getthis_cpx()) {
    4.10                  // don't print class part for local references
    4.11                  cpx=x.cpx2;
    4.12 @@ -851,7 +851,7 @@
    4.13          case CONSTANT_INTERFACEMETHOD:
    4.14          case CONSTANT_FIELD: {
    4.15              // CPX2 x=(CPX2)(cpool[cpx]);
    4.16 -            CPX2 x = (CPX2)(cls.getCpoolEntry(cpx));
    4.17 +            CPX2 x = cls.getCpoolEntry(cpx);
    4.18              if (x.cpx1 == cls.getthis_cpx()) {
    4.19                  // don't print class part for local references
    4.20                  cpx=x.cpx2;
     5.1 --- a/src/share/classes/sun/tools/javap/Main.java	Thu May 22 15:51:41 2008 -0700
     5.2 +++ b/src/share/classes/sun/tools/javap/Main.java	Thu May 22 16:06:00 2008 -0700
     5.3 @@ -35,9 +35,9 @@
     5.4   *
     5.5   * @author  Sucheta Dambalkar (Adopted code from old javap)
     5.6   */
     5.7 -public class Main{
     5.8 +public class Main {
     5.9  
    5.10 -    private Vector classList = new Vector();
    5.11 +    private Vector<String> classList = new Vector<String>();
    5.12      private PrintWriter out;
    5.13      JavapEnvironment env = new JavapEnvironment();
    5.14      private static boolean errorOccurred = false;
    5.15 @@ -201,7 +201,7 @@
    5.16       */
    5.17      private void displayResults() {
    5.18          for (int i = 0; i < classList.size() ; i++ ) {
    5.19 -            String Name = (String)classList.elementAt(i);
    5.20 +            String Name = classList.elementAt(i);
    5.21              InputStream classin = env.getFileInputStream(Name);
    5.22  
    5.23              try {
     6.1 --- a/src/share/classes/sun/tools/javap/MethodData.java	Thu May 22 15:51:41 2008 -0700
     6.2 +++ b/src/share/classes/sun/tools/javap/MethodData.java	Thu May 22 16:06:00 2008 -0700
     6.3 @@ -43,14 +43,14 @@
     6.4      int descriptor_index;
     6.5      int attributes_count;
     6.6      byte[] code;
     6.7 -    Vector exception_table = new Vector(0);
     6.8 -    Vector lin_num_tb = new Vector(0);
     6.9 -    Vector loc_var_tb = new Vector(0);
    6.10 +    Vector<TrapData> exception_table = new Vector<TrapData>(0);
    6.11 +    Vector<LineNumData> lin_num_tb = new Vector<LineNumData>(0);
    6.12 +    Vector<LocVarData> loc_var_tb = new Vector<LocVarData>(0);
    6.13      StackMapTableData[] stackMapTable;
    6.14      StackMapData[] stackMap;
    6.15      int[] exc_index_table=null;
    6.16 -    Vector attrs=new Vector(0);
    6.17 -    Vector code_attrs=new Vector(0);
    6.18 +    Vector<AttrData> attrs=new Vector<AttrData>(0);
    6.19 +    Vector<AttrData> code_attrs=new Vector<AttrData>(0);
    6.20      int max_stack,  max_locals;
    6.21      boolean isSynthetic=false;
    6.22      boolean isDeprecated=false;
    6.23 @@ -165,7 +165,7 @@
    6.24       */
    6.25      void readExceptionTable (DataInputStream in) throws IOException {
    6.26          int exception_table_len=in.readUnsignedShort();
    6.27 -        exception_table=new Vector(exception_table_len);
    6.28 +        exception_table=new Vector<TrapData>(exception_table_len);
    6.29          for (int l = 0; l < exception_table_len; l++) {
    6.30              exception_table.addElement(new TrapData(in, l));
    6.31          }
    6.32 @@ -177,7 +177,7 @@
    6.33      void readLineNumTable (DataInputStream in) throws IOException {
    6.34          int attr_len = in.readInt(); // attr_length
    6.35          int lin_num_tb_len = in.readUnsignedShort();
    6.36 -        lin_num_tb=new Vector(lin_num_tb_len);
    6.37 +        lin_num_tb=new Vector<LineNumData>(lin_num_tb_len);
    6.38          for (int l = 0; l < lin_num_tb_len; l++) {
    6.39              lin_num_tb.addElement(new LineNumData(in));
    6.40          }
    6.41 @@ -189,7 +189,7 @@
    6.42      void readLocVarTable (DataInputStream in) throws IOException {
    6.43          int attr_len=in.readInt(); // attr_length
    6.44          int loc_var_tb_len = in.readUnsignedShort();
    6.45 -        loc_var_tb = new Vector(loc_var_tb_len);
    6.46 +        loc_var_tb = new Vector<LocVarData>(loc_var_tb_len);
    6.47          for (int l = 0; l < loc_var_tb_len; l++) {
    6.48              loc_var_tb.addElement(new LocVarData(in));
    6.49          }
    6.50 @@ -237,7 +237,7 @@
    6.51       */
    6.52      public String[] getAccess(){
    6.53  
    6.54 -        Vector v = new Vector();
    6.55 +        Vector<String> v = new Vector<String>();
    6.56          if ((access & ACC_PUBLIC)   !=0) v.addElement("public");
    6.57          if ((access & ACC_PRIVATE)   !=0) v.addElement("private");
    6.58          if ((access & ACC_PROTECTED)   !=0) v.addElement("protected");
     7.1 --- a/src/share/classes/sun/tools/javap/Tables.java	Thu May 22 15:51:41 2008 -0700
     7.2 +++ b/src/share/classes/sun/tools/javap/Tables.java	Thu May 22 16:06:00 2008 -0700
     7.3 @@ -26,8 +26,6 @@
     7.4  
     7.5  package sun.tools.javap;
     7.6  
     7.7 -import java.io.IOException;
     7.8 -import java.io.InputStream;
     7.9  import java.util.Hashtable;
    7.10  import java.util.Vector;
    7.11  
    7.12 @@ -36,14 +34,14 @@
    7.13      /**
    7.14       * Define mnemocodes table.
    7.15       */
    7.16 -  static  Hashtable mnemocodes = new Hashtable(301, 0.5f);
    7.17 +  static  Hashtable<String,Integer> mnemocodes = new Hashtable<String,Integer>(301, 0.5f);
    7.18    static  String opcExtNamesTab[]=new String[128];
    7.19    static  String opcPrivExtNamesTab[]=new String[128];
    7.20    static  void defineNonPriv(int opc, String mnem) {
    7.21 -        mnemocodes.put(opcExtNamesTab[opc]=mnem, new Integer(opc_nonpriv*256+opc));
    7.22 +        mnemocodes.put(opcExtNamesTab[opc]=mnem, opc_nonpriv*256+opc);
    7.23    }
    7.24    static  void definePriv(int opc, String mnem) {
    7.25 -        mnemocodes.put(opcPrivExtNamesTab[opc]="priv_"+mnem, new Integer(opc_priv*256+opc));
    7.26 +        mnemocodes.put(opcPrivExtNamesTab[opc]="priv_"+mnem, opc_priv*256+opc);
    7.27    }
    7.28    static  void defineExt(int opc, String mnem) {
    7.29          defineNonPriv(opc, mnem);
    7.30 @@ -51,28 +49,28 @@
    7.31    }
    7.32    static { int k;
    7.33          for (k=0; k<opc_wide; k++) {
    7.34 -                mnemocodes.put(opcNamesTab[k], new Integer(k));
    7.35 +                mnemocodes.put(opcNamesTab[k], k);
    7.36          }
    7.37          for (k=opc_wide+1; k<opcNamesTab.length; k++) {
    7.38 -                mnemocodes.put(opcNamesTab[k], new Integer(k));
    7.39 +                mnemocodes.put(opcNamesTab[k], k);
    7.40          }
    7.41 -        mnemocodes.put("invokenonvirtual", new Integer(opc_invokespecial));
    7.42 +        mnemocodes.put("invokenonvirtual", opc_invokespecial);
    7.43  
    7.44 -        mnemocodes.put("iload_w", new Integer(opc_iload_w));
    7.45 -        mnemocodes.put("lload_w", new Integer(opc_lload_w));
    7.46 -        mnemocodes.put("fload_w", new Integer(opc_fload_w));
    7.47 -        mnemocodes.put("dload_w", new Integer(opc_dload_w));
    7.48 -        mnemocodes.put("aload_w", new Integer(opc_aload_w));
    7.49 -        mnemocodes.put("istore_w", new Integer(opc_istore_w));
    7.50 -        mnemocodes.put("lstore_w", new Integer(opc_lstore_w));
    7.51 -        mnemocodes.put("fstore_w", new Integer(opc_fstore_w));
    7.52 -        mnemocodes.put("dstore_w", new Integer(opc_dstore_w));
    7.53 -        mnemocodes.put("astore_w", new Integer(opc_astore_w));
    7.54 -        mnemocodes.put("ret_w", new Integer(opc_ret_w));
    7.55 -        mnemocodes.put("iinc_w", new Integer(opc_iinc_w));
    7.56 +        mnemocodes.put("iload_w", opc_iload_w);
    7.57 +        mnemocodes.put("lload_w", opc_lload_w);
    7.58 +        mnemocodes.put("fload_w", opc_fload_w);
    7.59 +        mnemocodes.put("dload_w", opc_dload_w);
    7.60 +        mnemocodes.put("aload_w", opc_aload_w);
    7.61 +        mnemocodes.put("istore_w", opc_istore_w);
    7.62 +        mnemocodes.put("lstore_w", opc_lstore_w);
    7.63 +        mnemocodes.put("fstore_w", opc_fstore_w);
    7.64 +        mnemocodes.put("dstore_w", opc_dstore_w);
    7.65 +        mnemocodes.put("astore_w", opc_astore_w);
    7.66 +        mnemocodes.put("ret_w", opc_ret_w);
    7.67 +        mnemocodes.put("iinc_w", opc_iinc_w);
    7.68  
    7.69 -        mnemocodes.put("nonpriv", new Integer(opc_nonpriv));
    7.70 -        mnemocodes.put("priv", new Integer(opc_priv));
    7.71 +        mnemocodes.put("nonpriv", opc_nonpriv);
    7.72 +        mnemocodes.put("priv", opc_priv);
    7.73  
    7.74          defineExt(0, "load_ubyte");
    7.75          defineExt(1, "load_byte");
    7.76 @@ -183,7 +181,7 @@
    7.77    }
    7.78  
    7.79    public static int opcode(String mnem) {
    7.80 -        Integer Val=(Integer)(mnemocodes.get(mnem));
    7.81 +        Integer Val=mnemocodes.get(mnem);
    7.82          if (Val == null) return -1;
    7.83          return Val.intValue();
    7.84    }
    7.85 @@ -191,7 +189,7 @@
    7.86      /**
    7.87       * Initialized keyword and token Hashtables
    7.88       */
    7.89 -  static Vector keywordNames = new Vector(40);
    7.90 +  static Vector<String> keywordNames = new Vector<String>(40);
    7.91    private static void defineKeywordName(String id, int token) {
    7.92  
    7.93          if (token>=keywordNames.size()) {
    7.94 @@ -202,7 +200,7 @@
    7.95    public static String keywordName(int token) {
    7.96          if (token==-1) return "EOF";
    7.97          if (token>=keywordNames.size()) return null;
    7.98 -        return (String)keywordNames.elementAt(token);
    7.99 +        return keywordNames.elementAt(token);
   7.100    }
   7.101    static {
   7.102          defineKeywordName("ident", IDENT);
   7.103 @@ -217,15 +215,15 @@
   7.104          defineKeywordName("RBRACE", RBRACE);
   7.105    }
   7.106  
   7.107 -  static Hashtable keywords = new Hashtable(40);
   7.108 +  static Hashtable<String,Integer> keywords = new Hashtable<String,Integer>(40);
   7.109    public static int keyword(String idValue) {
   7.110 -        Integer Val=(Integer)(keywords.get(idValue));
   7.111 -        if (Val == null) return IDENT;
   7.112 -        return Val.intValue();
   7.113 +        Integer val=keywords.get(idValue);
   7.114 +        if (val == null) return IDENT;
   7.115 +        return val.intValue();
   7.116    }
   7.117  
   7.118    private static void defineKeyword(String id, int token) {
   7.119 -        keywords.put(id, new Integer(token));
   7.120 +        keywords.put(id, token);
   7.121          defineKeywordName(id, token);
   7.122    }
   7.123    static {
   7.124 @@ -275,8 +273,8 @@
   7.125     /**
   7.126       * Define tag table.
   7.127       */
   7.128 -  private static Vector tagNames = new Vector(10);
   7.129 -  private static Hashtable Tags = new Hashtable(10);
   7.130 +  private static Vector<String> tagNames = new Vector<String>(10);
   7.131 +  private static Hashtable<String,Integer> Tags = new Hashtable<String,Integer>(10);
   7.132    static {
   7.133          defineTag("Asciz",CONSTANT_UTF8);
   7.134          defineTag("int",CONSTANT_INTEGER);
   7.135 @@ -291,7 +289,7 @@
   7.136          defineTag("NameAndType",CONSTANT_NAMEANDTYPE);
   7.137    }
   7.138    private static void defineTag(String id, int val) {
   7.139 -        Tags.put(id, new Integer(val));
   7.140 +        Tags.put(id, val);
   7.141          if (val>=tagNames.size()) {
   7.142                  tagNames.setSize(val+1);
   7.143          }
   7.144 @@ -299,10 +297,10 @@
   7.145    }
   7.146    public static String tagName(int tag) {
   7.147          if (tag>=tagNames.size()) return null;
   7.148 -        return (String)tagNames.elementAt(tag);
   7.149 +        return tagNames.elementAt(tag);
   7.150    }
   7.151    public static int tagValue(String idValue) {
   7.152 -        Integer Val=(Integer)(Tags.get(idValue));
   7.153 +        Integer Val=Tags.get(idValue);
   7.154          if (Val == null) return 0;
   7.155          return Val.intValue();
   7.156    }
   7.157 @@ -310,8 +308,8 @@
   7.158     /**
   7.159       * Define type table. These types used in "newarray" instruction only.
   7.160       */
   7.161 -  private static Vector typeNames = new Vector(10);
   7.162 -  private static Hashtable Types = new Hashtable(10);
   7.163 +  private static Vector<String> typeNames = new Vector<String>(10);
   7.164 +  private static Hashtable<String,Integer> Types = new Hashtable<String,Integer>(10);
   7.165    static {
   7.166          defineType("int",T_INT);
   7.167          defineType("long",T_LONG);
   7.168 @@ -324,28 +322,28 @@
   7.169          defineType("short",T_SHORT);
   7.170    }
   7.171    private static void defineType(String id, int val) {
   7.172 -        Types.put(id, new Integer(val));
   7.173 +        Types.put(id, val);
   7.174          if (val>=typeNames.size()) {
   7.175                  typeNames.setSize(val+1);
   7.176          }
   7.177          typeNames.setElementAt(id, val);
   7.178    }
   7.179    public static int typeValue(String idValue) {
   7.180 -        Integer Val=(Integer)(Types.get(idValue));
   7.181 +        Integer Val=Types.get(idValue);
   7.182          if (Val == null) return -1;
   7.183          return Val.intValue();
   7.184    }
   7.185    public static String typeName(int type) {
   7.186          if (type>=typeNames.size()) return null;
   7.187 -        return (String)typeNames.elementAt(type);
   7.188 +        return typeNames.elementAt(type);
   7.189    }
   7.190  
   7.191     /**
   7.192       * Define MapTypes table.
   7.193       * These constants used in stackmap tables only.
   7.194       */
   7.195 -  private static Vector mapTypeNames = new Vector(10);
   7.196 -  private static Hashtable MapTypes = new Hashtable(10);
   7.197 +  private static Vector<String> mapTypeNames = new Vector<String>(10);
   7.198 +  private static Hashtable<String,Integer> MapTypes = new Hashtable<String,Integer>(10);
   7.199    static {
   7.200          defineMapType("bogus",             ITEM_Bogus);
   7.201          defineMapType("int",               ITEM_Integer);
   7.202 @@ -358,20 +356,20 @@
   7.203          defineMapType("uninitialized",     ITEM_NewObject);
   7.204    }
   7.205    private static void defineMapType(String id, int val) {
   7.206 -        MapTypes.put(id, new Integer(val));
   7.207 +        MapTypes.put(id, val);
   7.208          if (val>=mapTypeNames.size()) {
   7.209                  mapTypeNames.setSize(val+1);
   7.210          }
   7.211          mapTypeNames.setElementAt(id, val);
   7.212    }
   7.213    public static int mapTypeValue(String idValue) {
   7.214 -        Integer Val=(Integer)(MapTypes.get(idValue));
   7.215 +        Integer Val=MapTypes.get(idValue);
   7.216          if (Val == null) return -1;
   7.217          return Val.intValue();
   7.218    }
   7.219    public static String mapTypeName(int type) {
   7.220          if (type>=mapTypeNames.size()) return null;
   7.221 -        return (String)mapTypeNames.elementAt(type);
   7.222 +        return mapTypeNames.elementAt(type);
   7.223    }
   7.224  
   7.225  }
     8.1 --- a/src/share/classes/sun/tools/javap/TypeSignature.java	Thu May 22 15:51:41 2008 -0700
     8.2 +++ b/src/share/classes/sun/tools/javap/TypeSignature.java	Thu May 22 16:06:00 2008 -0700
     8.3 @@ -79,7 +79,7 @@
     8.4       * Returns java type signature of a parameter.
     8.5       */
     8.6      public String getParametersHelper(String parameterdes){
     8.7 -        Vector parameters = new Vector();
     8.8 +        Vector<String> parameters = new Vector<String>();
     8.9          int startindex = -1;
    8.10          int endindex = -1;
    8.11          String param = "";
    8.12 @@ -187,7 +187,7 @@
    8.13          int i;
    8.14  
    8.15          for(i = 0; i < parameters.size(); i++){
    8.16 -            parametersignature += (String)parameters.elementAt(i);
    8.17 +            parametersignature += parameters.elementAt(i);
    8.18              if(i != parameters.size()-1){
    8.19                  parametersignature += ", ";
    8.20              }

mercurial