Why does the JVM allow us to name a function starting with a digit in bytecode?

前端 未结 2 1684
情深已故
情深已故 2021-01-14 12:48

Identifiers are well defined by The Java Language Specification, Java SE 7 Edition (§3.8)

An identifier is an unlimited-length sequenc         


        
2条回答
  •  广开言路
    2021-01-14 13:55

    The Java Language Specification restricts the characters in valid method names so as to help make parsing the Java language unambiguous.

    The JVM was designed to be able to support languages other than just Java. As such the restrictions should not be the same; unless we wanted to force all non-Java languages to have the same restrictions. The restrictions chosen for the JVM are the minimal set that permit unambiguous parsing of the method signatures, a format that appears in the JVM spec and not the JLS.

    Taken from the JVM Spec

    a name must not contain any of the ASCII characters . ; [ / < > :
    

    That is, the following is a valid JVM signatures [Lcom/foo/Bar;, and its special characters have been excluded from method names.

    <> was further reserved to separate special JVM methods from application methods, specifically and , which are both method names that the JLS does not permit.

提交回复
热议问题