8157176: Improved classfile parsing

Thu, 30 Jun 2016 23:08:42 +0300

author
vkempik
date
Thu, 30 Jun 2016 23:08:42 +0300
changeset 8562
56e96eb12a4b
parent 8561
36d5b27fbbdc
child 8563
a3ede966ecfe

8157176: Improved classfile parsing
Reviewed-by: pliden

src/share/vm/runtime/sharedRuntime.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/signature.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/runtime/sharedRuntime.cpp	Wed Jun 29 12:13:08 2016 -0700
     1.2 +++ b/src/share/vm/runtime/sharedRuntime.cpp	Thu Jun 30 23:08:42 2016 +0300
     1.3 @@ -2830,8 +2830,6 @@
     1.4    char *s = sig->as_C_string();
     1.5    int len = (int)strlen(s);
     1.6    s++; len--;                   // Skip opening paren
     1.7 -  char *t = s+len;
     1.8 -  while( *(--t) != ')' ) ;      // Find close paren
     1.9  
    1.10    BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, 256 );
    1.11    VMRegPair *regs = NEW_RESOURCE_ARRAY( VMRegPair, 256 );
    1.12 @@ -2840,7 +2838,7 @@
    1.13      sig_bt[cnt++] = T_OBJECT; // Receiver is argument 0; not in signature
    1.14    }
    1.15  
    1.16 -  while( s < t ) {
    1.17 +  while( *s != ')' ) {          // Find closing right paren
    1.18      switch( *s++ ) {            // Switch on signature character
    1.19      case 'B': sig_bt[cnt++] = T_BYTE;    break;
    1.20      case 'C': sig_bt[cnt++] = T_CHAR;    break;
     2.1 --- a/src/share/vm/runtime/signature.cpp	Wed Jun 29 12:13:08 2016 -0700
     2.2 +++ b/src/share/vm/runtime/signature.cpp	Thu Jun 30 23:08:42 2016 +0300
     2.3 @@ -225,7 +225,49 @@
     2.4    _index = 0;
     2.5    expect('(');
     2.6    Symbol* sig = _signature;
     2.7 -  while (sig->byte_at(_index) != ')') _index++;
     2.8 +  // Need to skip over each type in the signature's argument list until a
     2.9 +  // closing ')' is found., then get the return type.  We cannot just scan
    2.10 +  // for the first ')' because ')' is a legal character in a type name.
    2.11 +  while (sig->byte_at(_index) != ')') {
    2.12 +    switch(sig->byte_at(_index)) {
    2.13 +      case 'B':
    2.14 +      case 'C':
    2.15 +      case 'D':
    2.16 +      case 'F':
    2.17 +      case 'I':
    2.18 +      case 'J':
    2.19 +      case 'S':
    2.20 +      case 'Z':
    2.21 +      case 'V':
    2.22 +        {
    2.23 +          _index++;
    2.24 +        }
    2.25 +        break;
    2.26 +      case 'L':
    2.27 +        {
    2.28 +          while (sig->byte_at(_index++) != ';') ;
    2.29 +        }
    2.30 +        break;
    2.31 +      case '[':
    2.32 +        {
    2.33 +          int begin = ++_index;
    2.34 +          skip_optional_size();
    2.35 +          while (sig->byte_at(_index) == '[') {
    2.36 +            _index++;
    2.37 +            skip_optional_size();
    2.38 +          }
    2.39 +          if (sig->byte_at(_index) == 'L') {
    2.40 +            while (sig->byte_at(_index++) != ';') ;
    2.41 +          } else {
    2.42 +            _index++;
    2.43 +          }
    2.44 +        }
    2.45 +        break;
    2.46 +      default:
    2.47 +        ShouldNotReachHere();
    2.48 +        break;
    2.49 +    }
    2.50 +  }
    2.51    expect(')');
    2.52    // Parse return type
    2.53    _parameter_index = -1;

mercurial