United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6324107 : ClassFormatError should be thrown for without a code attribute in an interface

Details
Type:
Bug
Submit Date:
2005-09-14
Status:
Closed
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
2006-01-31
Component:
hotspot
OS:
generic
Sub-Component:
runtime
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports

Sub Tasks

Description
Sun's JDK raises VerifyError when an interface contains <clinit> without a code attribute.

JVMS, 2nd Edition, Chapter 4.6 Methods states:
    ...
    Class and interface initialization methods (3.9) are called implicitly by
    the Java virtual machine; the value of their access_flags item is ignored
    except for the settings of the ACC_STRICT flag.
    ...

Thus, ClassFormatError should be thrown in such case, because:
  - the value of ACC_ABSTRACT is among the ignored flag (as others but except ACC_STRICT)
  - ACC_ABSTRACT cannot be used to suggest that VM should not check for a Code attribute
  - the unstated implicit assumption is that if <clinit> exists, it must have a Code Attribute
  - the check for the existence of a Code Attribute should result to ClassFormatError,
    not a VerifyError.

It is fine for other methods that ACC_ABSTRACT implies no code attribute,
but <clinit> is specifically excepted by the above paragraph.

Note that Sun's JDK raises VerifyError in such cases at least since JDK 1.2. 

Please see comments for 6300312 for more details.

                                    

Comments
EVALUATION

class file parser should check for this
                                     
2006-01-10



Hardware and Software, Engineered to Work Together