< prev index next >

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

Print this page
*** 58,11 ***
--- 58,13 ---
   */
  
  package jdk.internal.org.objectweb.asm;
  
  import java.lang.reflect.Constructor;
+ import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
+ import java.lang.reflect.Modifier;
  
  /**
   * A Java field or method type. This class can be used to make it easier to manipulate type and
   * method descriptors.
   *

*** 333,11 ***
          // 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.
                  int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
                  currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
              }
              ++numArgumentTypes;
--- 335,12 ---
          // 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.
                  int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
                  currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
              }
              ++numArgumentTypes;

*** 352,11 ***
          while (methodDescriptor.charAt(currentOffset) != ')') {
              final int currentArgumentTypeOffset = currentOffset;
              while (methodDescriptor.charAt(currentOffset) == '[') {
                  currentOffset++;
              }
!             if (methodDescriptor.charAt(currentOffset++) == 'L') {
                  // Skip the argument descriptor content.
                  int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
                  currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
              }
              argumentTypes[currentArgumentTypeIndex++] =
--- 355,12 ---
          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.
                  int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
                  currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
              }
              argumentTypes[currentArgumentTypeIndex++] =

*** 423,11 ***
          // 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.
                  int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
                  currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
              }
          }
--- 427,12 ---
          // 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.
                  int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
                  currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
              }
          }

*** 466,10 ***
--- 471,11 ---
              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("Invalid descriptor: " + descriptorBuffer);

*** 671,14 ***
              } else {
                  throw new AssertionError();
              }
              stringBuilder.append(descriptor);
          } else {
!             stringBuilder.append('L').append(getInternalName(currentClass)).append(';');
          }
      }
  
      // -----------------------------------------------------------------------------------------------
      // Methods to get the sort, dimension, size, and opcodes corresponding to a Type or descriptor.
      // -----------------------------------------------------------------------------------------------
  
      /**
--- 677,18 ---
              } else {
                  throw new AssertionError();
              }
              stringBuilder.append(descriptor);
          } else {
!             stringBuilder.append(isPrimitiveClass(currentClass) ? 'Q' : 'L').append(getInternalName(currentClass)).append(';');
          }
      }
  
+     static boolean isPrimitiveClass(Class<?> clazz) {
+         return (clazz.getModifiers() & Opcodes.ACC_PRIMITIVE) != 0;
+     }
+ 
      // -----------------------------------------------------------------------------------------------
      // Methods to get the sort, dimension, size, and opcodes corresponding to a Type or descriptor.
      // -----------------------------------------------------------------------------------------------
  
      /**

*** 768,11 ***
                  argumentsSize += 2;
              } else {
                  while (methodDescriptor.charAt(currentOffset) == '[') {
                      currentOffset++;
                  }
!                 if (methodDescriptor.charAt(currentOffset++) == 'L') {
                      // Skip the argument descriptor content.
                      int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
                      currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
                  }
                  argumentsSize += 1;
--- 778,12 ---
                  argumentsSize += 2;
              } else {
                  while (methodDescriptor.charAt(currentOffset) == '[') {
                      currentOffset++;
                  }
!                 char c = methodDescriptor.charAt(currentOffset++);
+                 if (c == 'L' || c == 'Q') {
                      // Skip the argument descriptor content.
                      int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset);
                      currentOffset = Math.max(currentOffset, semiColumnOffset + 1);
                  }
                  argumentsSize += 1;
< prev index next >