[ 
https://issues.apache.org/jira/browse/BCEL-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14249902#comment-14249902
 ] 

Jérôme Leroux commented on BCEL-183:
------------------------------------

According to the Java SE 7 Edition of _The Java Virtual Machine Specification_, 
there is not restriction on the attributes of a method named {{<clinit>}}. To 
be considered as a _class or interface initialization method_ a method must 
have the name {{<clinit>}}, take no arguments, and be void. A method named 
{{<clinit>}} that is not a  _class or interface initialization method_ is still 
valid. That's why there is no specific check for these methods in the verifier.

The only restriction is about calling a method named {{<clinit>}}, it is 
forbidden. The issue is handle by the {{validMethodNameReference(String)}} 
method.

http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.9
{quote}
A class or interface has at most one class or interface initialization method 
and is initialized (§5.5) by invoking that method. The initialization method of 
a class or interface has the special name <clinit>, takes no arguments, and is 
void (§4.3.3).

Other methods named <clinit> in a class file are of no consequence. They are 
not class or interface initialization methods. They cannot be invoked by any 
Java Virtual Machine instruction and are never invoked by the Java Virtual 
Machine itself. 
{quote}

In the Second Edition of _The Java Virtual Machine Specification_, this 
clarification is missing.
http://docs.oracle.com/javase/specs/jvms/se5.0/html/Overview.doc.html#12174
{quote}
A class or interface has at most one class or interface initialization method 
and is initialized (§2.17.4) by invoking that method. The initialization method 
of a class or interface is static and takes no arguments. It has the special 
name <clinit>. This name is supplied by a compiler. Because the name <clinit> 
is not a valid identifier, it cannot be used directly in a program written in 
the Java programming language. Class and interface initialization methods are 
invoked implicitly by the Java virtual machine; they are never invoked directly 
from any Java virtual machine instruction, but are invoked only indirectly as 
part of the class initialization process.
{quote}


> Implement Java 7 field/method name validation rules
> ---------------------------------------------------
>
>                 Key: BCEL-183
>                 URL: https://issues.apache.org/jira/browse/BCEL-183
>             Project: Commons BCEL
>          Issue Type: Improvement
>          Components: Verifier
>    Affects Versions: 5.2
>            Reporter: Jérôme Leroux
>             Fix For: 6.0
>
>         Attachments: BCEL-183-2.patch, BCEL-183-2.zip, BCEL-183-src.zip, 
> BCEL-183.patch, BCEL-183.zip
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> The JustIce bytecode verifier checks the validity of the field name and the 
> variable name considering the java langage specification. 
> This check is not specified by the bytecode verifier specification.
> This may lead to bytecode verification errors in pass2 on valid classfiles.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to