1577 * @param type2 index of an internal name in {@link #typeTable}.
1578 * @return the index of the common super type of the two given types.
1579 */
1580 int getMergedType(final int type1, final int type2) {
1581 key2.type = TYPE_MERGED;
1582 key2.longVal = type1 | (((long) type2) << 32);
1583 key2.hashCode = 0x7FFFFFFF & (TYPE_MERGED + type1 + type2);
1584 Item result = get(key2);
1585 if (result == null) {
1586 String t = typeTable[type1].strVal1;
1587 String u = typeTable[type2].strVal1;
1588 key2.intVal = addType(getCommonSuperClass(t, u));
1589 result = new Item((short) 0, key2);
1590 put(result);
1591 }
1592 return result.intVal;
1593 }
1594
1595 /**
1596 * Returns the common super type of the two given types. The default
1597 * implementation of this method <i>loads<i> the two given classes and uses
1598 * the java.lang.Class methods to find the common super class. It can be
1599 * overridden to compute this common super type in other ways, in particular
1600 * without actually loading any class, or to take into account the class
1601 * that is currently being generated by this ClassWriter, which can of
1602 * course not be loaded since it is under construction.
1603 *
1604 * @param type1 the internal name of a class.
1605 * @param type2 the internal name of another class.
1606 * @return the internal name of the common super class of the two given
1607 * classes.
1608 */
1609 protected String getCommonSuperClass(final String type1, final String type2)
1610 {
1611 Class<?> c, d;
1612 ClassLoader classLoader = getClass().getClassLoader();
1613 try {
1614 c = Class.forName(type1.replace('/', '.'), false, classLoader);
1615 d = Class.forName(type2.replace('/', '.'), false, classLoader);
1616 } catch (Exception e) {
1617 throw new RuntimeException(e.toString());
|
1577 * @param type2 index of an internal name in {@link #typeTable}.
1578 * @return the index of the common super type of the two given types.
1579 */
1580 int getMergedType(final int type1, final int type2) {
1581 key2.type = TYPE_MERGED;
1582 key2.longVal = type1 | (((long) type2) << 32);
1583 key2.hashCode = 0x7FFFFFFF & (TYPE_MERGED + type1 + type2);
1584 Item result = get(key2);
1585 if (result == null) {
1586 String t = typeTable[type1].strVal1;
1587 String u = typeTable[type2].strVal1;
1588 key2.intVal = addType(getCommonSuperClass(t, u));
1589 result = new Item((short) 0, key2);
1590 put(result);
1591 }
1592 return result.intVal;
1593 }
1594
1595 /**
1596 * Returns the common super type of the two given types. The default
1597 * implementation of this method <i>loads</i> the two given classes and uses
1598 * the java.lang.Class methods to find the common super class. It can be
1599 * overridden to compute this common super type in other ways, in particular
1600 * without actually loading any class, or to take into account the class
1601 * that is currently being generated by this ClassWriter, which can of
1602 * course not be loaded since it is under construction.
1603 *
1604 * @param type1 the internal name of a class.
1605 * @param type2 the internal name of another class.
1606 * @return the internal name of the common super class of the two given
1607 * classes.
1608 */
1609 protected String getCommonSuperClass(final String type1, final String type2)
1610 {
1611 Class<?> c, d;
1612 ClassLoader classLoader = getClass().getClassLoader();
1613 try {
1614 c = Class.forName(type1.replace('/', '.'), false, classLoader);
1615 d = Class.forName(type2.replace('/', '.'), false, classLoader);
1616 } catch (Exception e) {
1617 throw new RuntimeException(e.toString());
|