This proposal defines new syntax to perform privleged static initialization of a class.
See the proposal repository for background material and discussion.
A ClassStaticBlockDefinition Record is a
ClassStaticBlockDefinition Records have the fields listed in
Field Name | Value | Meaning |
---|---|---|
[[BodyFunction]] |
An |
The |
The abstract operation EvaluateStaticBlock takes arguments receiver (an Object) and blockRecord (a
In addition to those defined in this section, specialized syntax-directed operations are defined throughout this specification.
At the top level of a
The LexicallyDeclaredNames of a
export
At the top level of a
This section is extended by Annex
export
This section is extended by Annex
export
With parameter labelSet.
This section is extended by Annex
With parameter labelSet.
This section is extended by Annex
With parameters iterationSet and labelSet.
This section is extended by Annex
With parameter symbol.
Every grammar production alternative in this specification which is not listed below implicitly has the following default definition of Contains:
Static semantic rules that depend upon substructure generally do not look into function definitions.
Static semantic rules that depend upon substructure generally do not look into class bodies except for
Static semantic rules that depend upon substructure generally do not look into static
initialization blocks.
super
or this
, return super
, or this
, return super
, or this
, return Contains is used to detect new.target
, this
, and super
usage within an
super
, return With parameter symbol.
These operations are used in multiple places throughout the specification.
With parameters functionObject and argumentsList (a
Even though field initializers constitute a function boundary, calling
continue
Statementstatic
initialization block boundaries), within an break
Statementstatic
initialization block boundaries), within an Every grammar production alternative in this specification which is not listed below implicitly has the following default definition of ContainsAwait:
Static semantic rules that depend upon substructure generally do not look into function definitions.
Static semantic rules that depend upon substructure generally do not look into class bodies except for
Static semantic rules that depend upon substructure containing await
do not need to look into arrow functions.
With parameter homeObject.
With parameter functionObject.
With parameters object and enumerable.
With parameters classBinding and className.
For ease of specification, private methods and accessors are included alongside private fields in the [[PrivateElements]] slot of class instances. However, any given object has either all or none of the private methods and accessors defined by a given class. This feature has been designed so that implementations may choose to implement private methods and accessors using a strategy which does not require tracking each method or accessor individually.
For example, an implementation could directly associate instance private methods with their corresponding Private Name and track, for each object, which class constructors have run with that object as their this
value. Looking up an instance private method on an object then consists of checking that the class
This differs from private fields: because field initializers can throw during class instantiation, an individual object may have some proper subset of the private fields of a given class, and so private fields must in general be tracked individually.
© 2021 Ron Buckton, Ecma International
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.