Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/classfile/classFileParser.cpp
          +++ new/src/share/vm/classfile/classFileParser.cpp
↓ open down ↓ 144 lines elided ↑ open up ↑
 145  145            cp->string_index_at_put(index, string_index);
 146  146          }
 147  147          break;
 148  148        case JVM_CONSTANT_MethodHandle :
 149  149        case JVM_CONSTANT_MethodType :
 150  150          if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
 151  151            classfile_parse_error(
 152  152              "Class file version does not support constant tag %u in class file %s",
 153  153              tag, CHECK);
 154  154          }
 155      -        if (!EnableMethodHandles) {
      155 +        if (!EnableInvokeDynamic) {
 156  156            classfile_parse_error(
 157  157              "This JVM does not support constant tag %u in class file %s",
 158  158              tag, CHECK);
 159  159          }
 160  160          if (tag == JVM_CONSTANT_MethodHandle) {
 161  161            cfs->guarantee_more(4, CHECK);  // ref_kind, method_index, tag/access_flags
 162  162            u1 ref_kind = cfs->get_u1_fast();
 163  163            u2 method_index = cfs->get_u2_fast();
 164  164            cp->method_handle_index_at_put(index, ref_kind, method_index);
 165  165          } else if (tag == JVM_CONSTANT_MethodType) {
↓ open down ↓ 87 lines elided ↑ open up ↑
 253  253            assert(utf8_buffer != NULL, "null utf8 buffer");
 254  254            // Got utf8 string, guarantee utf8_length+1 bytes, set stream position forward.
 255  255            cfs->guarantee_more(utf8_length+1, CHECK);  // utf8 string, tag/access_flags
 256  256            cfs->skip_u1_fast(utf8_length);
 257  257  
 258  258            // Before storing the symbol, make sure it's legal
 259  259            if (_need_verify) {
 260  260              verify_legal_utf8((unsigned char*)utf8_buffer, utf8_length, CHECK);
 261  261            }
 262  262  
 263      -          if (AnonymousClasses && has_cp_patch_at(index)) {
      263 +          if (EnableInvokeDynamic && has_cp_patch_at(index)) {
 264  264              Handle patch = clear_cp_patch_at(index);
 265  265              guarantee_property(java_lang_String::is_instance(patch()),
 266  266                                 "Illegal utf8 patch at %d in class file %s",
 267  267                                 index, CHECK);
 268  268              char* str = java_lang_String::as_utf8_string(patch());
 269  269              // (could use java_lang_String::as_symbol instead, but might as well batch them)
 270  270              utf8_buffer = (u1*) str;
 271  271              utf8_length = (int) strlen(str);
 272  272            }
 273  273  
↓ open down ↓ 162 lines elided ↑ open up ↑
 436  436              string_index, CHECK_(nullHandle));
 437  437            Symbol* sym = cp->symbol_at(string_index);
 438  438            cp->unresolved_string_at_put(index, sym);
 439  439          }
 440  440          break;
 441  441        case JVM_CONSTANT_MethodHandle :
 442  442          {
 443  443            int ref_index = cp->method_handle_index_at(index);
 444  444            check_property(
 445  445              valid_cp_range(ref_index, length) &&
 446      -                EnableMethodHandles,
      446 +                EnableInvokeDynamic,
 447  447                "Invalid constant pool index %u in class file %s",
 448  448                ref_index, CHECK_(nullHandle));
 449  449            constantTag tag = cp->tag_at(ref_index);
 450  450            int ref_kind  = cp->method_handle_ref_kind_at(index);
 451  451            switch (ref_kind) {
 452  452            case JVM_REF_getField:
 453  453            case JVM_REF_getStatic:
 454  454            case JVM_REF_putField:
 455  455            case JVM_REF_putStatic:
 456  456              check_property(
↓ open down ↓ 23 lines elided ↑ open up ↑
 480  480            }
 481  481            // Keep the ref_index unchanged.  It will be indirected at link-time.
 482  482          }
 483  483          break;
 484  484        case JVM_CONSTANT_MethodType :
 485  485          {
 486  486            int ref_index = cp->method_type_index_at(index);
 487  487            check_property(
 488  488              valid_cp_range(ref_index, length) &&
 489  489                  cp->tag_at(ref_index).is_utf8() &&
 490      -                EnableMethodHandles,
      490 +                EnableInvokeDynamic,
 491  491                "Invalid constant pool index %u in class file %s",
 492  492                ref_index, CHECK_(nullHandle));
 493  493          }
 494  494          break;
 495  495        case JVM_CONSTANT_InvokeDynamicTrans :
 496  496        case JVM_CONSTANT_InvokeDynamic :
 497  497          {
 498  498            int name_and_type_ref_index = cp->invoke_dynamic_name_and_type_ref_index_at(index);
 499  499            check_property(valid_cp_range(name_and_type_ref_index, length) &&
 500  500                           cp->tag_at(name_and_type_ref_index).is_name_and_type(),
↓ open down ↓ 14 lines elided ↑ open up ↑
 515  515        default:
 516  516          fatal(err_msg("bad constant pool tag value %u",
 517  517                        cp->tag_at(index).value()));
 518  518          ShouldNotReachHere();
 519  519          break;
 520  520      } // end of switch
 521  521    } // end of for
 522  522  
 523  523    if (_cp_patches != NULL) {
 524  524      // need to treat this_class specially...
 525      -    assert(AnonymousClasses, "");
      525 +    assert(EnableInvokeDynamic, "");
 526  526      int this_class_index;
 527  527      {
 528  528        cfs->guarantee_more(8, CHECK_(nullHandle));  // flags, this_class, super_class, infs_len
 529  529        u1* mark = cfs->current();
 530  530        u2 flags         = cfs->get_u2_fast();
 531  531        this_class_index = cfs->get_u2_fast();
 532  532        cfs->set_current(mark);  // revert to mark
 533  533      }
 534  534  
 535  535      for (index = 1; index < length; index++) {          // Index 0 is unused
↓ open down ↓ 134 lines elided ↑ open up ↑
 670  670        }
 671  671      }  // end of switch
 672  672    }  // end of for
 673  673  
 674  674    cp_in_error.set_in_error(false);
 675  675    return cp;
 676  676  }
 677  677  
 678  678  
 679  679  void ClassFileParser::patch_constant_pool(constantPoolHandle cp, int index, Handle patch, TRAPS) {
 680      -  assert(AnonymousClasses, "");
      680 +  assert(EnableInvokeDynamic, "");
 681  681    BasicType patch_type = T_VOID;
 682  682    switch (cp->tag_at(index).value()) {
 683  683  
 684  684    case JVM_CONSTANT_UnresolvedClass :
 685  685      // Patching a class means pre-resolving it.
 686  686      // The name in the constant pool is ignored.
 687  687      if (java_lang_Class::is_instance(patch())) {
 688  688        guarantee_property(!java_lang_Class::is_primitive(patch()),
 689  689                           "Illegal class patch at %d in class file %s",
 690  690                           index, CHECK);
↓ open down ↓ 1405 lines elided ↑ open up ↑
2096 2096      } else {
2097 2097        _has_finalizer = true;
2098 2098      }
2099 2099    }
2100 2100    if (name == vmSymbols::object_initializer_name() &&
2101 2101        signature == vmSymbols::void_method_signature() &&
2102 2102        m->is_vanilla_constructor()) {
2103 2103      _has_vanilla_constructor = true;
2104 2104    }
2105 2105  
2106      -  if (EnableMethodHandles && (m->is_method_handle_invoke() ||
     2106 +  if (EnableInvokeDynamic && (m->is_method_handle_invoke() ||
2107 2107                                m->is_method_handle_adapter())) {
2108 2108      THROW_MSG_(vmSymbols::java_lang_VirtualMachineError(),
2109 2109                 "Method handle invokers must be defined internally to the VM", nullHandle);
2110 2110    }
2111 2111  
2112 2112    return m;
2113 2113  }
2114 2114  
2115 2115  
2116 2116  // The promoted_flags parameter is used to pass relevant access_flags
↓ open down ↓ 647 lines elided ↑ open up ↑
2764 2764  // There is no way for a classfile to express this, so we must help it.
2765 2765  void ClassFileParser::java_lang_invoke_MethodHandle_fix_pre(constantPoolHandle cp,
2766 2766                                                      typeArrayHandle fields,
2767 2767                                                      FieldAllocationCount *fac_ptr,
2768 2768                                                      TRAPS) {
2769 2769    // Add fake fields for java.lang.invoke.MethodHandle instances
2770 2770    //
2771 2771    // This is not particularly nice, but since there is no way to express
2772 2772    // a native wordSize field in Java, we must do it at this level.
2773 2773  
2774      -  if (!EnableMethodHandles)  return;
     2774 +  if (!EnableInvokeDynamic)  return;
2775 2775  
2776 2776    int word_sig_index = 0;
2777 2777    const int cp_size = cp->length();
2778 2778    for (int index = 1; index < cp_size; index++) {
2779 2779      if (cp->tag_at(index).is_utf8() &&
2780 2780          cp->symbol_at(index) == vmSymbols::machine_word_signature()) {
2781 2781        word_sig_index = index;
2782 2782        break;
2783 2783      }
2784 2784    }
↓ open down ↓ 399 lines elided ↑ open up ↑
3184 3184      // Add fake fields for java.lang.Class instances (also see below)
3185 3185      if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
3186 3186        java_lang_Class_fix_pre(&nonstatic_field_size, &fac);
3187 3187      }
3188 3188  
3189 3189      first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
3190 3190                                     nonstatic_field_size * heapOopSize;
3191 3191      next_nonstatic_field_offset = first_nonstatic_field_offset;
3192 3192  
3193 3193      // adjust the vmentry field declaration in java.lang.invoke.MethodHandle
3194      -    if (EnableMethodHandles && class_name == vmSymbols::java_lang_invoke_MethodHandle() && class_loader.is_null()) {
     3194 +    if (EnableInvokeDynamic && class_name == vmSymbols::java_lang_invoke_MethodHandle() && class_loader.is_null()) {
3195 3195        java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
3196 3196      }
3197 3197      if (AllowTransitionalJSR292 &&
3198      -        EnableMethodHandles && class_name == vmSymbols::java_dyn_MethodHandle() && class_loader.is_null()) {
     3198 +        EnableInvokeDynamic && class_name == vmSymbols::java_dyn_MethodHandle() && class_loader.is_null()) {
3199 3199        java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
3200 3200      }
3201 3201      if (AllowTransitionalJSR292 &&
3202      -        EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
     3202 +        EnableInvokeDynamic && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
3203 3203        // allow vmentry field in MethodHandleImpl also
3204 3204        java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
3205 3205      }
3206 3206  
3207 3207      // Add a fake "discovered" field if it is not present
3208 3208      // for compatibility with earlier jdk's.
3209 3209      if (class_name == vmSymbols::java_lang_ref_Reference()
3210 3210        && class_loader.is_null()) {
3211 3211        java_lang_ref_Reference_fix_pre(&fields, cp, &fac, CHECK_(nullHandle));
3212 3212      }
↓ open down ↓ 1403 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX