You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chapter-1.txt
+22-8Lines changed: 22 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@ Table of Contents
7
7
1.3. Notation
8
8
1.4. Relationship to Predefined Classes and Interfaces
9
9
1.5. Preview Features
10
+
1.5.1. Restrictions on the Use of Preview Features
11
+
1.5.2. Current Preview Language Features
10
12
1.6. Feedback
11
13
1.7. References
12
14
@@ -16,7 +18,7 @@ The Java programming language is strongly and statically typed. This specificati
16
18
17
19
The Java programming language is a relatively high-level language, in that details of the machine representation are not available through the language. It includes automatic storage management, typically using a garbage collector, to avoid the safety problems of explicit deallocation (as in C's free or C++'s delete). High-performance garbage-collected implementations can have bounded pauses to support systems programming and real-time applications. The language does not include any unsafe constructs, such as array accesses without index checking, since such unsafe constructs would cause a program to behave in an unspecified way.
18
20
19
-
The Java programming language is normally compiled to the bytecode instruction set and binary format defined in The Java Virtual Machine Specification, Java SE 24 Edition.
21
+
The Java programming language is normally compiled to the bytecode instruction set and binary format defined in The Java Virtual Machine Specification, Java SE 25 Edition.
20
22
21
23
1.1. Organization of the Specification
22
24
@@ -111,7 +113,7 @@ Hello, world.
111
113
112
114
Throughout this specification, we refer to classes and interfaces drawn from the Java SE Platform API. Whenever we refer to a class or interface (other than those declared in an example) using a single identifier N, the intended reference is to the class or interface named N in the package java.lang. We use the canonical name (§6.7) for classes or interfaces from packages other than java.lang.
113
115
114
-
A cross-reference within this specification is shown as (§x.y). Occasionally, we refer to concepts in the The Java Virtual Machine Specification, Java SE 24 Edition via cross-references of the form (JVMS §x.y).
116
+
A cross-reference within this specification is shown as (§x.y). Occasionally, we refer to concepts in the The Java Virtual Machine Specification, Java SE 25 Edition via cross-references of the form (JVMS §x.y).
115
117
116
118
Non-normative text, designed to clarify the normative text of this specification, is given in smaller, indented text.
117
119
@@ -133,21 +135,25 @@ A preview feature is:
133
135
134
136
a new feature of the Java programming language ("preview language feature"), or
135
137
138
+
a new feature of the Java Virtual Machine ("preview VM feature"), or
139
+
136
140
a new module, package, class, interface, field, method, constructor, or enum constant in the java.* or javax.* namespace ("preview API")
137
141
138
142
that is fully specified, fully implemented, and yet impermanent. It is available in implementations of a given release of the Java SE Platform to provoke developer feedback based on real world use; this may lead to it becoming permanent in a future release of the Java SE Platform.
139
143
140
-
Implementations must disable, at both compile time and run time, the preview features defined by a given release of the Java SE Platform, unless the user indicates via the host system, at both compile time and run time, that preview features are to be enabled.
141
-
142
144
The preview features defined by a given release of the Java SE Platform are enumerated in the Java SE Platform Specification for that release. The preview features are specified as follows:
143
145
144
146
Preview language features are specified in standalone documents that indicate changes ("diffs") to The Java® Language Specification for that release. The specifications of preview language features are incorporated into The Java® Language Specification by reference, and made a part thereof, if and only if preview features are enabled at compile time.
145
147
146
-
Java SE 24 defines four preview language features: Flexible Constructor Bodies; Simple Source Files and Instance main Methods; Module Import Declarations; and Primitive Types in Patterns, instanceof, and switch. The standalone documents which specify these preview features are available at the web site which hosts this edition of The Java® Language Specification.
148
+
Preview VM features are specified in standalone documents that indicate changes ("diffs") to The Java® Virtual Machine Specification for that release. The specifications of preview VM features are incorporated into The Java® Virtual Machine Specification by reference, and made a part thereof, if and only if preview features are enabled at run time.
147
149
148
150
Preview APIs are specified within the Java SE API Specification for that release.
149
151
150
-
The rules for use of preview language features are as follows:
152
+
1.5.1. Restrictions on the Use of Preview Features
153
+
154
+
Implementations of the Java SE Platform disable, at both compile time and run time, the preview features defined by a given release, unless the user indicates via the host system, at both compile time and run time, that preview features are enabled. Implementations do not provide a way to enable only some of the given release's preview features.
155
+
156
+
At compile time, the rules for use of preview language features are as follows:
151
157
152
158
If preview features are disabled, then any source code reference to a preview language feature, or to a class or interface declared using a preview language feature, causes a compile-time error.
153
159
@@ -159,7 +165,7 @@ The reference appears in an import declaration (§7.5).
159
165
160
166
When preview features are enabled, Java compilers are strongly encouraged to give a non-suppressible warning for every source code reference to a preview language feature. Details of this warning are beyond the scope of this specification, but the intent should be to alert programmers to the possibility of code being affected by future changes to preview language features.
161
167
162
-
Some preview APIs are described as reflective by the Java SE Platform Specification, principally in the java.lang.reflect, java.lang.invoke, and javax.lang.model packages. The rule for use of reflective preview APIs is as follows:
168
+
Some preview APIs are described as reflective by the Java SE Platform Specification, principally in the java.lang.reflect, java.lang.invoke, and javax.lang.model packages. At compile time, the rule for use of reflective preview APIs is as follows:
163
169
164
170
Whether preview features are enabled or disabled, any source code reference to a reflective preview API element causes a preview warning, unless one of the following is true:
165
171
@@ -169,7 +175,7 @@ The reference appears in a declaration that is annotated to suppress preview war
169
175
170
176
The reference appears in an import declaration.
171
177
172
-
All preview APIs not described as reflective in the Java SE Platform Specification are normal. The rules for use of normal preview APIs are as follows:
178
+
All preview APIs not described as reflective in the Java SE Platform Specification are normal. At compile time, the rules for use of normal preview APIs are as follows:
173
179
174
180
If preview features are disabled, then any source code reference to a normal preview API element causes a compile-time error, unless:
175
181
@@ -183,6 +189,14 @@ The reference appears in a declaration that is annotated to suppress preview war
183
189
184
190
The reference appears in an import declaration.
185
191
192
+
1.5.2. Current Preview Language Features
193
+
194
+
Java SE 25 defines one preview language feature:
195
+
196
+
Primitive Types in Patterns, instanceof, and switch
197
+
198
+
The standalone documents which specify this preview feature are available at the web site which hosts this edition of The Java® Language Specification.
199
+
186
200
1.6. Feedback
187
201
188
202
Readers are invited to report technical errors and ambiguities in The Java® Language Specification to jls-jvms-spec-comments@openjdk.org.
Copy file name to clipboardExpand all lines: chapter-11.txt
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Table of Contents
8
8
11.1.3. Asynchronous Exceptions
9
9
11.2. Compile-Time Checking of Exceptions
10
10
11.2.1. Exception Analysis of Expressions
11
-
11.2.2. Exception Analysis of Statements
11
+
11.2.2. Exception Analysis of Statements and Constructor Invocations
12
12
11.2.3. Exception Checking
13
13
11.3. Run-Time Handling of an Exception
14
14
@@ -147,7 +147,7 @@ For every other kind of expression, the expression can throw an exception class
147
147
148
148
Note that a method reference expression (§15.13) of the form Primary :: [TypeArguments] Identifier can throw an exception class if the Primary subexpression can throw an exception class. In contrast, a lambda expression can throw nothing, and has no immediate subexpressions on which to perform exception analysis. It is the body of a lambda expression, containing expressions and statements, that can throw exception classes.
149
149
150
-
11.2.2. Exception Analysis of Statements
150
+
11.2.2. Exception Analysis of Statements and Constructor Invocations
151
151
152
152
A throw statement (§14.18) whose thrown expression has static type E and is not a final or effectively final exception parameter can throw E or any exception class that the thrown expression can throw.
153
153
@@ -169,12 +169,6 @@ Some catch block of the try statement can throw E and either no finally block is
169
169
170
170
A finally block is present and can throw E.
171
171
172
-
An explicit constructor invocation statement (§8.8.7.1) can throw an exception class E iff either:
173
-
174
-
Some expression of the constructor invocation's parameter list can throw E; or
175
-
176
-
E is determined to be an exception class of the throws clause of the constructor that is invoked (§15.12.2.6).
177
-
178
172
A switch statement (§14.11) can throw an exception class E iff either:
179
173
180
174
The selector expression can throw E; or
@@ -183,6 +177,12 @@ Some switch rule expression, switch rule block, switch rule throw statement, or
183
177
184
178
Any other statement S can throw an exception class E iff an expression or statement immediately contained in S can throw E.
185
179
180
+
A constructor invocation (§8.8.7.1) can throw an exception class E iff either:
181
+
182
+
Some expression of the constructor invocation's parameter list can throw E; or
183
+
184
+
E is determined to be an exception class of the throws clause of the constructor that is invoked (§15.12.2.6).
185
+
186
186
11.2.3. Exception Checking
187
187
188
188
It is a compile-time error if a method or constructor body can throw some exception class E when E is a checked exception class and E is not a subclass of some class declared in the throws clause of the method or constructor.
0 commit comments