# HG changeset patch # User asaha # Date 1409940673 25200 # Node ID 0b53273ef822d74427df9c5e230d61ff8b2387dd # Parent ded432e6064be694b166011e3c2f4a044d223c3c# Parent cbd62ecbb9154031e281a3608956d3ad45014bb5 Merge diff -r ded432e6064b -r 0b53273ef822 .hgtags --- a/.hgtags Wed Aug 20 12:12:55 2014 -0700 +++ b/.hgtags Fri Sep 05 11:11:13 2014 -0700 @@ -633,6 +633,9 @@ 8175599864880938d68d0a515fa561043d7d5fd0 jdk7u55-b31 ba9270b8fb1f4852ff1d9dab15571eb9e0714495 jdk7u55-b32 0901a8cf66a0494b55bf104c9666d4e3c6ff93f0 jdk7u55-b33 +278d7e230b297a4632b94ddc07d591e74736e039 jdk7u55-b34 +db88943dba0b7672a09e22974934022fbe8ba8dd jdk7u55-b35 +b3e388601b0fc0922b311e2cc68b9417cedd16ef jdk7u55-b36 ae4adc1492d1c90a70bd2d139a939fc0c8329be9 jdk7u60-b00 af1fc2868a2b919727bfbb0858449bd991bbee4a jdk7u40-b60 cc83359f5e5eb46dd9176b0a272390b1a0a51fdc hs24.60-b01 @@ -663,6 +666,10 @@ 617a6338e0c4f7699eed5061d7e8f576c3ace029 jdk7u60-b18 4a9635c98a917cfcef506ca5d034c733a33c53f3 jdk7u65-b01 361493c7cdb5f75b28efc63389d6cebaaaa43a2c jdk7u60-b19 +13f561930b3e80a94e2baddc51dfc6c43c5ca601 jdk7u60-b30 +35b2dbe7f7c69ea0f2feb1e66fe8651511a5fb6d jdk7u60-b31 +f166d2e391993f1b12b4ad1685baf999c78e6372 jdk7u60-b32 +cc1fea28c886ef100632247a708eac0c83640914 jdk7u60-b33 eb797fab50d3b440b17b3e7c5d83f42bfa73655e jdk7u65-b02 bb00df28ecdbd0da89ab4ed81f6f2b732fa512da jdk7u65-b03 848481af9003067546c7f34c166bb8d745b95d5f jdk7u65-b04 @@ -683,6 +690,45 @@ d006213be74730453cf5c3ce31f1d1d505334419 jdk7u65-b18 1d8226b3e9896656451801393eb3ae394faeb638 jdk7u65-b19 c43b0b843f897a4d8cf0a3566b017b87230dd3b4 jdk7u65-b32 +d3c9265e12fa115052f18d1e3d379143b56bbf63 jdk7u65-b20 +39776d90970221dd260187acb4c37631e41a66a9 jdk7u67-b01 +1d8226b3e9896656451801393eb3ae394faeb638 jdk7u65-b40 +cf8b3a090e597e59177c5f67d44cdec12309777f jdk7u65-b31 +df855c3f4d31dd7db081d68e3054518380127893 jdk7u65-b33 +6b37a189944aaa09e81d97d394496464d16bee42 jdk7u66-b00 +121dc94194d9234e2b13c867d875e23e1bdd6abd jdk7u66-b01 +f28ea516eb0b9e99f1e342954ab4642456af4da1 jdk7u66-b09 +3dc6ae1972a45ba563518cc0e51f09885258f69d jdk7u66-b10 +8d2b3f7d5b3001d019832476d684679ca6be0c8d jdk7u66-b11 +5ee19b64ef208daaef91f063d800aa162427f8f6 jdk7u66-b12 +a1e6f9c4c1f47be1b0edef6bd92399f8f07b7d15 jdk7u66-b13 +b44baba406f2de6eeccc57dbfae653cf124b527b jdk7u66-b14 +d20b495c96d3f8899a64657aba0fc72799773cb3 jdk7u66-b15 +3bbfed065c601187449d319fd70bba6ae1ebb707 jdk7u66-b16 +4abb71ff14b2e6cf932e5c61900f480d5e1afedb jdk7u66-b17 +4ceb9c03fe8ee6b93d22854780ef8c737edd14b2 jdk7u71-b00 +f95d6d32e08006209f1798f82b60d7d05767a3e8 jdk7u71-b01 +1c760efe2d0795f4ce8260ec655b8870bfd77ca1 jdk7u71-b02 +0cb0b5abd0b5aa25fc8bd5920c8d61c5b85a10c6 jdk7u71-b03 +a491e5e52998c23502ebb1340955e3e726d44ad6 jdk7u71-b04 +c93efe6377ffd7484c50cba9a88a37bebf525114 jdk7u71-b05 +f95fa655cc119659686ba68c7242497fd209f9e1 jdk7u71-b06 +7f32b65fde34db41bf951ed81374240840ef88f4 jdk7u71-b07 +4e17bd4fb2304d068023d9d805e86d6b592d4230 jdk7u71-b08 +1ffc702334d960aa4015e5cc6f4fb9e971952b54 jdk7u71-b09 +9a17c184bcb99f13dc6ab714ad98976410429637 jdk7u71-b10 +d6cb97651f0bd8d61f4d22aa7550145bbe6fb051 jdk7u71-b11 +1bd3adac3aac3c29c81303812b35f484ff90cb2b jdk7u72-b01 +0caed46767e35c00eff69b22acf984d98eb66b3d jdk7u72-b02 +3a2934191de4bb8ca9d2faca93f3381e521e8cac jdk7u72-b03 +e4708cde2898df4c936595aacb57bc5b4e15869a jdk7u72-b04 +137e0859cd296cb8d9f9e327112ddc793ed59318 jdk7u72-b05 +4d9d227d70f33b70461230172386217317954312 jdk7u72-b06 +ece56f93f37b41b9c8875e54fbd8010277f6b460 jdk7u72-b07 +439c695a7aa03652ab92681120434b9ce8cdd2b7 jdk7u72-b08 +a27f16d45457a68a723acca621cb11bc173a0eb6 jdk7u72-b09 +e6508ab77271d1d3ce7b5f60d91a7334fdacb03a jdk7u72-b10 +c17a8487086433e14cd22373039a8b6b48e7cbb8 jdk7u72-b11 b92f390febd01615af4a736b4f830f6052aa1d09 hs24.80-b00 1448ebfef4f1aae0174eca983ad05507730ca6fd hs24.80-b01 b1d29549dca7e36a4d050af5a54f8f56963a5c7d hs24.80-b02 diff -r ded432e6064b -r 0b53273ef822 make/bsd/makefiles/mapfile-vers-debug --- a/make/bsd/makefiles/mapfile-vers-debug Wed Aug 20 12:12:55 2014 -0700 +++ b/make/bsd/makefiles/mapfile-vers-debug Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -82,6 +82,7 @@ _JVM_EnableCompiler _JVM_Exit _JVM_FillInStackTrace + _JVM_FindClassFromCaller _JVM_FindClassFromClass _JVM_FindClassFromClassLoader _JVM_FindClassFromBootLoader diff -r ded432e6064b -r 0b53273ef822 make/bsd/makefiles/mapfile-vers-product --- a/make/bsd/makefiles/mapfile-vers-product Wed Aug 20 12:12:55 2014 -0700 +++ b/make/bsd/makefiles/mapfile-vers-product Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -82,6 +82,7 @@ _JVM_EnableCompiler _JVM_Exit _JVM_FillInStackTrace + _JVM_FindClassFromCaller _JVM_FindClassFromClass _JVM_FindClassFromClassLoader _JVM_FindClassFromBootLoader diff -r ded432e6064b -r 0b53273ef822 make/hotspot_version diff -r ded432e6064b -r 0b53273ef822 make/linux/makefiles/mapfile-vers-debug --- a/make/linux/makefiles/mapfile-vers-debug Wed Aug 20 12:12:55 2014 -0700 +++ b/make/linux/makefiles/mapfile-vers-debug Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -84,6 +84,7 @@ JVM_EnableCompiler; JVM_Exit; JVM_FillInStackTrace; + JVM_FindClassFromCaller; JVM_FindClassFromClass; JVM_FindClassFromClassLoader; JVM_FindClassFromBootLoader; diff -r ded432e6064b -r 0b53273ef822 make/linux/makefiles/mapfile-vers-product --- a/make/linux/makefiles/mapfile-vers-product Wed Aug 20 12:12:55 2014 -0700 +++ b/make/linux/makefiles/mapfile-vers-product Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -84,6 +84,7 @@ JVM_EnableCompiler; JVM_Exit; JVM_FillInStackTrace; + JVM_FindClassFromCaller; JVM_FindClassFromClass; JVM_FindClassFromClassLoader; JVM_FindClassFromBootLoader; diff -r ded432e6064b -r 0b53273ef822 make/solaris/makefiles/mapfile-vers --- a/make/solaris/makefiles/mapfile-vers Wed Aug 20 12:12:55 2014 -0700 +++ b/make/solaris/makefiles/mapfile-vers Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -84,6 +84,7 @@ JVM_EnableCompiler; JVM_Exit; JVM_FillInStackTrace; + JVM_FindClassFromCaller; JVM_FindClassFromClass; JVM_FindClassFromClassLoader; JVM_FindClassFromBootLoader; diff -r ded432e6064b -r 0b53273ef822 src/os/bsd/vm/os_bsd.cpp diff -r ded432e6064b -r 0b53273ef822 src/os/linux/vm/os_linux.cpp diff -r ded432e6064b -r 0b53273ef822 src/share/vm/adlc/formssel.cpp --- a/src/share/vm/adlc/formssel.cpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/adlc/formssel.cpp Fri Sep 05 11:11:13 2014 -0700 @@ -536,12 +536,6 @@ if( data_type != Form::none ) rematerialize = true; - // Ugly: until a better fix is implemented, disable rematerialization for - // negD nodes because they are proved to be problematic. - if (is_ideal_negD()) { - return false; - } - // Constants if( _components.count() == 1 && _components[0]->is(Component::USE_DEF) ) rematerialize = true; diff -r ded432e6064b -r 0b53273ef822 src/share/vm/classfile/classFileParser.cpp --- a/src/share/vm/classfile/classFileParser.cpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/classfile/classFileParser.cpp Fri Sep 05 11:11:13 2014 -0700 @@ -2721,6 +2721,11 @@ "bootstrap_method_index %u has bad constant type in class file %s", bootstrap_method_index, CHECK); + + guarantee_property((operand_fill_index + 1 + argument_count) < operands->length(), + "Invalid BootstrapMethods num_bootstrap_methods or num_bootstrap_arguments value in class file %s", + CHECK); + operands->short_at_put(operand_fill_index++, bootstrap_method_index); operands->short_at_put(operand_fill_index++, argument_count); @@ -2738,7 +2743,6 @@ } assert(operand_fill_index == operands()->length(), "exact fill"); - assert(constantPoolOopDesc::operand_array_length(operands()) == attribute_array_length, "correct decode"); u1* current_end = cfs->current(); guarantee_property(current_end == current_start + attribute_byte_length, diff -r ded432e6064b -r 0b53273ef822 src/share/vm/classfile/verifier.cpp --- a/src/share/vm/classfile/verifier.cpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/classfile/verifier.cpp Fri Sep 05 11:11:13 2014 -0700 @@ -2222,6 +2222,181 @@ } } +// Look at the method's handlers. If the bci is in the handler's try block +// then check if the handler_pc is already on the stack. If not, push it. +void ClassVerifier::push_handlers(ExceptionTable* exhandlers, + GrowableArray* handler_stack, + u4 bci) { + int exlength = exhandlers->length(); + for(int x = 0; x < exlength; x++) { + if (bci >= exhandlers->start_pc(x) && bci < exhandlers->end_pc(x)) { + handler_stack->append_if_missing(exhandlers->handler_pc(x)); + } + } +} + +// Return TRUE if all code paths starting with start_bc_offset end in +// bytecode athrow or loop. +bool ClassVerifier::ends_in_athrow(u4 start_bc_offset) { + ResourceMark rm; + // Create bytecode stream. + RawBytecodeStream bcs(method()); + u4 code_length = method()->code_size(); + bcs.set_start(start_bc_offset); + u4 target; + // Create stack for storing bytecode start offsets for if* and *switch. + GrowableArray* bci_stack = new GrowableArray(30); + // Create stack for handlers for try blocks containing this handler. + GrowableArray* handler_stack = new GrowableArray(30); + // Create list of visited branch opcodes (goto* and if*). + GrowableArray* visited_branches = new GrowableArray(30); + ExceptionTable exhandlers(_method()); + + while (true) { + if (bcs.is_last_bytecode()) { + // if no more starting offsets to parse or if at the end of the + // method then return false. + if ((bci_stack->is_empty()) || ((u4)bcs.end_bci() == code_length)) + return false; + // Pop a bytecode starting offset and scan from there. + bcs.set_start(bci_stack->pop()); + } + Bytecodes::Code opcode = bcs.raw_next(); + u4 bci = bcs.bci(); + + // If the bytecode is in a TRY block, push its handlers so they + // will get parsed. + push_handlers(&exhandlers, handler_stack, bci); + + switch (opcode) { + case Bytecodes::_if_icmpeq: + case Bytecodes::_if_icmpne: + case Bytecodes::_if_icmplt: + case Bytecodes::_if_icmpge: + case Bytecodes::_if_icmpgt: + case Bytecodes::_if_icmple: + case Bytecodes::_ifeq: + case Bytecodes::_ifne: + case Bytecodes::_iflt: + case Bytecodes::_ifge: + case Bytecodes::_ifgt: + case Bytecodes::_ifle: + case Bytecodes::_if_acmpeq: + case Bytecodes::_if_acmpne: + case Bytecodes::_ifnull: + case Bytecodes::_ifnonnull: + target = bcs.dest(); + if (visited_branches->contains(bci)) { + if (bci_stack->is_empty()) return true; + // Pop a bytecode starting offset and scan from there. + bcs.set_start(bci_stack->pop()); + } else { + if (target > bci) { // forward branch + if (target >= code_length) return false; + // Push the branch target onto the stack. + bci_stack->push(target); + // then, scan bytecodes starting with next. + bcs.set_start(bcs.next_bci()); + } else { // backward branch + // Push bytecode offset following backward branch onto the stack. + bci_stack->push(bcs.next_bci()); + // Check bytecodes starting with branch target. + bcs.set_start(target); + } + // Record target so we don't branch here again. + visited_branches->append(bci); + } + break; + + case Bytecodes::_goto: + case Bytecodes::_goto_w: + target = (opcode == Bytecodes::_goto ? bcs.dest() : bcs.dest_w()); + if (visited_branches->contains(bci)) { + if (bci_stack->is_empty()) return true; + // Been here before, pop new starting offset from stack. + bcs.set_start(bci_stack->pop()); + } else { + if (target >= code_length) return false; + // Continue scanning from the target onward. + bcs.set_start(target); + // Record target so we don't branch here again. + visited_branches->append(bci); + } + break; + + // Check that all switch alternatives end in 'athrow' bytecodes. Since it + // is difficult to determine where each switch alternative ends, parse + // each switch alternative until either hit a 'return', 'athrow', or reach + // the end of the method's bytecodes. This is gross but should be okay + // because: + // 1. tableswitch and lookupswitch byte codes in handlers for ctor explicit + // constructor invocations should be rare. + // 2. if each switch alternative ends in an athrow then the parsing should be + // short. If there is no athrow then it is bogus code, anyway. + case Bytecodes::_lookupswitch: + case Bytecodes::_tableswitch: + { + address aligned_bcp = (address) round_to((intptr_t)(bcs.bcp() + 1), jintSize); + u4 default_offset = Bytes::get_Java_u4(aligned_bcp) + bci; + int keys, delta; + if (opcode == Bytecodes::_tableswitch) { + jint low = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize); + jint high = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize); + // This is invalid, but let the regular bytecode verifier + // report this because the user will get a better error message. + if (low > high) return true; + keys = high - low + 1; + delta = 1; + } else { + keys = (int)Bytes::get_Java_u4(aligned_bcp + jintSize); + delta = 2; + } + // Invalid, let the regular bytecode verifier deal with it. + if (keys < 0) return true; + + // Push the offset of the next bytecode onto the stack. + bci_stack->push(bcs.next_bci()); + + // Push the switch alternatives onto the stack. + for (int i = 0; i < keys; i++) { + u4 target = bci + (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize); + if (target > code_length) return false; + bci_stack->push(target); + } + + // Start bytecode parsing for the switch at the default alternative. + if (default_offset > code_length) return false; + bcs.set_start(default_offset); + break; + } + + case Bytecodes::_return: + return false; + + case Bytecodes::_athrow: + { + if (bci_stack->is_empty()) { + if (handler_stack->is_empty()) { + return true; + } else { + // Parse the catch handlers for try blocks containing athrow. + bcs.set_start(handler_stack->pop()); + } + } else { + // Pop a bytecode offset and starting scanning from there. + bcs.set_start(bci_stack->pop()); + } + } + break; + + default: + ; + } // end switch + } // end while loop + + return false; +} + void ClassVerifier::verify_invoke_init( RawBytecodeStream* bcs, u2 ref_class_index, VerificationType ref_class_type, StackMapFrame* current_frame, u4 code_length, bool *this_uninit, @@ -2241,18 +2416,26 @@ return; } - // Make sure that this call is not done from within a TRY block because - // that can result in returning an incomplete object. Simply checking - // (bci >= start_pc) also ensures that this call is not done after a TRY - // block. That is also illegal because this call must be the first Java - // statement in the constructor. + // Check if this call is done from inside of a TRY block. If so, make + // sure that all catch clause paths end in a throw. Otherwise, this + // can result in returning an incomplete object. ExceptionTable exhandlers(_method()); int exlength = exhandlers.length(); for(int i = 0; i < exlength; i++) { - if (bci >= exhandlers.start_pc(i)) { - verify_error(ErrorContext::bad_code(bci), - "Bad method call from after the start of a try block"); - return; + u2 start_pc = exhandlers.start_pc(i); + u2 end_pc = exhandlers.end_pc(i); + + if (bci >= start_pc && bci < end_pc) { + if (!ends_in_athrow(exhandlers.handler_pc(i))) { + verify_error(ErrorContext::bad_code(bci), + "Bad method call from after the start of a try block"); + return; + } else if (VerboseVerification) { + ResourceMark rm; + tty->print_cr( + "Survived call to ends_in_athrow(): %s", + current_class()->name()->as_C_string()); + } } } diff -r ded432e6064b -r 0b53273ef822 src/share/vm/classfile/verifier.hpp --- a/src/share/vm/classfile/verifier.hpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/classfile/verifier.hpp Fri Sep 05 11:11:13 2014 -0700 @@ -30,6 +30,7 @@ #include "oops/klass.hpp" #include "oops/methodOop.hpp" #include "runtime/handles.hpp" +#include "utilities/growableArray.hpp" #include "utilities/exceptions.hpp" // The verifier class @@ -301,6 +302,16 @@ StackMapFrame* current_frame, u4 code_length, bool* this_uninit, constantPoolHandle cp, TRAPS); + // Used by ends_in_athrow() to push all handlers that contain bci onto + // the handler_stack, if the handler is not already on the stack. + void push_handlers(ExceptionTable* exhandlers, + GrowableArray* handler_stack, + u4 bci); + + // Returns true if all paths starting with start_bc_offset end in athrow + // bytecode or loop. + bool ends_in_athrow(u4 start_bc_offset); + void verify_invoke_instructions( RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame, bool* this_uninit, VerificationType return_type, diff -r ded432e6064b -r 0b53273ef822 src/share/vm/interpreter/linkResolver.cpp --- a/src/share/vm/interpreter/linkResolver.cpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/interpreter/linkResolver.cpp Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -187,6 +187,14 @@ void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { methodOop result_oop = klass->uncached_lookup_method(name, signature); + + //JDK 7 does not support default methods, but this code ported from JDK8 to keep code consistent for all JDK. + if (klass->oop_is_array()) { + // Only consider klass and super klass for arrays + result = methodHandle(THREAD, result_oop); + return; + } + if (EnableInvokeDynamic && result_oop != NULL) { vmIntrinsics::ID iid = result_oop->intrinsic_id(); if (MethodHandles::is_signature_polymorphic(iid)) { @@ -421,7 +429,7 @@ // 2. lookup method in resolved klass and its super klasses lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK); - if (resolved_method.is_null()) { // not found in the class hierarchy + if (resolved_method.is_null() && !resolved_klass->oop_is_array()) { // not found in the class hierarchy // 3. lookup method in all the interfaces implemented by the resolved klass lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK); @@ -434,16 +442,16 @@ CLEAR_PENDING_EXCEPTION; } } + } - if (resolved_method.is_null()) { - // 4. method lookup failed - ResourceMark rm(THREAD); - THROW_MSG_CAUSE(vmSymbols::java_lang_NoSuchMethodError(), - methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), - method_name, - method_signature), - nested_exception); - } + if (resolved_method.is_null()) { + // 4. method lookup failed + ResourceMark rm(THREAD); + THROW_MSG_CAUSE(vmSymbols::java_lang_NoSuchMethodError(), + methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + method_name, + method_signature), + nested_exception); } // 5. check if method is concrete @@ -514,17 +522,18 @@ // lookup method in this interface or its super, java.lang.Object lookup_instance_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK); - if (resolved_method.is_null()) { + if (resolved_method.is_null() && !resolved_klass->oop_is_array()) { // lookup method in all the super-interfaces lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK); - if (resolved_method.is_null()) { - // no method found - ResourceMark rm(THREAD); - THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(), - methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), - method_name, - method_signature)); - } + } + + if (resolved_method.is_null()) { + // no method found + ResourceMark rm(THREAD); + THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(), + methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()), + method_name, + method_signature)); } if (check_access) { @@ -614,7 +623,7 @@ // Resolve instance field fieldDescriptor fd; // find_field initializes fd if found - KlassHandle sel_klass(THREAD, instanceKlass::cast(resolved_klass())->find_field(field, sig, &fd)); + KlassHandle sel_klass(THREAD, resolved_klass->find_field(field, sig, &fd)); // check if field exists; i.e., if a klass containing the field def has been selected if (sel_klass.is_null()){ ResourceMark rm(THREAD); diff -r ded432e6064b -r 0b53273ef822 src/share/vm/oops/arrayKlass.cpp --- a/src/share/vm/oops/arrayKlass.cpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/oops/arrayKlass.cpp Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,6 +64,13 @@ return NULL; } +// find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined +klassOop arrayKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { + // There are no fields in an array klass but look to the super class (Object) + assert(super(), "super klass must be present"); + return Klass::cast(super())->find_field(name, sig, fd); +} + methodOop arrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const { // There are no methods in an array klass but the super class (Object) has some assert(super(), "super klass must be present"); diff -r ded432e6064b -r 0b53273ef822 src/share/vm/oops/arrayKlass.hpp --- a/src/share/vm/oops/arrayKlass.hpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/oops/arrayKlass.hpp Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,8 @@ #include "oops/klassOop.hpp" #include "oops/klassVtable.hpp" +class fieldDescriptor; + // arrayKlass is the abstract baseclass for all array classes class arrayKlass: public Klass { @@ -83,6 +85,9 @@ virtual oop multi_allocate(int rank, jint* sizes, TRAPS); objArrayOop allocate_arrayArray(int n, int length, TRAPS); + // find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined + klassOop find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const; + // Lookup operations methodOop uncached_lookup_method(Symbol* name, Symbol* signature) const; diff -r ded432e6064b -r 0b53273ef822 src/share/vm/oops/klass.cpp --- a/src/share/vm/oops/klass.cpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/oops/klass.cpp Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -119,6 +119,15 @@ return is_subclass_of(k); } +klassOop Klass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { +#ifdef ASSERT + tty->print_cr("Error: find_field called on a klass oop." + " Likely error: reflection method does not correctly" + " wrap return value in a mirror object."); +#endif + ShouldNotReachHere(); + return NULL; +} methodOop Klass::uncached_lookup_method(Symbol* name, Symbol* signature) const { #ifdef ASSERT diff -r ded432e6064b -r 0b53273ef822 src/share/vm/oops/klass.hpp --- a/src/share/vm/oops/klass.hpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/oops/klass.hpp Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,6 +88,7 @@ class klassVtable; class KlassHandle; class OrderAccess; +class fieldDescriptor; // Holder (or cage) for the C++ vtable of each kind of Klass. // We want to tightly constrain the location of the C++ vtable in the overall layout. @@ -514,6 +515,7 @@ virtual void initialize(TRAPS); // lookup operation for MethodLookupCache friend class MethodLookupCache; + virtual klassOop find_field(Symbol* name, Symbol* signature, fieldDescriptor* fd) const; virtual methodOop uncached_lookup_method(Symbol* name, Symbol* signature) const; public: methodOop lookup_method(Symbol* name, Symbol* signature) const { diff -r ded432e6064b -r 0b53273ef822 src/share/vm/opto/graphKit.cpp diff -r ded432e6064b -r 0b53273ef822 src/share/vm/opto/library_call.cpp diff -r ded432e6064b -r 0b53273ef822 src/share/vm/opto/reg_split.cpp --- a/src/share/vm/opto/reg_split.cpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/opto/reg_split.cpp Fri Sep 05 11:11:13 2014 -0700 @@ -51,15 +51,6 @@ static const char out_of_nodes[] = "out of nodes during split"; -static bool contains_no_live_range_input(const Node* def) { - for (uint i = 1; i < def->req(); ++i) { - if (def->in(i) != NULL && def->in_RegMask(i).is_NotEmpty()) { - return false; - } - } - return true; -} - //------------------------------get_spillcopy_wide----------------------------- // Get a SpillCopy node with wide-enough masks. Use the 'wide-mask', the // wide ideal-register spill-mask if possible. If the 'wide-mask' does @@ -326,10 +317,13 @@ if( def->req() > 1 ) { for( uint i = 1; i < def->req(); i++ ) { Node *in = def->in(i); - // Check for single-def (LRG cannot redefined) uint lidx = n2lidx(in); - if( lidx >= _maxlrg ) continue; // Value is a recent spill-copy - if (lrgs(lidx).is_singledef()) continue; + // We do not need this for live ranges that are only defined once. + // However, this is not true for spill copies that are added in this + // Split() pass, since they might get coalesced later on in this pass. + if (lidx < _maxlrg && lrgs(lidx).is_singledef()) { + continue; + } Block *b_def = _cfg._bbs[def->_idx]; int idx_def = b_def->find_node(def); @@ -1303,7 +1297,7 @@ Node *def = Reaches[pidx][slidx]; assert( def, "must have reaching def" ); // If input up/down sense and reg-pressure DISagree - if (def->rematerialize() && contains_no_live_range_input(def)) { + if (def->rematerialize()) { // Place the rematerialized node above any MSCs created during // phi node splitting. end_idx points at the insertion point // so look at the node before it. diff -r ded432e6064b -r 0b53273ef822 src/share/vm/prims/jvm.cpp --- a/src/share/vm/prims/jvm.cpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/prims/jvm.cpp Fri Sep 05 11:11:13 2014 -0700 @@ -752,6 +752,7 @@ return (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror()); JVM_END +// Not used; JVM_FindClassFromCaller replaces this. JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, jboolean init, jobject loader, jboolean throwError)) @@ -778,6 +779,42 @@ return result; JVM_END +// Find a class with this name in this loader, using the caller's protection domain. +JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name, + jboolean init, jobject loader, + jclass caller)) + JVMWrapper2("JVM_FindClassFromCaller %s throws ClassNotFoundException", name); + // Java libraries should ensure that name is never null... + if (name == NULL || (int)strlen(name) > Symbol::max_length()) { + // It's impossible to create this class; the name cannot fit + // into the constant pool. + THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name); + } + + TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); + + oop loader_oop = JNIHandles::resolve(loader); + oop from_class = JNIHandles::resolve(caller); + oop protection_domain = NULL; + // If loader is null, shouldn't call ClassLoader.checkPackageAccess; otherwise get + // NPE. Put it in another way, the bootstrap class loader has all permission and + // thus no checkPackageAccess equivalence in the VM class loader. + // The caller is also passed as NULL by the java code if there is no security + // manager to avoid the performance cost of getting the calling class. + if (from_class != NULL && loader_oop != NULL) { + protection_domain = instanceKlass::cast(java_lang_Class::as_klassOop(from_class))->protection_domain(); + } + + Handle h_loader(THREAD, loader_oop); + Handle h_prot(THREAD, protection_domain); + jclass result = find_class_from_class_loader(env, h_name, init, h_loader, + h_prot, false, THREAD); + + if (TraceClassResolution && result != NULL) { + trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result))); + } + return result; +JVM_END JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, jclass from)) @@ -4104,10 +4141,15 @@ // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// -jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) { +jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, + Handle loader, Handle protection_domain, + jboolean throwError, TRAPS) { // Security Note: // The Java level wrapper will perform the necessary security check allowing - // us to pass the NULL as the initiating class loader. + // us to pass the NULL as the initiating class loader. The VM is responsible for + // the checkPackageAccess relative to the initiating class loader via the + // protection_domain. The protection_domain is passed as NULL by the java code + // if there is no security manager in 3-arg Class.forName(). klassOop klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); KlassHandle klass_handle(THREAD, klass); diff -r ded432e6064b -r 0b53273ef822 src/share/vm/prims/jvm.h --- a/src/share/vm/prims/jvm.h Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/prims/jvm.h Fri Sep 05 11:11:13 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -415,6 +415,19 @@ JVM_FindClassFromBootLoader(JNIEnv *env, const char *name); /* + * Find a class from a given class loader. Throws ClassNotFoundException. + * name: name of class + * init: whether initialization is done + * loader: class loader to look up the class. This may not be the same as the caller's + * class loader. + * caller: initiating class. The initiating class may be null when a security + * manager is not installed. + */ +JNIEXPORT jclass JNICALL +JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init, + jobject loader, jclass caller); + +/* * Find a class from a given class. */ JNIEXPORT jclass JNICALL diff -r ded432e6064b -r 0b53273ef822 src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/runtime/arguments.cpp Fri Sep 05 11:11:13 2014 -0700 @@ -2100,6 +2100,10 @@ PrintNMTStatistics = false; } +#ifdef COMPILER1 + status &= verify_interval(SafepointPollOffset, 0, os::vm_page_size() - BytesPerWord, "SafepointPollOffset"); +#endif + return status; } diff -r ded432e6064b -r 0b53273ef822 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Wed Aug 20 12:12:55 2014 -0700 +++ b/src/share/vm/runtime/globals.hpp Fri Sep 05 11:11:13 2014 -0700 @@ -1094,9 +1094,11 @@ "Prevent spurious or premature wakeups from object.wait " \ "(Solaris only)") \ \ - product(intx, NativeMonitorTimeout, -1, "(Unstable)" ) \ - product(intx, NativeMonitorFlags, 0, "(Unstable)" ) \ - product(intx, NativeMonitorSpinLimit, 20, "(Unstable)" ) \ + experimental(intx, NativeMonitorTimeout, -1, "(Unstable)") \ + \ + experimental(intx, NativeMonitorFlags, 0, "(Unstable)") \ + \ + experimental(intx, NativeMonitorSpinLimit, 20, "(Unstable)") \ \ develop(bool, UsePthreads, false, \ "Use pthread-based instead of libthread-based synchronization " \ diff -r ded432e6064b -r 0b53273ef822 test/compiler/7141637/SpreadNullArg.java --- a/test/compiler/7141637/SpreadNullArg.java Wed Aug 20 12:12:55 2014 -0700 +++ b/test/compiler/7141637/SpreadNullArg.java Fri Sep 05 11:11:13 2014 -0700 @@ -46,13 +46,17 @@ mh_spread_target = MethodHandles.lookup().findStatic(SpreadNullArg.class, "target_spread_arg", mt_ref_arg); result = (int) mh_spreadInvoker.invokeExact(mh_spread_target, (Object[]) null); - } catch(NullPointerException e) { - // Expected exception - do nothing! - } catch(Throwable e) { + throw new Error("Expected IllegalArgumentException was not thrown"); + } catch (IllegalArgumentException e) { + System.out.println("Expected exception : " + e); + } catch (Throwable e) { throw new Error(e); } - if (result != 42) throw new Error("Expected NullPointerException was not thrown"); + if (result != 42) { + throw new Error("result [" + result + + "] != 42 : Expected IllegalArgumentException was not thrown?"); + } } public static int target_spread_arg(Integer i1) {