comparison src/share/vm/interpreter/linkResolver.cpp @ 12945:662c154d2749

8026394: Eclipse fails with JDK8 build 111 Summary: If the resolved interface does not itself contain "clone" or "finalize" methods, the method/interface method resolution looks to the interface's super class, java.lang.Object. With the JDK 8 interface method accessability check requirement, since these two methods are declared within Object as protected, they must be special cased in LinkResolver::check_method_accessability() in order to avoid an IAE. Reviewed-by: acorn, dholmes Contributed-by: lois.foltan@oracle.com
author hseigel
date Tue, 22 Oct 2013 14:47:59 -0400
parents ee99e1a7c5fb
children fce21ac5968d
comparison
equal deleted inserted replaced
12944:1327b7f85503 12945:662c154d2749
1 /* 1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * 4 *
6 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
417 methodHandle sel_method, 416 methodHandle sel_method,
418 TRAPS) { 417 TRAPS) {
419 418
420 AccessFlags flags = sel_method->access_flags(); 419 AccessFlags flags = sel_method->access_flags();
421 420
422 // Special case: arrays always override "clone". JVMS 2.15. 421 // Special case #1: arrays always override "clone". JVMS 2.15.
423 // If the resolved klass is an array class, and the declaring class 422 // If the resolved klass is an array class, and the declaring class
424 // is java.lang.Object and the method is "clone", set the flags 423 // is java.lang.Object and the method is "clone", set the flags
425 // to public. 424 // to public.
425 // Special case #2: If the resolved klass is an interface, and
426 // the declaring class is java.lang.Object, and the method is
427 // "clone" or "finalize", set the flags to public. If the
428 // resolved interface does not contain "clone" or "finalize"
429 // methods, the method/interface method resolution looks to
430 // the interface's super class, java.lang.Object. With JDK 8
431 // interface accessability check requirement, special casing
432 // this scenario is necessary to avoid an IAE.
426 // 433 //
427 // We'll check for the method name first, as that's most likely 434 // We'll check for each method name first and then java.lang.Object
428 // to be false (so we'll short-circuit out of these tests). 435 // to best short-circuit out of these tests.
429 if (sel_method->name() == vmSymbols::clone_name() && 436 if (((sel_method->name() == vmSymbols::clone_name() &&
430 sel_klass() == SystemDictionary::Object_klass() && 437 (resolved_klass->oop_is_array() || resolved_klass->is_interface())) ||
431 resolved_klass->oop_is_array()) { 438 (sel_method->name() == vmSymbols::finalize_method_name() &&
439 resolved_klass->is_interface())) &&
440 sel_klass() == SystemDictionary::Object_klass()) {
432 // We need to change "protected" to "public". 441 // We need to change "protected" to "public".
433 assert(flags.is_protected(), "clone not protected?"); 442 assert(flags.is_protected(), "clone or finalize not protected?");
434 jint new_flags = flags.as_int(); 443 jint new_flags = flags.as_int();
435 new_flags = new_flags & (~JVM_ACC_PROTECTED); 444 new_flags = new_flags & (~JVM_ACC_PROTECTED);
436 new_flags = new_flags | JVM_ACC_PUBLIC; 445 new_flags = new_flags | JVM_ACC_PUBLIC;
437 flags.set_flags(new_flags); 446 flags.set_flags(new_flags);
438 } 447 }