src/share/vm/classfile/classFileParser.cpp

changeset 2638
72dee110246f
parent 2616
dbad0519a1c4
child 2639
8033953d67ff
     1.1 --- a/src/share/vm/classfile/classFileParser.cpp	Fri Mar 11 21:19:15 2011 -0800
     1.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Fri Mar 11 22:33:47 2011 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -146,12 +146,14 @@
    1.11          break;
    1.12        case JVM_CONSTANT_MethodHandle :
    1.13        case JVM_CONSTANT_MethodType :
    1.14 -        if (!EnableMethodHandles ||
    1.15 -            _major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
    1.16 +        if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
    1.17            classfile_parse_error(
    1.18 -            (!EnableMethodHandles ?
    1.19 -             "This JVM does not support constant tag %u in class file %s" :
    1.20 -             "Class file version does not support constant tag %u in class file %s"),
    1.21 +            "Class file version does not support constant tag %u in class file %s",
    1.22 +            tag, CHECK);
    1.23 +        }
    1.24 +        if (!EnableMethodHandles) {
    1.25 +          classfile_parse_error(
    1.26 +            "This JVM does not support constant tag %u in class file %s",
    1.27              tag, CHECK);
    1.28          }
    1.29          if (tag == JVM_CONSTANT_MethodHandle) {
    1.30 @@ -170,12 +172,14 @@
    1.31        case JVM_CONSTANT_InvokeDynamicTrans :  // this tag appears only in old classfiles
    1.32        case JVM_CONSTANT_InvokeDynamic :
    1.33          {
    1.34 -          if (!EnableInvokeDynamic ||
    1.35 -              _major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
    1.36 +          if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
    1.37              classfile_parse_error(
    1.38 -              (!EnableInvokeDynamic ?
    1.39 -               "This JVM does not support constant tag %u in class file %s" :
    1.40 -               "Class file version does not support constant tag %u in class file %s"),
    1.41 +              "Class file version does not support constant tag %u in class file %s",
    1.42 +              tag, CHECK);
    1.43 +          }
    1.44 +          if (!EnableInvokeDynamic) {
    1.45 +            classfile_parse_error(
    1.46 +              "This JVM does not support constant tag %u in class file %s",
    1.47                tag, CHECK);
    1.48            }
    1.49            cfs->guarantee_more(5, CHECK);  // bsm_index, nt, tag/access_flags
    1.50 @@ -2823,6 +2827,7 @@
    1.51      }
    1.52    }
    1.53  
    1.54 +  if (AllowTransitionalJSR292 && word_sig_index == 0)  return;
    1.55    if (word_sig_index == 0)
    1.56      THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
    1.57                "missing I or J signature (for vmentry) in java.dyn.MethodHandle");
    1.58 @@ -2862,6 +2867,7 @@
    1.59      }
    1.60    }
    1.61  
    1.62 +  if (AllowTransitionalJSR292 && !found_vmentry)  return;
    1.63    if (!found_vmentry)
    1.64      THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
    1.65                "missing vmentry byte field in java.dyn.MethodHandle");
    1.66 @@ -3230,7 +3236,12 @@
    1.67      }
    1.68  
    1.69      // adjust the vmentry field declaration in java.dyn.MethodHandle
    1.70 -    if (EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
    1.71 +    if (EnableMethodHandles && class_name == vmSymbols::java_dyn_MethodHandle() && class_loader.is_null()) {
    1.72 +      java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
    1.73 +    }
    1.74 +    if (AllowTransitionalJSR292 &&
    1.75 +        EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
    1.76 +      // allow vmentry field in MethodHandleImpl also
    1.77        java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
    1.78      }
    1.79  

mercurial