# HG changeset patch # User ehelin # Date 1386262195 -3600 # Node ID 816c89d5957d870194af9d85ec7485b111fee584 # Parent e84d2afb2fb099862b71c290b755a40bb6d49d9e# Parent 50287b659eb834321f08f225156063a92d5da2fb Merge diff -r 50287b659eb8 -r 816c89d5957d agent/make/jsdbproc64.sh --- a/agent/make/jsdbproc64.sh Tue Dec 03 12:01:18 2013 +0100 +++ b/agent/make/jsdbproc64.sh Thu Dec 05 17:49:55 2013 +0100 @@ -1,7 +1,7 @@ -#!/bin/sh +#!/bin/sh # -# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 2013, 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 @@ -21,10 +21,10 @@ # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. -# +# # - -. `dirname $0`/saenv64.sh - -$SA_JAVA_CMD sun.jvm.hotspot.tools.JSDB $* + +. `dirname $0`/saenv64.sh + +$SA_JAVA_CMD sun.jvm.hotspot.tools.soql.JSDB $* diff -r 50287b659eb8 -r 816c89d5957d src/share/vm/classfile/defaultMethods.cpp --- a/src/share/vm/classfile/defaultMethods.cpp Tue Dec 03 12:01:18 2013 +0100 +++ b/src/share/vm/classfile/defaultMethods.cpp Thu Dec 05 17:49:55 2013 +0100 @@ -625,13 +625,13 @@ while (super != NULL) { for (int i = 0; i < super->methods()->length(); ++i) { Method* m = super->methods()->at(i); - if (m->is_overpass()) { + if (m->is_overpass() || m->is_static()) { // m is a method that would have been a miranda if not for the // default method processing that occurred on behalf of our superclass, // so it's a method we want to re-examine in this new context. That is, // unless we have a real implementation of it in the current class. Method* impl = klass->lookup_method(m->name(), m->signature()); - if (impl == NULL || impl->is_overpass()) { + if (impl == NULL || impl->is_overpass() || impl->is_static()) { if (!already_in_vtable_slots(slots, m)) { slots->append(new EmptyVtableSlot(m)); } @@ -648,7 +648,7 @@ // so it's a method we want to re-examine in this new context. That is, // unless we have a real implementation of it in the current class. Method* impl = klass->lookup_method(m->name(), m->signature()); - if (impl == NULL || impl->is_overpass()) { + if (impl == NULL || impl->is_overpass() || impl->is_static()) { if (!already_in_vtable_slots(slots, m)) { slots->append(new EmptyVtableSlot(m)); } diff -r 50287b659eb8 -r 816c89d5957d src/share/vm/interpreter/linkResolver.cpp --- a/src/share/vm/interpreter/linkResolver.cpp Tue Dec 03 12:01:18 2013 +0100 +++ b/src/share/vm/interpreter/linkResolver.cpp Thu Dec 05 17:49:55 2013 +0100 @@ -242,7 +242,7 @@ // Look up method in klasses, including static methods // Then look up local default methods -void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { +void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, bool checkpolymorphism, TRAPS) { Method* result_oop = klass->uncached_lookup_method(name, signature); if (result_oop == NULL) { Array* default_methods = InstanceKlass::cast(klass())->default_methods(); @@ -251,7 +251,7 @@ } } - if (EnableInvokeDynamic && result_oop != NULL) { + if (checkpolymorphism && EnableInvokeDynamic && result_oop != NULL) { vmIntrinsics::ID iid = result_oop->intrinsic_id(); if (MethodHandles::is_signature_polymorphic(iid)) { // Do not link directly to these. The VM must produce a synthetic one using lookup_polymorphic_method. @@ -267,8 +267,8 @@ Method* result_oop = klass->uncached_lookup_method(name, signature); result = methodHandle(THREAD, result_oop); while (!result.is_null() && result->is_static() && result->method_holder()->super() != NULL) { - klass = KlassHandle(THREAD, result->method_holder()->super()); - result = methodHandle(THREAD, klass->uncached_lookup_method(name, signature)); + KlassHandle super_klass = KlassHandle(THREAD, result->method_holder()->super()); + result = methodHandle(THREAD, super_klass->uncached_lookup_method(name, signature)); } if (result.is_null()) { @@ -503,11 +503,14 @@ } if (code == Bytecodes::_invokeinterface) { - resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK); + resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK); } else if (code == Bytecodes::_invokevirtual) { resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK); + } else if (!resolved_klass->is_interface()) { + resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, false, CHECK); } else { - resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, false, CHECK); + bool nostatics = (code == Bytecodes::_invokestatic) ? false : true; + resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, nostatics, CHECK); } } @@ -528,7 +531,7 @@ } // 2. lookup method in resolved klass and its super klasses - lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK); + lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, true, CHECK); if (resolved_method.is_null()) { // not found in the class hierarchy // 3. lookup method in all the interfaces implemented by the resolved klass @@ -612,7 +615,8 @@ Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, - bool check_access, TRAPS) { + bool check_access, + bool nostatics, TRAPS) { // check if klass is interface if (!resolved_klass->is_interface()) { @@ -623,7 +627,8 @@ } // 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); + // JDK8: also look for static methods + lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, false, CHECK); if (resolved_method.is_null()) { // lookup method in all the super-interfaces @@ -638,6 +643,16 @@ } } + if (nostatics && resolved_method->is_static()) { + ResourceMark rm(THREAD); + char buf[200]; + jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s", Method::name_and_sig_as_C_string(resolved_klass(), + resolved_method->name(), + resolved_method->signature())); + THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); + } + + if (check_access) { // JDK8 adds non-public interface methods, and accessability check requirement assert(current_klass.not_null() , "current_klass should not be null"); @@ -864,7 +879,11 @@ Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) { - resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, false, CHECK); + if (!resolved_klass->is_interface()) { + resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, false, CHECK); + } else { + resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, false, CHECK); + } assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier"); // check if static @@ -898,7 +917,11 @@ // and the selected method is recalculated relative to the direct superclass // superinterface.method, which explicitly does not check shadowing - resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, false, CHECK); + if (!resolved_klass->is_interface()) { + resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, false, CHECK); + } else { + resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, true, CHECK); + } // check if method name is , that it is found in same klass as static type if (resolved_method->name() == vmSymbols::object_initializer_name() && @@ -1219,7 +1242,7 @@ void LinkResolver::linktime_resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) { // normal interface method resolution - resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK); + resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, true, CHECK); assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); diff -r 50287b659eb8 -r 816c89d5957d src/share/vm/interpreter/linkResolver.hpp --- a/src/share/vm/interpreter/linkResolver.hpp Tue Dec 03 12:01:18 2013 +0100 +++ b/src/share/vm/interpreter/linkResolver.hpp Thu Dec 05 17:49:55 2013 +0100 @@ -124,7 +124,7 @@ friend class klassItable; private: - static void lookup_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); + static void lookup_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, bool checkpolymorphism, TRAPS); static void lookup_instance_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); static void lookup_method_in_interfaces (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); static void lookup_polymorphic_method (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, @@ -134,7 +134,7 @@ static void resolve_pool (KlassHandle& resolved_klass, Symbol*& method_name, Symbol*& method_signature, KlassHandle& current_klass, constantPoolHandle pool, int index, TRAPS); - static void resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); + static void resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool nostatics, TRAPS); static void resolve_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool require_methodref, TRAPS); static void linktime_resolve_static_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); diff -r 50287b659eb8 -r 816c89d5957d src/share/vm/oops/instanceKlass.cpp --- a/src/share/vm/oops/instanceKlass.cpp Tue Dec 03 12:01:18 2013 +0100 +++ b/src/share/vm/oops/instanceKlass.cpp Thu Dec 05 17:49:55 2013 +0100 @@ -1427,6 +1427,17 @@ return InstanceKlass::find_method(methods(), name, signature); } +// find_instance_method looks up the name/signature in the local methods array +// and skips over static methods +Method* InstanceKlass::find_instance_method( + Array* methods, Symbol* name, Symbol* signature) { + Method* meth = InstanceKlass::find_method(methods, name, signature); + if (meth != NULL && meth->is_static()) { + meth = NULL; + } + return meth; +} + // find_method looks up the name/signature in the local methods array Method* InstanceKlass::find_method( Array* methods, Symbol* name, Symbol* signature) { diff -r 50287b659eb8 -r 816c89d5957d src/share/vm/oops/instanceKlass.hpp --- a/src/share/vm/oops/instanceKlass.hpp Tue Dec 03 12:01:18 2013 +0100 +++ b/src/share/vm/oops/instanceKlass.hpp Thu Dec 05 17:49:55 2013 +0100 @@ -515,6 +515,7 @@ // find a local method (returns NULL if not found) Method* find_method(Symbol* name, Symbol* signature) const; static Method* find_method(Array* methods, Symbol* name, Symbol* signature); + static Method* find_instance_method(Array* methods, Symbol* name, Symbol* signature); // find a local method index in default_methods (returns -1 if not found) static int find_method_index(Array* methods, Symbol* name, Symbol* signature); diff -r 50287b659eb8 -r 816c89d5957d src/share/vm/oops/klassVtable.cpp --- a/src/share/vm/oops/klassVtable.cpp Tue Dec 03 12:01:18 2013 +0100 +++ b/src/share/vm/oops/klassVtable.cpp Thu Dec 05 17:49:55 2013 +0100 @@ -665,6 +665,11 @@ // check if a method is a miranda method, given a class's methods table, // its default_method table and its super +// Miranda methods are calculated twice: +// first: before vtable size calculation: including abstract and default +// This is seen by default method creation +// Second: recalculated during vtable initialization: only abstract +// This is seen by link resolution and selection. // "miranda" means not static, not defined by this class. // private methods in interfaces do not belong in the miranda list. // the caller must make sure that the method belongs to an interface implemented by the class @@ -678,7 +683,8 @@ } Symbol* name = m->name(); Symbol* signature = m->signature(); - if (InstanceKlass::find_method(class_methods, name, signature) == NULL) { + + if (InstanceKlass::find_instance_method(class_methods, name, signature) == NULL) { // did not find it in the method table of the current class if ((default_methods == NULL) || InstanceKlass::find_method(default_methods, name, signature) == NULL) { @@ -688,6 +694,12 @@ } Method* mo = InstanceKlass::cast(super)->lookup_method(name, signature); + while (mo != NULL && mo->access_flags().is_static() + && mo->method_holder() != NULL + && mo->method_holder()->super() != NULL) + { + mo = mo->method_holder()->super()->uncached_lookup_method(name, signature); + } if (mo == NULL || mo->access_flags().is_private() ) { // super class hierarchy does not implement it or protection is different return true; diff -r 50287b659eb8 -r 816c89d5957d src/share/vm/prims/jvmtiEnvThreadState.cpp --- a/src/share/vm/prims/jvmtiEnvThreadState.cpp Tue Dec 03 12:01:18 2013 +0100 +++ b/src/share/vm/prims/jvmtiEnvThreadState.cpp Thu Dec 05 17:49:55 2013 +0100 @@ -269,11 +269,20 @@ void doit() { ResourceMark rmark; // _thread != Thread::current() RegisterMap rm(_thread, false); - javaVFrame* vf = _thread->last_java_vframe(&rm); - assert(vf != NULL, "must have last java frame"); - Method* method = vf->method(); - _method_id = method->jmethod_id(); - _bci = vf->bci(); + // There can be a race condition between a VM_Operation reaching a safepoint + // and the target thread exiting from Java execution. + // We must recheck the last Java frame still exists. + if (_thread->has_last_Java_frame()) { + javaVFrame* vf = _thread->last_java_vframe(&rm); + assert(vf != NULL, "must have last java frame"); + Method* method = vf->method(); + _method_id = method->jmethod_id(); + _bci = vf->bci(); + } else { + // Clear current location as the target thread has no Java frames anymore. + _method_id = (jmethodID)NULL; + _bci = 0; + } } void get_current_location(jmethodID *method_id, int *bci) { *method_id = _method_id; diff -r 50287b659eb8 -r 816c89d5957d test/TEST.groups --- a/test/TEST.groups Tue Dec 03 12:01:18 2013 +0100 +++ b/test/TEST.groups Thu Dec 05 17:49:55 2013 +0100 @@ -70,7 +70,6 @@ runtime/7107135/Test7107135.sh \ runtime/7158988/FieldMonitor.java \ runtime/7194254/Test7194254.java \ - runtime/8026365/InvokeSpecialAnonTest.java \ runtime/jsig/Test8017498.sh \ runtime/Metaspace/FragmentMetaspace.java \ runtime/NMT/BaselineWithParameter.java \ diff -r 50287b659eb8 -r 816c89d5957d test/runtime/8024804/RegisterNatives.java --- a/test/runtime/8024804/RegisterNatives.java Tue Dec 03 12:01:18 2013 +0100 +++ b/test/runtime/8024804/RegisterNatives.java Thu Dec 05 17:49:55 2013 +0100 @@ -22,6 +22,7 @@ */ /* + * @ignore 8028741 * @test * @bug 8024804 * @summary registerNatives() interface resolution should receive IAE