Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/classFileParser.cpp @ 7579:adc176e95bf2
8005689: InterfaceAccessFlagsTest failures in Lambda-JDK tests
Summary: Fix verifier for new interface access flags
Reviewed-by: acorn, kvn
Contributed-by: bharadwaj.yadavalli@oracle.com
author | acorn |
---|---|
date | Wed, 09 Jan 2013 11:39:30 -0500 |
parents | ade95d680b42 |
children | 4a916f2ce331 f9eb431c3efe |
comparison
equal
deleted
inserted
replaced
7466:0c93d4818214 | 7579:adc176e95bf2 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * 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 |
6 * 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 |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
3910 // check if this class overrides any final method | 3910 // check if this class overrides any final method |
3911 check_final_method_override(this_klass, CHECK_(nullHandle)); | 3911 check_final_method_override(this_klass, CHECK_(nullHandle)); |
3912 | 3912 |
3913 // check that if this class is an interface then it doesn't have static methods | 3913 // check that if this class is an interface then it doesn't have static methods |
3914 if (this_klass->is_interface()) { | 3914 if (this_klass->is_interface()) { |
3915 check_illegal_static_method(this_klass, CHECK_(nullHandle)); | 3915 /* An interface in a JAVA 8 classfile can be static */ |
3916 if (_major_version < JAVA_8_VERSION) { | |
3917 check_illegal_static_method(this_klass, CHECK_(nullHandle)); | |
3918 } | |
3916 } | 3919 } |
3917 | 3920 |
3918 | 3921 |
3919 #ifdef ASSERT | 3922 #ifdef ASSERT |
3920 if (ParseAllGenericSignatures) { | 3923 if (ParseAllGenericSignatures) { |
4464 const bool is_native = (flags & JVM_ACC_NATIVE) != 0; | 4467 const bool is_native = (flags & JVM_ACC_NATIVE) != 0; |
4465 const bool is_abstract = (flags & JVM_ACC_ABSTRACT) != 0; | 4468 const bool is_abstract = (flags & JVM_ACC_ABSTRACT) != 0; |
4466 const bool is_bridge = (flags & JVM_ACC_BRIDGE) != 0; | 4469 const bool is_bridge = (flags & JVM_ACC_BRIDGE) != 0; |
4467 const bool is_strict = (flags & JVM_ACC_STRICT) != 0; | 4470 const bool is_strict = (flags & JVM_ACC_STRICT) != 0; |
4468 const bool is_synchronized = (flags & JVM_ACC_SYNCHRONIZED) != 0; | 4471 const bool is_synchronized = (flags & JVM_ACC_SYNCHRONIZED) != 0; |
4472 const bool is_protected = (flags & JVM_ACC_PROTECTED) != 0; | |
4469 const bool major_gte_15 = _major_version >= JAVA_1_5_VERSION; | 4473 const bool major_gte_15 = _major_version >= JAVA_1_5_VERSION; |
4470 const bool major_gte_8 = _major_version >= JAVA_8_VERSION; | 4474 const bool major_gte_8 = _major_version >= JAVA_8_VERSION; |
4471 const bool is_initializer = (name == vmSymbols::object_initializer_name()); | 4475 const bool is_initializer = (name == vmSymbols::object_initializer_name()); |
4472 | 4476 |
4473 bool is_illegal = false; | 4477 bool is_illegal = false; |
4474 | 4478 |
4475 if (is_interface) { | 4479 if (is_interface) { |
4476 if (!is_public || is_static || is_final || is_native || | 4480 if (major_gte_8) { |
4477 ((is_synchronized || is_strict) && major_gte_15 && | 4481 // Class file version is JAVA_8_VERSION or later Methods of |
4478 (!major_gte_8 || is_abstract)) || | 4482 // interfaces may set any of the flags except ACC_PROTECTED, |
4479 (!major_gte_8 && !is_abstract)) { | 4483 // ACC_FINAL, ACC_NATIVE, and ACC_SYNCHRONIZED; they must |
4480 is_illegal = true; | 4484 // have exactly one of the ACC_PUBLIC or ACC_PRIVATE flags set. |
4485 if ((is_public == is_private) || /* Only one of private and public should be true - XNOR */ | |
4486 (is_native || is_protected || is_final || is_synchronized) || | |
4487 // If a specific method of a class or interface has its | |
4488 // ACC_ABSTRACT flag set, it must not have any of its | |
4489 // ACC_FINAL, ACC_NATIVE, ACC_PRIVATE, ACC_STATIC, | |
4490 // ACC_STRICT, or ACC_SYNCHRONIZED flags set. No need to | |
4491 // check for ACC_FINAL, ACC_NATIVE or ACC_SYNCHRONIZED as | |
4492 // those flags are illegal irrespective of ACC_ABSTRACT being set or not. | |
4493 (is_abstract && (is_private || is_static || is_strict))) { | |
4494 is_illegal = true; | |
4495 } | |
4496 } else if (major_gte_15) { | |
4497 // Class file version in the interval [JAVA_1_5_VERSION, JAVA_8_VERSION) | |
4498 if (!is_public || is_static || is_final || is_synchronized || | |
4499 is_native || !is_abstract || is_strict) { | |
4500 is_illegal = true; | |
4501 } | |
4502 } else { | |
4503 // Class file version is pre-JAVA_1_5_VERSION | |
4504 if (!is_public || is_static || is_final || is_native || !is_abstract) { | |
4505 is_illegal = true; | |
4506 } | |
4481 } | 4507 } |
4482 } else { // not interface | 4508 } else { // not interface |
4483 if (is_initializer) { | 4509 if (is_initializer) { |
4484 if (is_static || is_final || is_synchronized || is_native || | 4510 if (is_static || is_final || is_synchronized || is_native || |
4485 is_abstract || (major_gte_15 && is_bridge)) { | 4511 is_abstract || (major_gte_15 && is_bridge)) { |