Mercurial > hg > truffle
comparison src/share/vm/classfile/verifier.cpp @ 1602:136b78722a08
6939203: JSR 292 needs method handle constants
Summary: Add new CP types CONSTANT_MethodHandle, CONSTANT_MethodType; extend 'ldc' bytecode.
Reviewed-by: twisti, never
author | jrose |
---|---|
date | Wed, 09 Jun 2010 18:50:45 -0700 |
parents | e9ff18c4ace7 |
children | 083fde3b838e a5c9d63a187d |
comparison
equal
deleted
inserted
replaced
1585:49fac4acd688 | 1602:136b78722a08 |
---|---|
1596 constantTag tag = cp->tag_at(index); | 1596 constantTag tag = cp->tag_at(index); |
1597 unsigned int types; | 1597 unsigned int types; |
1598 if (opcode == Bytecodes::_ldc || opcode == Bytecodes::_ldc_w) { | 1598 if (opcode == Bytecodes::_ldc || opcode == Bytecodes::_ldc_w) { |
1599 if (!tag.is_unresolved_string() && !tag.is_unresolved_klass()) { | 1599 if (!tag.is_unresolved_string() && !tag.is_unresolved_klass()) { |
1600 types = (1 << JVM_CONSTANT_Integer) | (1 << JVM_CONSTANT_Float) | 1600 types = (1 << JVM_CONSTANT_Integer) | (1 << JVM_CONSTANT_Float) |
1601 | (1 << JVM_CONSTANT_String) | (1 << JVM_CONSTANT_Class); | 1601 | (1 << JVM_CONSTANT_String) | (1 << JVM_CONSTANT_Class) |
1602 | (1 << JVM_CONSTANT_MethodHandle) | (1 << JVM_CONSTANT_MethodType); | |
1603 // Note: The class file parser already verified the legality of | |
1604 // MethodHandle and MethodType constants. | |
1602 verify_cp_type(index, cp, types, CHECK_VERIFY(this)); | 1605 verify_cp_type(index, cp, types, CHECK_VERIFY(this)); |
1603 } | 1606 } |
1604 } else { | 1607 } else { |
1605 assert(opcode == Bytecodes::_ldc2_w, "must be ldc2_w"); | 1608 assert(opcode == Bytecodes::_ldc2_w, "must be ldc2_w"); |
1606 types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long); | 1609 types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long); |
1630 VerificationType::double2_type(), CHECK_VERIFY(this)); | 1633 VerificationType::double2_type(), CHECK_VERIFY(this)); |
1631 } else if (tag.is_long()) { | 1634 } else if (tag.is_long()) { |
1632 current_frame->push_stack_2( | 1635 current_frame->push_stack_2( |
1633 VerificationType::long_type(), | 1636 VerificationType::long_type(), |
1634 VerificationType::long2_type(), CHECK_VERIFY(this)); | 1637 VerificationType::long2_type(), CHECK_VERIFY(this)); |
1638 } else if (tag.is_method_handle()) { | |
1639 current_frame->push_stack( | |
1640 VerificationType::reference_type( | |
1641 vmSymbols::java_dyn_MethodHandle()), CHECK_VERIFY(this)); | |
1642 } else if (tag.is_method_type()) { | |
1643 current_frame->push_stack( | |
1644 VerificationType::reference_type( | |
1645 vmSymbols::java_dyn_MethodType()), CHECK_VERIFY(this)); | |
1635 } else { | 1646 } else { |
1636 verify_error(bci, "Invalid index in ldc"); | 1647 verify_error(bci, "Invalid index in ldc"); |
1637 return; | 1648 return; |
1638 } | 1649 } |
1639 } | 1650 } |
1918 } | 1929 } |
1919 | 1930 |
1920 // Get referenced class type | 1931 // Get referenced class type |
1921 VerificationType ref_class_type; | 1932 VerificationType ref_class_type; |
1922 if (opcode == Bytecodes::_invokedynamic) { | 1933 if (opcode == Bytecodes::_invokedynamic) { |
1923 if (!EnableInvokeDynamic) { | 1934 if (!EnableInvokeDynamic || |
1935 _klass->major_version() < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { | |
1924 class_format_error( | 1936 class_format_error( |
1925 "invokedynamic instructions not enabled on this JVM", | 1937 (!EnableInvokeDynamic ? |
1938 "invokedynamic instructions not enabled in this JVM" : | |
1939 "invokedynamic instructions not supported by this class file version"), | |
1926 _klass->external_name()); | 1940 _klass->external_name()); |
1927 return; | 1941 return; |
1928 } | 1942 } |
1929 } else { | 1943 } else { |
1930 ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this)); | 1944 ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this)); |