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
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ The Java programming language is strongly and statically typed. This specificati
16
16
17
17
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
18
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 23 Edition.
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.
20
20
21
21
1.1. Organization of the Specification
22
22
@@ -111,7 +111,7 @@ Hello, world.
111
111
112
112
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
113
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 23 Edition via cross-references of the form (JVMS §x.y).
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).
115
115
116
116
Non-normative text, designed to clarify the normative text of this specification, is given in smaller, indented text.
117
117
@@ -143,7 +143,7 @@ The preview features defined by a given release of the Java SE Platform are enum
143
143
144
144
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
145
146
-
Java SE 23 defines four preview language features: Flexible Constructor Bodies; Implicitly Declared Classes 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 Oracle web site which hosts The Java® Language Specification: https://docs.oracle.com/javase/specs/.
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.
147
147
148
148
Preview APIs are specified within the Java SE API Specification for that release.
149
149
@@ -214,4 +214,4 @@ Mitchell, James G., William Maybury, and Richard Sweet. The Mesa Programming Lan
214
214
215
215
Stroustrup, Bjarne. The C++ Programming Language, 2nd ed. Addison-Wesley, Reading, Massachusetts, 1991, reprinted with corrections January 1994, ISBN 0-201-53992-6.
216
216
217
-
Unicode Consortium, The. The Unicode Standard, Version 15.1.0. South San Francisco, CA: The Unicode Consortium, 2023. ISBN 978-1-936213-33-7.
217
+
Unicode Consortium, The. The Unicode Standard, Version 16.0.0. South San Francisco: The Unicode Consortium, 2024. ISBN 978-1-936213-34-4.
Copy file name to clipboardExpand all lines: chapter-12.txt
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ The chapter continues with a specification of the procedures for creation of new
34
34
35
35
The Java Virtual Machine starts execution by invoking the method main of some specified class or interface, passing it a single argument which is an array of strings. In the examples in this specification, this first class is typically called Test.
36
36
37
-
The precise semantics of Java Virtual Machine startup are given in Chapter 5 of The Java Virtual Machine Specification, Java SE 23 Edition. Here we present an overview of the process from the viewpoint of the Java programming language.
37
+
The precise semantics of Java Virtual Machine startup are given in Chapter 5 of The Java Virtual Machine Specification, Java SE 24 Edition. Here we present an overview of the process from the viewpoint of the Java programming language.
38
38
39
39
The manner in which the initial class or interface is specified to the Java Virtual Machine is beyond the scope of this specification, but it is typical, in host environments that use command lines, for the fully qualified name of the class or interface to be specified as a command line argument and for following command line arguments to be used as strings to be provided as the argument to the method main.
40
40
@@ -99,9 +99,9 @@ public static void main(String... args)
99
99
100
100
Loading refers to the process of finding the binary form of a class or interface with a particular name, perhaps by computing it on the fly, but more typically by retrieving a binary representation previously computed from source code by a Java compiler, and constructing, from that binary form, a Class object to represent the class or interface (§1.4).
101
101
102
-
The precise semantics of loading are given in Chapter 5 of The Java Virtual Machine Specification, Java SE 23 Edition. Here we present an overview of the process from the viewpoint of the Java programming language.
102
+
The precise semantics of loading are given in Chapter 5 of The Java Virtual Machine Specification, Java SE 24 Edition. Here we present an overview of the process from the viewpoint of the Java programming language.
103
103
104
-
The binary representation of a class or interface is normally the class file format described in Chapter 4 of The Java Virtual Machine Specification, Java SE 23 Edition, but other representations are possible, provided they meet the requirements specified in §13.1.
104
+
The binary representation of a class or interface is normally the class file format described in Chapter 4 of The Java Virtual Machine Specification, Java SE 24 Edition, but other representations are possible, provided they meet the requirements specified in §13.1.
105
105
106
106
12.2.1. The Loading Process
107
107
@@ -129,13 +129,13 @@ If a class loader L1 delegates loading of a class or interface C to another load
129
129
130
130
A malicious class loader could violate these properties. However, it could not undermine the security of the type system, because the Java Virtual Machine guards against this.
131
131
132
-
For further discussion of these issues, see The Java Virtual Machine Specification, Java SE 23 Edition and the paper Dynamic Class Loading in the Java Virtual Machine, by Sheng Liang and Gilad Bracha, in Proceedings of OOPSLA '98, published as ACM SIGPLAN Notices, Volume 33, Number 10, October 1998, pages 36-44. A basic principle of the design of the Java programming language is that the run-time type system cannot be subverted by code written in the Java programming language, not even by implementations of such otherwise sensitive system classes as ClassLoader and SecurityManager.
132
+
For further discussion of these issues, see The Java Virtual Machine Specification, Java SE 24 Edition and the paper Dynamic Class Loading in the Java Virtual Machine, by Sheng Liang and Gilad Bracha, in Proceedings of OOPSLA '98, published as ACM SIGPLAN Notices, Volume 33, Number 10, October 1998, pages 36-44. A basic principle of the design of the Java programming language is that the run-time type system cannot be subverted by code written in the Java programming language, not even by implementations of sensitive system classes such as ClassLoader.
133
133
134
134
12.3. Linking of Classes and Interfaces
135
135
136
136
Linking is the process of taking a binary form of a class or interface and combining it into the run-time state of the Java Virtual Machine, so that it can be executed. A class or interface is always loaded before it is linked.
137
137
138
-
The precise semantics of linking are given in Chapter 5 of The Java Virtual Machine Specification, Java SE 23 Edition. Here we present an overview of the process from the viewpoint of the Java programming language.
138
+
The precise semantics of linking are given in Chapter 5 of The Java Virtual Machine Specification, Java SE 24 Edition. Here we present an overview of the process from the viewpoint of the Java programming language.
139
139
140
140
Three different activities are involved in linking: verification, preparation, and resolution of symbolic references.
141
141
@@ -469,7 +469,7 @@ This shows that the invocation of printThree in the constructor for class Super
469
469
470
470
12.6. Finalization of Class Instances
471
471
472
-
As of Java SE 23, the Java SE Platform Specification allows finalization of class instances to be disabled in an implementation of the Java SE Platform, in anticipation of the removal of finalization from a future release of the Java SE Platform.
472
+
As of Java SE 24, the Java SE Platform Specification allows finalization of class instances to be disabled in an implementation of the Java SE Platform, in anticipation of the removal of finalization from a future release of the Java SE Platform.
473
473
474
474
The class Object has a protected method called finalize; this method can be overridden by other classes. The particular definition of finalize that can be invoked for an object is called the finalizer of that object. Before the storage for an object is reclaimed by the garbage collector, the Java Virtual Machine will invoke the finalizer of that object.
Copy file name to clipboardExpand all lines: chapter-13.txt
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ This chapter first specifies some properties that any binary format for the Java
78
78
79
79
13.1. The Form of a Binary
80
80
81
-
Programs must be compiled either into the class file format specified by The Java Virtual Machine Specification, Java SE 23 Edition, or into a representation that can be mapped into that format by a class loader written in the Java programming language.
81
+
Programs must be compiled either into the class file format specified by The Java Virtual Machine Specification, Java SE 24 Edition, or into a representation that can be mapped into that format by a class loader written in the Java programming language.
82
82
83
83
A class file corresponding to a class or interface declaration must have certain properties. A number of these properties are specifically chosen to support source code transformations that preserve binary compatibility. The required properties are:
84
84
@@ -337,7 +337,7 @@ Example 13.4.4-1. Changing A Superclass
337
337
338
338
Suppose that the following test program:
339
339
340
-
class Hyper { char h = 'h'; }
340
+
class Hyper { char h = 'h'; }
341
341
class Super extends Hyper { char s = 's'; }
342
342
class Test extends Super {
343
343
public static void printH(Hyper h) {
@@ -508,8 +508,8 @@ class Test extends points.Point {
Copy file name to clipboardExpand all lines: chapter-14.txt
+21-22Lines changed: 21 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -309,7 +309,7 @@ The following code illustrates the typing of variables declared with var:
309
309
310
310
var a = 1; // a has type 'int'
311
311
var b = java.util.List.of(1, 2); // b has type 'List<Integer>'
312
-
var c = "x".getClass(); // c has type 'Class<? extends String>'
312
+
var c = "x".getClass(); // c has type 'Class<? extends String>'
313
313
// (see JLS 15.12.2.6)
314
314
var d = new Object() {}; // d has the type of the anonymous class
315
315
var e = (CharSequence & Comparable<String>) "x";
@@ -457,7 +457,7 @@ class Test {
457
457
while (n-- != 0) {
458
458
if (v1[j++] != v2[k++])
459
459
continue i;
460
-
}
460
+
}
461
461
return i - offset;
462
462
}
463
463
return -1;
@@ -566,22 +566,22 @@ This rule is motivated by a case that demands special treatment. Recall that the
566
566
567
567
public class Foo {
568
568
public static void main(String[] args) {
569
-
Baz.testAsserts();
569
+
Baz.testAsserts();
570
570
// Will execute after Baz is initialized.
571
571
}
572
572
}
573
573
class Bar {
574
574
static {
575
-
Baz.testAsserts();
575
+
Baz.testAsserts();
576
576
// Will execute before Baz is initialized!
577
577
}
578
578
}
579
579
class Baz extends Bar {
580
580
static void testAsserts() {
581
581
boolean enabled = false;
582
582
assert enabled = true;
583
-
System.out.println("Asserts " +
584
-
(enabled ? "enabled" : "disabled"));
583
+
System.out.println("Asserts " +
584
+
(enabled ? "enabled" : "disabled"));
585
585
}
586
586
}
587
587
@@ -686,35 +686,35 @@ If a case label with more than one case pattern could declare pattern variables,
686
686
687
687
688
688
Object obj = ...;
689
-
switch (obj) {
690
-
case Integer i, Boolean b -> {
689
+
switch (obj) {
690
+
case Integer i, Boolean b -> {
691
691
... // Error! Is i or b initialized?
692
-
}
693
-
...
692
+
}
693
+
...
694
694
}
695
695
696
696
697
697
Even if only one of the case patterns declares a pattern variable, it would still not be clear whether the variable was initialized or not; for example:
698
698
699
699
700
700
Object obj = ...;
701
-
switch (obj) {
702
-
case Integer i, Boolean _ -> {
701
+
switch (obj) {
702
+
case Integer i, Boolean _ -> {
703
703
... // Error! Is i initialized?
704
-
}
705
-
...
704
+
}
705
+
...
706
706
}
707
707
708
708
709
709
The following does not result in a compile-time error:
710
710
711
711
712
712
Object obj = ...;
713
-
switch (obj) {
714
-
case Integer _, Boolean _ -> {
713
+
switch (obj) {
714
+
case Integer _, Boolean _ -> {
715
715
... // Matches both an Integer and a Boolean
716
-
}
717
-
...
716
+
}
717
+
...
718
718
}
719
719
720
720
@@ -815,7 +815,7 @@ A case label with more than one case pattern is dominated if any one of these pa
815
815
case Integer _, String _ -> // Error - dominated!
816
816
System.out.println("An Integer or a String");
817
817
...
818
-
}
818
+
}
819
819
820
820
821
821
A case label with a case constant c is dominated if one of the following holds:
@@ -976,7 +976,7 @@ static int testEnumExhaustive(E e) {
976
976
case H -> 2; // No default required!
977
977
};
978
978
}
979
-
979
+
980
980
981
981
982
982
The type T names an abstract sealed class or sealed interface C and for every permitted direct subclass or subinterface D of C, one of the following two conditions holds:
@@ -987,7 +987,6 @@ There is a type U that both names D and is a subtype of T, and P covers U.
987
987
988
988
A default label is permitted, but not required, in the case where the switch block exhausts all the permitted direct subclasses and subinterfaces of an abstract sealed class or sealed interface. For example:
0 commit comments