src/share/classes/sun/misc/ProxyGenerator.java

Print this page
rev 10203 : 8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes
Reviewed-by: chegar, prappo
Contributed-by: Otavio Santana <otaviojava@java.net>


1868          * Get or assign the index for an entry of a type that contains
1869          * a direct value.  The type of the given object determines the
1870          * type of the desired entry as follows:
1871          *
1872          *      java.lang.String        CONSTANT_Utf8
1873          *      java.lang.Integer       CONSTANT_Integer
1874          *      java.lang.Float         CONSTANT_Float
1875          *      java.lang.Long          CONSTANT_Long
1876          *      java.lang.Double        CONSTANT_DOUBLE
1877          */
1878         private short getValue(Object key) {
1879             Short index = map.get(key);
1880             if (index != null) {
1881                 return index.shortValue();
1882             } else {
1883                 if (readOnly) {
1884                     throw new InternalError(
1885                         "late constant pool addition: " + key);
1886                 }
1887                 short i = addEntry(new ValueEntry(key));
1888                 map.put(key, new Short(i));
1889                 return i;
1890             }
1891         }
1892 
1893         /**
1894          * Get or assign the index for an entry of a type that contains
1895          * references to other constant pool entries.
1896          */
1897         private short getIndirect(IndirectEntry e) {
1898             Short index = map.get(e);
1899             if (index != null) {
1900                 return index.shortValue();
1901             } else {
1902                 if (readOnly) {
1903                     throw new InternalError("late constant pool addition");
1904                 }
1905                 short i = addEntry(e);
1906                 map.put(e, new Short(i));
1907                 return i;
1908             }
1909         }
1910 
1911         /**
1912          * Entry is the abstact superclass of all constant pool entry types
1913          * that can be stored in the "pool" list; its purpose is to define a
1914          * common method for writing constant pool entries to a class file.
1915          */
1916         private static abstract class Entry {
1917             public abstract void write(DataOutputStream out)
1918                 throws IOException;
1919         }
1920 
1921         /**
1922          * ValueEntry represents a constant pool entry of a type that
1923          * contains a direct value (see the comments for the "getValue"
1924          * method for a list of such types).
1925          *
1926          * ValueEntry objects are not used as keys for their entries in the




1868          * Get or assign the index for an entry of a type that contains
1869          * a direct value.  The type of the given object determines the
1870          * type of the desired entry as follows:
1871          *
1872          *      java.lang.String        CONSTANT_Utf8
1873          *      java.lang.Integer       CONSTANT_Integer
1874          *      java.lang.Float         CONSTANT_Float
1875          *      java.lang.Long          CONSTANT_Long
1876          *      java.lang.Double        CONSTANT_DOUBLE
1877          */
1878         private short getValue(Object key) {
1879             Short index = map.get(key);
1880             if (index != null) {
1881                 return index.shortValue();
1882             } else {
1883                 if (readOnly) {
1884                     throw new InternalError(
1885                         "late constant pool addition: " + key);
1886                 }
1887                 short i = addEntry(new ValueEntry(key));
1888                 map.put(key, i);
1889                 return i;
1890             }
1891         }
1892 
1893         /**
1894          * Get or assign the index for an entry of a type that contains
1895          * references to other constant pool entries.
1896          */
1897         private short getIndirect(IndirectEntry e) {
1898             Short index = map.get(e);
1899             if (index != null) {
1900                 return index.shortValue();
1901             } else {
1902                 if (readOnly) {
1903                     throw new InternalError("late constant pool addition");
1904                 }
1905                 short i = addEntry(e);
1906                 map.put(e, i);
1907                 return i;
1908             }
1909         }
1910 
1911         /**
1912          * Entry is the abstact superclass of all constant pool entry types
1913          * that can be stored in the "pool" list; its purpose is to define a
1914          * common method for writing constant pool entries to a class file.
1915          */
1916         private static abstract class Entry {
1917             public abstract void write(DataOutputStream out)
1918                 throws IOException;
1919         }
1920 
1921         /**
1922          * ValueEntry represents a constant pool entry of a type that
1923          * contains a direct value (see the comments for the "getValue"
1924          * method for a list of such types).
1925          *
1926          * ValueEntry objects are not used as keys for their entries in the