src/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java

Print this page
rev 10195 : 8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
Reviewed-by: chegar, psandoz
Contributed-by: Otavio Santana <otaviojava@java.net>


2485      * method is intended for {@link Attribute} sub classes, and is normally not
2486      * needed by class generators or adapters.</i>
2487      *
2488      * @param item
2489      *            the index of a constant pool item.
2490      * @param buf
2491      *            buffer to be used to read the item. This buffer must be
2492      *            sufficiently large. It is not automatically resized.
2493      * @return the {@link Integer}, {@link Float}, {@link Long}, {@link Double},
2494      *         {@link String}, {@link Type} or {@link Handle} corresponding to
2495      *         the given constant pool item.
2496      */
2497     public Object readConst(final int item, final char[] buf) {
2498         int index = items[item];
2499         switch (b[index - 1]) {
2500         case ClassWriter.INT:
2501             return new Integer(readInt(index));
2502         case ClassWriter.FLOAT:
2503             return new Float(Float.intBitsToFloat(readInt(index)));
2504         case ClassWriter.LONG:
2505             return new Long(readLong(index));
2506         case ClassWriter.DOUBLE:
2507             return new Double(Double.longBitsToDouble(readLong(index)));
2508         case ClassWriter.CLASS:
2509             return Type.getObjectType(readUTF8(index, buf));
2510         case ClassWriter.STR:
2511             return readUTF8(index, buf);
2512         case ClassWriter.MTYPE:
2513             return Type.getMethodType(readUTF8(index, buf));
2514         default: // case ClassWriter.HANDLE_BASE + [1..9]:
2515             int tag = readByte(index);
2516             int[] items = this.items;
2517             int cpIndex = items[readUnsignedShort(index + 1)];
2518             String owner = readClass(cpIndex, buf);
2519             cpIndex = items[readUnsignedShort(cpIndex + 2)];
2520             String name = readUTF8(cpIndex, buf);
2521             String desc = readUTF8(cpIndex + 2, buf);
2522             return new Handle(tag, owner, name, desc);
2523         }
2524     }
2525 }


2485      * method is intended for {@link Attribute} sub classes, and is normally not
2486      * needed by class generators or adapters.</i>
2487      *
2488      * @param item
2489      *            the index of a constant pool item.
2490      * @param buf
2491      *            buffer to be used to read the item. This buffer must be
2492      *            sufficiently large. It is not automatically resized.
2493      * @return the {@link Integer}, {@link Float}, {@link Long}, {@link Double},
2494      *         {@link String}, {@link Type} or {@link Handle} corresponding to
2495      *         the given constant pool item.
2496      */
2497     public Object readConst(final int item, final char[] buf) {
2498         int index = items[item];
2499         switch (b[index - 1]) {
2500         case ClassWriter.INT:
2501             return new Integer(readInt(index));
2502         case ClassWriter.FLOAT:
2503             return new Float(Float.intBitsToFloat(readInt(index)));
2504         case ClassWriter.LONG:
2505             return Long.valueOf(readLong(index));
2506         case ClassWriter.DOUBLE:
2507             return new Double(Double.longBitsToDouble(readLong(index)));
2508         case ClassWriter.CLASS:
2509             return Type.getObjectType(readUTF8(index, buf));
2510         case ClassWriter.STR:
2511             return readUTF8(index, buf);
2512         case ClassWriter.MTYPE:
2513             return Type.getMethodType(readUTF8(index, buf));
2514         default: // case ClassWriter.HANDLE_BASE + [1..9]:
2515             int tag = readByte(index);
2516             int[] items = this.items;
2517             int cpIndex = items[readUnsignedShort(index + 1)];
2518             String owner = readClass(cpIndex, buf);
2519             cpIndex = items[readUnsignedShort(cpIndex + 2)];
2520             String name = readUTF8(cpIndex, buf);
2521             String desc = readUTF8(cpIndex + 2, buf);
2522             return new Handle(tag, owner, name, desc);
2523         }
2524     }
2525 }