< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/Type.java

Print this page

        

*** 57,66 **** --- 57,67 ---- * THE POSSIBILITY OF SUCH DAMAGE. */ package jdk.internal.org.objectweb.asm; import java.lang.reflect.Constructor; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * A Java field or method type. This class can be used to make it easier to manipulate type and * method descriptors.
*** 332,342 **** // Parse the argument types, one at a each loop iteration. while (methodDescriptor.charAt(currentOffset) != ')') { while (methodDescriptor.charAt(currentOffset) == '[') { currentOffset++; } ! if (methodDescriptor.charAt(currentOffset++) == 'L') { // Skip the argument descriptor content. currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1; } ++numArgumentTypes; } --- 333,344 ---- // Parse the argument types, one at a each loop iteration. while (methodDescriptor.charAt(currentOffset) != ')') { while (methodDescriptor.charAt(currentOffset) == '[') { currentOffset++; } ! char c = methodDescriptor.charAt(currentOffset++); ! if (c == 'L' || c == 'Q') { // Skip the argument descriptor content. currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1; } ++numArgumentTypes; }
*** 350,360 **** while (methodDescriptor.charAt(currentOffset) != ')') { final int currentArgumentTypeOffset = currentOffset; while (methodDescriptor.charAt(currentOffset) == '[') { currentOffset++; } ! if (methodDescriptor.charAt(currentOffset++) == 'L') { // Skip the argument descriptor content. currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1; } argumentTypes[currentArgumentTypeIndex++] = getTypeInternal(methodDescriptor, currentArgumentTypeOffset, currentOffset); --- 352,363 ---- while (methodDescriptor.charAt(currentOffset) != ')') { final int currentArgumentTypeOffset = currentOffset; while (methodDescriptor.charAt(currentOffset) == '[') { currentOffset++; } ! char c = methodDescriptor.charAt(currentOffset++); ! if (c == 'L' || c == 'Q') { // Skip the argument descriptor content. currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1; } argumentTypes[currentArgumentTypeIndex++] = getTypeInternal(methodDescriptor, currentArgumentTypeOffset, currentOffset);
*** 399,409 **** // Skip the argument types, one at a each loop iteration. while (methodDescriptor.charAt(currentOffset) != ')') { while (methodDescriptor.charAt(currentOffset) == '[') { currentOffset++; } ! if (methodDescriptor.charAt(currentOffset++) == 'L') { // Skip the argument descriptor content. currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1; } } return getTypeInternal(methodDescriptor, currentOffset + 1, methodDescriptor.length()); --- 402,413 ---- // Skip the argument types, one at a each loop iteration. while (methodDescriptor.charAt(currentOffset) != ')') { while (methodDescriptor.charAt(currentOffset) == '[') { currentOffset++; } ! char c = methodDescriptor.charAt(currentOffset++); ! if (c == 'L' || c == 'Q') { // Skip the argument descriptor content. currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1; } } return getTypeInternal(methodDescriptor, currentOffset + 1, methodDescriptor.length());
*** 451,460 **** --- 455,465 ---- case 'D': return DOUBLE_TYPE; case '[': return new Type(ARRAY, descriptorBuffer, descriptorBegin, descriptorEnd); case 'L': + case 'Q': return new Type(OBJECT, descriptorBuffer, descriptorBegin + 1, descriptorEnd - 1); case '(': return new Type(METHOD, descriptorBuffer, descriptorBegin, descriptorEnd); default: throw new IllegalArgumentException();
*** 660,680 **** } else { throw new AssertionError(); } stringBuilder.append(descriptor); } else { - stringBuilder.append('L'); String name = currentClass.getName(); int nameLength = name.length(); for (int i = 0; i < nameLength; ++i) { char car = name.charAt(i); stringBuilder.append(car == '.' ? '/' : car); } stringBuilder.append(';'); } } // ----------------------------------------------------------------------------------------------- // Methods to get the sort, dimension, size, and opcodes corresponding to a Type or descriptor. // ----------------------------------------------------------------------------------------------- /** --- 665,718 ---- } else { throw new AssertionError(); } stringBuilder.append(descriptor); } else { String name = currentClass.getName(); + if (Helper.isIndirectType(currentClass)) { + stringBuilder.append('L'); + } else { + stringBuilder.append('Q'); + + } int nameLength = name.length(); for (int i = 0; i < nameLength; ++i) { char car = name.charAt(i); stringBuilder.append(car == '.' ? '/' : car); } stringBuilder.append(';'); } } + // Workarounds nasgen build that depends on ASM but compiled with + // the bootstrap JDK. Can't reference Class::isIndirectType + static class Helper { + static final Method isIndirectTypeMethod = isIndirectTypeMethod(); + static Method isIndirectTypeMethod() { + try { + return Class.class.getMethod("isIndirectType"); + } catch (NoSuchMethodException e) { + return null; + } + } + + static boolean isIndirectType(Class<?> clazz) { + int mods = clazz.getModifiers(); + if ((mods & 0x00000100) != 0) { // inline class + assert isIndirectTypeMethod != null; + try { + return (boolean) isIndirectTypeMethod.invoke(clazz); + } catch (InvocationTargetException e) { + throw new InternalError(e.getCause()); + } catch (IllegalAccessException e) { + throw new InternalError(e); + } + } + return true; + } + } + // ----------------------------------------------------------------------------------------------- // Methods to get the sort, dimension, size, and opcodes corresponding to a Type or descriptor. // ----------------------------------------------------------------------------------------------- /**
*** 764,774 **** argumentsSize += 2; } else { while (methodDescriptor.charAt(currentOffset) == '[') { currentOffset++; } ! if (methodDescriptor.charAt(currentOffset++) == 'L') { // Skip the argument descriptor content. currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1; } argumentsSize += 1; } --- 802,813 ---- argumentsSize += 2; } else { while (methodDescriptor.charAt(currentOffset) == '[') { currentOffset++; } ! char c = methodDescriptor.charAt(currentOffset++); ! if (c == 'L' || c == 'Q') { // Skip the argument descriptor content. currentOffset = methodDescriptor.indexOf(';', currentOffset) + 1; } argumentsSize += 1; }
< prev index next >