1. Trang chủ
  2. » Công Nghệ Thông Tin

Java SE 8 edition for everyone Java SE 8 edition for everyone Java SE 8 edtion for everyone

780 1,5K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 780
Dung lượng 3,76 MB

Nội dung

THE Java® programming language is a generalpurpose, concurrent, classbased, objectoriented language. It is designed to be simple enough that manyprogrammers can achieve fluency in the language. The Java programming languageis related to C and C++ but is organized rather differently, with a number of aspectsof C and C++ omitted and a few ideas from other languages included. It is intendedto be a production language, not a research language, and so, as C. A. R. Hoaresuggested in his classic paper on language design, the design has avoided includingnew and untested features

The Java® Language Specification Java SE Edition James Gosling Bill Joy Guy Steele Gilad Bracha Alex Buckley 2014-03-03 Specification: JSR-337 Java® SE Release Contents ("Specification") Version: Status: Final Release Release: March 2014 Copyright © 1997, 2014, Oracle America, Inc and/or its affiliates All rights reserved 500 Oracle Parkway, Redwood City, California 94065, U.S.A Oracle and Java are registered trademarks of Oracle and/or its affiliates Other names may be trademarks of their respective owners The Specification provided herein is provided to you only under the Limited License Grant included herein as Appendix A Please see Appendix A, Limited License Grant To Maurizio, with deepest thanks Table of Contents Preface to the Java SE Edition xix Introduction 1.1 1.2 1.3 1.4 1.5 1.6 Organization of the Specification Example Programs Notation Relationship to Predefined Classes and Interfaces Feedback References Grammars 2.1 2.2 2.3 2.4 Context-Free Grammars The Lexical Grammar The Syntactic Grammar 10 Grammar Notation 10 Lexical Structure 15 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 Unicode 15 Lexical Translations 16 Unicode Escapes 17 Line Terminators 19 Input Elements and Tokens 19 White Space 20 Comments 21 Identifiers 22 Keywords 24 Literals 24 3.10.1 Integer Literals 25 3.10.2 Floating-Point Literals 31 3.10.3 Boolean Literals 34 3.10.4 Character Literals 34 3.10.5 String Literals 35 3.10.6 Escape Sequences for Character and String Literals 37 3.10.7 The Null Literal 38 Separators 38 Operators 39 v The Java® Language Specification Types, Values, and Variables 41 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 4.12 The Kinds of Types and Values 41 Primitive Types and Values 42 4.2.1 Integral Types and Values 43 4.2.2 Integer Operations 43 4.2.3 Floating-Point Types, Formats, and Values 45 4.2.4 Floating-Point Operations 48 4.2.5 The boolean Type and boolean Values 51 Reference Types and Values 52 4.3.1 Objects 53 4.3.2 The Class Object 56 4.3.3 The Class String 56 4.3.4 When Reference Types Are the Same 57 Type Variables 57 Parameterized Types 59 4.5.1 Type Arguments of Parameterized Types 60 4.5.2 Members and Constructors of Parameterized Types 63 Type Erasure 64 Reifiable Types 65 Raw Types 66 Intersection Types 70 Subtyping 71 4.10.1 Subtyping among Primitive Types 71 4.10.2 Subtyping among Class and Interface Types 72 4.10.3 Subtyping among Array Types 73 4.10.4 Least Upper Bound 73 Where Types Are Used 76 Variables 80 4.12.1 Variables of Primitive Type 81 4.12.2 Variables of Reference Type 81 4.12.3 Kinds of Variables 83 4.12.4 final Variables 85 4.12.5 Initial Values of Variables 87 4.12.6 Types, Classes, and Interfaces 88 Conversions and Contexts 91 5.1 vi Kinds of Conversion 94 5.1.1 Identity Conversion 94 5.1.2 Widening Primitive Conversion 94 5.1.3 Narrowing Primitive Conversion 96 5.1.4 Widening and Narrowing Primitive Conversion 99 5.1.5 Widening Reference Conversion 99 5.1.6 Narrowing Reference Conversion 99 5.1.7 Boxing Conversion 100 5.1.8 Unboxing Conversion 102 5.1.9 Unchecked Conversion 103 5.1.10 Capture Conversion 103 The Java® Language Specification 5.2 5.3 5.4 5.5 5.6 5.1.11 String Conversion 105 5.1.12 Forbidden Conversions 106 5.1.13 Value Set Conversion 106 Assignment Contexts 107 Invocation Contexts 112 String Contexts 114 Casting Contexts 114 5.5.1 Reference Type Casting 118 5.5.2 Checked Casts and Unchecked Casts 122 5.5.3 Checked Casts at Run Time 123 Numeric Contexts 125 5.6.1 Unary Numeric Promotion 125 5.6.2 Binary Numeric Promotion 126 Names 129 6.1 6.2 6.3 6.4 6.5 6.6 6.7 Declarations 130 Names and Identifiers 137 Scope of a Declaration 139 Shadowing and Obscuring 142 6.4.1 Shadowing 144 6.4.2 Obscuring 147 Determining the Meaning of a Name 148 6.5.1 Syntactic Classification of a Name According to Context 149 6.5.2 Reclassification of Contextually Ambiguous Names 152 6.5.3 Meaning of Package Names 154 6.5.3.1 Simple Package Names 155 6.5.3.2 Qualified Package Names 155 6.5.4 Meaning of PackageOrTypeNames 155 6.5.4.1 Simple PackageOrTypeNames 155 6.5.4.2 Qualified PackageOrTypeNames 155 6.5.5 Meaning of Type Names 155 6.5.5.1 Simple Type Names 156 6.5.5.2 Qualified Type Names 156 6.5.6 Meaning of Expression Names 156 6.5.6.1 Simple Expression Names 156 6.5.6.2 Qualified Expression Names 157 6.5.7 Meaning of Method Names 160 6.5.7.1 Simple Method Names 160 Access Control 161 6.6.1 Determining Accessibility 162 6.6.2 Details on protected Access 166 6.6.2.1 Access to a protected Member 167 6.6.2.2 Qualified Access to a protected Constructor 167 Fully Qualified Names and Canonical Names 169 Packages 173 7.1 Package Members 173 vii The Java® Language Specification 7.2 7.3 7.4 7.5 7.6 Host Support for Packages 175 Compilation Units 177 Package Declarations 178 7.4.1 Named Packages 178 7.4.2 Unnamed Packages 179 7.4.3 Observability of a Package 179 Import Declarations 180 7.5.1 Single-Type-Import Declarations 180 7.5.2 Type-Import-on-Demand Declarations 183 7.5.3 Single-Static-Import Declarations 184 7.5.4 Static-Import-on-Demand Declarations 184 Top Level Type Declarations 185 Classes 189 8.1 8.2 8.3 8.4 viii Class Declarations 191 8.1.1 Class Modifiers 191 8.1.1.1 abstract Classes 192 8.1.1.2 final Classes 194 8.1.1.3 strictfp Classes 194 8.1.2 Generic Classes and Type Parameters 194 8.1.3 Inner Classes and Enclosing Instances 197 8.1.4 Superclasses and Subclasses 200 8.1.5 Superinterfaces 202 8.1.6 Class Body and Member Declarations 205 Class Members 206 Field Declarations 211 8.3.1 Field Modifiers 215 8.3.1.1 static Fields 216 8.3.1.2 final Fields 219 8.3.1.3 transient Fields 219 8.3.1.4 volatile Fields 220 8.3.2 Field Initialization 221 8.3.3 Forward References During Field Initialization 222 Method Declarations 225 8.4.1 Formal Parameters 226 8.4.2 Method Signature 230 8.4.3 Method Modifiers 231 8.4.3.1 abstract Methods 232 8.4.3.2 static Methods 233 8.4.3.3 final Methods 234 8.4.3.4 native Methods 235 8.4.3.5 strictfp Methods 235 8.4.3.6 synchronized Methods 235 8.4.4 Generic Methods 237 8.4.5 Method Result 237 8.4.6 Method Throws 238 8.4.7 Method Body 240 The Java® Language Specification 8.4.8 8.5 8.6 8.7 8.8 8.9 Inheritance, Overriding, and Hiding 240 8.4.8.1 Overriding (by Instance Methods) 241 8.4.8.2 Hiding (by Class Methods) 245 8.4.8.3 Requirements in Overriding and Hiding 246 8.4.8.4 Inheriting Methods with Override-Equivalent Signatures 250 8.4.9 Overloading 250 Member Type Declarations 254 8.5.1 Static Member Type Declarations 254 Instance Initializers 255 Static Initializers 255 Constructor Declarations 256 8.8.1 Formal Parameters 257 8.8.2 Constructor Signature 258 8.8.3 Constructor Modifiers 258 8.8.4 Generic Constructors 259 8.8.5 Constructor Throws 259 8.8.6 The Type of a Constructor 259 8.8.7 Constructor Body 259 8.8.7.1 Explicit Constructor Invocations 260 8.8.8 Constructor Overloading 264 8.8.9 Default Constructor 265 8.8.10 Preventing Instantiation of a Class 266 Enum Types 266 8.9.1 Enum Constants 267 8.9.2 Enum Body Declarations 268 8.9.3 Enum Members 271 Interfaces 277 9.1 9.2 9.3 9.4 Interface Declarations 278 9.1.1 Interface Modifiers 278 9.1.1.1 abstract Interfaces 279 9.1.1.2 strictfp Interfaces 279 9.1.2 Generic Interfaces and Type Parameters 279 9.1.3 Superinterfaces and Subinterfaces 280 9.1.4 Interface Body and Member Declarations 282 Interface Members 282 Field (Constant) Declarations 283 9.3.1 Initialization of Fields in Interfaces 285 Method Declarations 286 9.4.1 Inheritance and Overriding 287 9.4.1.1 Overriding (by Instance Methods) 288 9.4.1.2 Requirements in Overriding 289 9.4.1.3 Inheriting Methods with Override-Equivalent Signatures 289 9.4.2 Overloading 290 9.4.3 Interface Method Body 291 ix The Java® Language Specification 9.5 9.6 9.7 9.8 9.9 Member Type Declarations 291 Annotation Types 292 9.6.1 Annotation Type Elements 293 9.6.2 Defaults for Annotation Type Elements 297 9.6.3 Repeatable Annotation Types 298 9.6.4 Predefined Annotation Types 302 9.6.4.1 @Target 302 9.6.4.2 @Retention 303 9.6.4.3 @Inherited 304 9.6.4.4 @Override 304 9.6.4.5 @SuppressWarnings 305 9.6.4.6 @Deprecated 306 9.6.4.7 @SafeVarargs 307 9.6.4.8 @Repeatable 308 9.6.4.9 @FunctionalInterface 308 Annotations 308 9.7.1 Normal Annotations 309 9.7.2 Marker Annotations 311 9.7.3 Single-Element Annotations 312 9.7.4 Where Annotations May Appear 313 9.7.5 Multiple Annotations Of The Same Type 318 Functional Interfaces 319 Function Types 323 10 Arrays 329 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 Array Types 330 Array Variables 330 Array Creation 332 Array Access 332 Array Store Exception 333 Array Initializers 335 Array Members 336 Class Objects for Arrays 338 An Array of Characters is Not a String 339 11 Exceptions 341 11.1 11.2 11.3 x The Kinds and Causes of Exceptions 342 11.1.1 The Kinds of Exceptions 342 11.1.2 The Causes of Exceptions 343 11.1.3 Asynchronous Exceptions 344 Compile-Time Checking of Exceptions 345 11.2.1 Exception Analysis of Expressions 346 11.2.2 Exception Analysis of Statements 347 11.2.3 Exception Checking 348 Run-Time Handling of an Exception 350 INDEX method reference expressions, 532 normal and abrupt completion of statements, type comparison operator instanceof, 566 408 static initializers, 255 run-time evaluation of relational operators, 564 constant expressions, 606 relationship to predefined classes and array access expressions, 493 interfaces, array access, 333 remainder operator %, 555 evaluation order for other expressions, 473 normal and abrupt completion of evaluation, evaluate operands before operation, 470 floating-point operations, 49 integer operations, 44 normal and abrupt completion of evaluation, 467 repeatable annotation types, 298 @Repeatable, 308 evolution of annotation types, 405 multiple annotations of the same type, 318 requirements in overriding, 289 variables of reference type, 81 467, 467 run-time evaluation of array creation expressions, 489 evaluation order for other expressions, 473 initial values of variables, 87 kinds of variables, 84 normal and abrupt completion of evaluation, 466, 467 run-time evaluation of class instance creation expressions, 485 compile-time checking of Exceptions, 345 evaluation order for other expressions, 473 normal and abrupt completion of evaluation, method throws, 239 466 requirements in overriding and hiding, 246 requirements in overriding, 289, 289, 289 type of a lambda expression, 604 type of a method reference, 540 variables of reference type, 81 resolution, 677 invocation applicability inference, 681 invocation type inference, 683 resolution of symbolic references, 361 link test: verify, prepare, (optionally) resolve, 357 return statement, 438 break, continue, return, and throw statements, 626 constructor body, 260, 260 instance initializers, 255 interface method body, 291 method body, 240 746 throw statement, 441 run-time evaluation of lambda expressions, 605 creation of new class instances, 368 evaluation order for other expressions, 473 normal and abrupt completion of evaluation, 466 run-time evaluation of method invocation, 521 evaluation order for other expressions, 473 overloading, 251 run-time evaluation of method references, 541 creation of new class instances, 368 evaluation order for other expressions, 473 normal and abrupt completion of evaluation, 466 run-time handling of an exception, 350 INDEX expressions and run-time checks, 466 try statement, 444 initial values of variables, 87 try-with-resources, 450 kinds of variables, 84 type variables, 58 throw statement, 439 semantics of final fields, 656 try statement, 445 separators, 38 lexical grammar, shadowing, 144 compile-time step 1: determine class or S scope of a declaration, 139 interface to search, 502 basic for statement, 429 obscuring, 147 class body and member declarations, 206 scope of a declaration, 139 class declarations, 191 class literals, 475 compile-time step 1: determine class or simple expression names, 156 shadowing and obscuring, 142 basic for statement, 429 interface to search, 502 class body and member declarations, 206 enhanced for statement, 432, 432 class declarations, 191 enum constants, 268 enhanced for statement, 432 field declarations, 213 enum constants, 268 formal parameters, 228 forward references during field initialization, field declarations, 213 222 generic classes and type parameters, 195 generic classes and type parameters, 195 generic constructors, 259 generic constructors, 259 import declarations, 180 generic interfaces and type parameters, 280 interface declarations, 278 generic methods, 237 lambda parameters, 599 import declarations, 180 local class declarations, 409 interface body and member declarations, 282 local variable declarators and types, 412 interface declarations, 278 member type declarations, 254 lambda parameters, 599 method declarations, 226 local class declarations, 409 named packages, 178 local variable declarators and types, 412 top level type declarations, 185 member type declarations, 254 try statement, 444 method declarations, 226 formal parameters, 228 try-with-resources, 450 named packages, 178 reclassification of contextually ambiguous shared variables, 642 names, 152, 153 shift operators, 563 happens-before order, 646 simple package names, 155 constant expressions, 606 top level type declarations, 185 integer operations, 43 747 INDEX unary numeric promotion, 126 simple assignment operator =, 583 statements, 412 static fields, 216, 395 assignment contexts, 109 generic classes and type parameters, 195 expressions and run-time checks, 465, 466 normal and abrupt completion of evaluation, kinds of variables, 83, 83 467, 467 simple expression names, 156 when initialization occurs, 363 static initializers, 255, 402 constant expressions, 607 class body and member declarations, 206 definite assignment and static initializers, field access expressions, 496 630 simple method names, 160 method declarations, 226 exception checking, 348 final fields, 219 simple package names, 155 generic classes and type parameters, 195 simple packageortypenames, 155 inner classes and enclosing instances, 197 simple type names, 156 return statement, 438 single-element annotations, 312 simple expression names, 157 annotation type elements, 295 annotations, 308 single-static-import declarations, 184 static initializers, 402 throw statement, 441 static member type declarations, 254 declarations, 130, 131 anonymous class declarations, 487 identify potentially applicable methods, 510 class modifiers, 191 import declarations, 180 reclassification of contextually ambiguous generic classes and type parameters, 195 names, 153, 153 interface modifiers, 278, 279 static methods, 233, 400 scope of a declaration, 139 generic classes and type parameters, 195 simple method names, 160 interface method declarations, 404 single-type-import declarations, 181 syntactic classification of a name according simple expression names, 157 to context, 150 single-type-import declarations, 180 declarations, 130, 131 import declarations, 180 reclassification of contextually ambiguous static-import-on-demand declarations, 184 declarations, 130, 131 identify potentially applicable methods, 510 import declarations, 180 reclassification of contextually ambiguous names, 153, 153 names, 153 scope of a declaration, 139 scope of a declaration, 139 simple method names, 160 syntactic classification of a name according single-static-import declarations, 184 syntactic classification of a name according to context, 150 sleep and yield, 638 748 to context, 150 type-import-on-demand declarations, 183 strictfp classes, 194 INDEX fp-strict expressions, 464 strictfp interfaces, 279 fp-strict expressions, 464 strictfp methods, 235 fp-strict expressions, 464 String concatenation operator +, 558 subtyping, 71 assignment contexts, 108 checked casts and unchecked casts, 122 choosing the most specific method, 516 constraint formulas, 663 invocation contexts, 113 boolean type and boolean values, 51 method throws, 238 class String, 57 narrowing reference conversion, 99 constructor declarations, 256 parameterized types, 59 creation of new class instances, 368 subtyping constraints, 670 floating-point operations, 48 type arguments of parameterized types, 61, integer operations, 44 normal and abrupt completion of evaluation, 61 466 objects, 53, 55 String contexts, 114 types, classes, and interfaces, 88 String contexts, 114 boolean type and boolean values, 52 String conversion, 105 widening reference conversion, 99 subtyping among array types, 73 array types, 330 subtyping among class and interface types, 72 try statement, 444 subtyping among primitive types, 71 subtyping constraints, 670 superclasses and subclasses, 200 String concatenation operator +, 558 class members, 206 String contexts, 114 class Object, 56 String literals, 35 enum types, 267 class String, 56 final classes, 194 comments, 22 kinds of variables, 83 constant expressions, 606 loading process, 359 subtyping among class and interface types, creation of new class instances, 368 escape sequences for character and String 72 literals, 37 syntactic classification of a name according lexical literals, 475 to context, 150 reference equality operators == and !=, 569 where types are used, 76, 78 unicode, 16 strings, 56 superclasses and superinterfaces, 386 loading process, 359 lexical literals, 475 superinterfaces, 403 literals, 24 verification of the binary representation, 361 objects, 53 String literals, 35, 36 subsequent modification of final fields, 657 superinterfaces, 202, 403 checked casts at run time, 123 class members, 206 749 INDEX synchronized statements, 626 subtyping among class and interface types, 72 superinterfaces and subinterfaces, 281 syntactic classification of a name according synchronized statements, 626 syntactic classification of a name according to context, 149 to context, 150 access control, 161 types, classes, and interfaces, 89 declarations, 132 where types are used, 76, 78 reference types and values, 53 superinterfaces and subinterfaces, 280 syntactic grammar, 10 interface members, 282 compilation units, 177 loading process, 359 subtyping among class and interface types, input elements and tokens, 20 72 lexical translations, 16 syntax, 691 superclasses and subclasses, 202 superinterfaces, 203 syntactic classification of a name according T to context, 150 this, 476 where types are used, 76, 78 switch statement, 421 field initialization, 221, 222 initialization of fields in interfaces, 285 scope of a declaration, 140, 140 instance initializers, 255 switch statements, 623 static initializers, 256 switch statements, 623 synchronization, 634 objects, 56 synchronized methods, 235 synchronized statement, 441 volatile fields, 220 synchronization order, 644 static methods, 234 threads and locks, 633 objects, 56 throw statement, 439 throw statement, 439 break, continue, return, and throw statements, 626 actions, 642 causes of Exceptions, 343 interaction with the memory model, 374 exception analysis of statements, 347 synchronized methods, 235, 400 class Object, 56 initial values of variables, 87 synchronization, 634 kinds of variables, 84 normal and abrupt completion of statements, synchronized statement, 442 408, 408 synchronized statement, 441 create frame, synchronize, transfer control, run-time handling of an exception, 350 top level type declarations, 185 530 class instance creation expressions, 479 objects, 56 class modifiers, 191 synchronization, 634 compilation units, 177 750 INDEX determining accessibility, 163 form of a binary, 378 host support for packages, 175 interface modifiers, 279 package members, 173, 174 try-catch-finally statement, 447 try statement, 445 try-finally statement, 447 try statement, 445 try-with-resources, 449 scope of a declaration, 139, 139, 139 @Target, 303 shadowing, 146 final variables, 86 single-static-import declarations, 184 local variable declaration statements, 411 single-type-import declarations, 181 scope of a declaration, 141 syntactic classification of a name according when initialization occurs, 363 transient fields, 219, 395 to context, 151 try statement, 442 try statement, 446 @Target, 303 where types are used, 76 array variables, 331 try-with-resources (basic), 450 compile-time checking of Exceptions, 346 try-with-resources (extended), 453 declarations, 131, 132 type arguments of parameterized types, 60 definite assignment and parameters, 628 capture conversion, 103 exception analysis of statements, 347 checked casts and unchecked casts, 122 expressions and run-time checks, 465, 466 class instance creation expressions, 478, 479 final variables, 86 constraint formulas, 663 initial values of variables, 87 explicit constructor invocations, 261 kinds of variables, 84 method invocation expressions, 501 labeled statements, 415 method reference expressions, 531 method throws, 239 reclassification of contextually ambiguous reference types and values, 53 names, 152 reifiable types, 65 subtyping among class and interface types, run-time handling of an exception, 350 72 scope of a declaration, 141 subtyping constraints, 671 shadowing and obscuring, 142 type equality constraints, 673 shared variables, 642 syntactic classification of a name according types, classes, and interfaces, 89 to context, 151 throw statement, 439, 440, 440 unchecked conversion, 103 where types are used, 77 type comparison operator instanceof, 566 try statements, 626 expressions and run-time checks, 465 where types are used, 76, 78 try statements, 626 objects, 55 syntactic classification of a name according try-catch statement, 446 to context, 151 try statement, 445 where types are used, 77, 78 751 INDEX type compatibility constraints, 670 invocation type inference, 684, 685 type equality constraints, 672 lambda parameters, 598 type erasure, 64 assignment contexts, 109 type of a method reference, 539 checked exception constraints, 674 cast expressions, 551 type of an expression, 463 checked casts and unchecked casts, 123 type variables, 57 checked casts at run time, 123 class literals, 475 choosing the most specific method, 517 field declarations, 392 class type parameters, 387 compile-time step 3: is the chosen method generic classes and type parameters, 194 appropriate?, 520 generic interfaces and type parameters, 279 constructor Signature, 258 create frame, synchronize, transfer control, generic methods, 237 generic constructors, 259 530 intersection types, 70 method and constructor formal parameters, declarations, 131 398 evaluate arguments, 524 method result type, 398 field declarations, 392 reference types and values, 52 form of a binary, 380, 381, 382 type erasure, 64 invocation contexts, 114 method and constructor formal parameters, types, classes, and interfaces, 89 398 where types are used, 77 type-import-on-demand declarations, 183 method and constructor type parameters, 397 declarations, 130 method result type, 398 method Signature, 230 import declarations, 180 reclassification of contextually ambiguous raw types, 66 names, 153 requirements in overriding and hiding, 246 scope of a declaration, 139 type variables, 58 shadowing, 146 type inference, 661 compile-time step 2: determine method Signature, 505 generic constructors, 259 generic methods, 237 type of a constructor, 259 members and constructors of parameterized types, 63 type of a lambda expression, 603 static-import-on-demand declarations, 185 syntactic classification of a name according to context, 152 types, 41 capture conversion, 103 lexical literals, 475 literals, 24 null literal, 38 throw statement, 440 checked exception constraints, 673 types, classes, and interfaces, 88 expression compatibility constraints, 666 types, values, and variables, 41 752 INDEX U equality operators, 567 unary minus operator -, 549 constant expressions, 606 floating-point operations, 48 integer literals, 30, 30 integer operations, 43 unary numeric promotion, 126 unary numeric promotion, 125 array access, 333 array access expressions, 493 array creation expressions, 489 bitwise complement operator ~, 550 numeric contexts, 125 shift operators, 563 unary minus operator -, 549 unary plus operator +, 549 unary operators, 546 final variables, 86 unary plus operator +, 549 constant expressions, 606 floating-point operations, 48 integer operations, 43 unary numeric promotion, 126 unboxing conversion, 102 additive operators, 558, 558 array creation expressions, 489 assert statement, 420 assignment contexts, 108 binary numeric promotion, 127 bitwise complement operator ~, 550 boolean equality operators == and !=, 568 boolean logical operators &, ^, and |, 571 casting contexts, 115, 115, 115 conditional operator ? :, 574, 580 conditional-and operator &&, 572, 572 conditional-or operator ||, 572, 572 floating-point operations, 49 if-then statement, 417 if-then-else statement, 418 integer bitwise operators &, ^, and |, 570 integer operations, 44 invocation contexts, 113 iteration of for statement, 429 logical complement operator !, 550 multiplicative operators, 552 numeric contexts, 125 numerical comparison operators =, 564 numerical equality operators == and !=, 567 postfix decrement operator , 546 postfix increment operator ++, 545 prefix decrement operator , 548 prefix increment operator ++, 548 switch statement, 423 unary minus operator -, 549 unary numeric promotion, 125, 125 unary plus operator +, 549 while statement, 425 unchecked conversion, 103 @SafeVarargs, 307 assignment contexts, 108 casting contexts, 115, 115 invocation contexts, 113 method result, 238 type compatibility constraints, 670 variables of reference type, 81 unicode, 15 character literals, 34 lexical grammar, primitive types and values, 42 unicode escapes, 17 unicode escapes, 17 statement, 426 753 INDEX escape sequences for character and String literals, 38 input elements and tokens, 19 lexical translations, 16 unicode, 16 unloading of classes and interfaces, 375 kinds of variables, 83 variables, 81 verification of the binary representation, 360 link test: verify, prepare, (optionally) resolve, 356 volatile fields, 220 happens-before order, 646 synchronization order, 644 unnamed packages, 179 compilation units, 177 unreachable statements, 454 final fields and static constant variables, 393 instance initializers, 255 lambda body, 600 static initializers, 255 W wait, 635 happens-before order, 645 wait sets and notification, 634 class Object, 56 uses of inference, 679 well-formed executions, 649 V what binary compatibility is and is not, 384 executions, 648 when initialization occurs, 363 value set conversion, 106 assignment contexts, 109 binary numeric promotion, 127 final variables, 86 initialize test: execute initializers, 357 when reference types are the same, 57 casting contexts, 115 checked casts at run time, 123 compound assignment operators, 589, 591 create frame, synchronize, transfer control, constraint formulas, 663 530 type equality constraints, 672 where annotations may appear, 313 evaluation, denotation, and result, 461 annotation types, 292 floating-point types, formats, and values, 45 annotations, 308 fp-strict expressions, 464 class modifiers, 191 invocation contexts, 113 constructor modifiers, 258 simple assignment operator =, 584, 585 enum constants, 268 unary minus operator -, 549 field (constant) declarations, 283 unary numeric promotion, 126 field modifiers, 215 variables, 80 evaluation, denotation, and result, 461 formal parameters, 228 generic classes and type parameters, 195 variables of primitive type, 81 generic interfaces and type parameters, 280 variables of reference type, 81 interface modifiers, 278 @SafeVarargs, 307 lambda parameters, 599 type of an expression, 463 local variable declaration statements, 411 754 INDEX method declarations, 286 method modifiers, 231 named packages, 178 where types are used, 76 @Target, 303 lexical translations, 17 syntactic classification of a name according to context, 150 where annotations may appear, 313 while statement, 425 boolean type and boolean values, 51 while statements, 623 while statements, 623 white space, 20 input elements and tokens, 20 lexical grammar, lexical translations, 16 widening and narrowing primitive conversion, 99 casting contexts, 115 widening primitive conversion, 94 assignment contexts, 107 binary numeric promotion, 127 casting contexts, 115, 115 invocation contexts, 112, 113 numeric contexts, 125 unary numeric promotion, 125, 125 widening and narrowing primitive conversion, 99 widening reference conversion, 99 assignment contexts, 107 casting contexts, 115, 115 floating-point operations, 48 integer operations, 44 invocation contexts, 113, 113 word tearing, 659 write-protected fields, 658 755 Appendix A Limited License Grant Specification: JSR-337 Java® SE Release Contents ("Specification") Version: Status: Final Release Release: March 2014 Copyright © 1997, 2014, Oracle America, Inc and/or its affiliates All rights reserved 500 Oracle Parkway, Redwood City, California 94065, U.S.A LIMITED LICENSE GRANTS License for Evaluation Purposes Oracle hereby grants you a fully-paid, non-exclusive, non-transferable, worldwide, limited license (without the right to sublicense), under Oracle's applicable intellectual property rights to view, download, use and reproduce the Specification only for the purpose of internal evaluation This includes (i) developing applications intended to run on an implementation of the Specification, provided that such applications not themselves implement any portion(s) of the Specification, and (ii) discussing the Specification with any third party; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss the Specification provided that such excerpts not in the aggregate constitute a significant portion of the Specification License for the Distribution of Compliant Implementations Oracle also grants you a perpetual, non-exclusive, non-transferable, worldwide, fully paid-up, royalty free, limited license (without the right to sublicense) under any applicable copyrights or, subject to the provisions of subsection below, patent rights it may have covering the Specification to create and/or distribute an Independent Implementation of the Specification that: (a) fully implements the Specification including all its required interfaces and functionality; (b) does not modify, subset, superset or otherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces, fields or methods within the Licensor Name Space other than those required/authorized by the Specification or Specifications being implemented; and (c) passes the Technology Compatibility Kit (including satisfying the requirements of the applicable TCK Users Guide) for such Specification ("Compliant Implementation") In addition, the foregoing license is expressly conditioned on your not acting outside its scope No license 757 LIMITED LICENSE GRANT is granted hereunder for any other purpose (including, for example, modifying the Specification, other than to the extent of your fair use rights, or distributing the Specification to third parties) Also, no right, title, or interest in or to any trademarks, service marks, or trade names of Oracle or Oracle's licensors is granted hereunder Java, and Java-related logos, marks and names are trademarks or registered trademarks of Oracle in the U.S and other countries Pass-through Conditions You need not include limitations (a)-(c) from the previous paragraph or any other particular "pass through" requirements in any license You grant concerning the use of your Independent Implementation or products derived from it However, except with respect to Independent Implementations (and products derived from them) that satisfy limitations (a)-(c) from the previous paragraph, You may neither: (a) grant or otherwise pass through to your licensees any licenses under Oracle's applicable intellectual property rights; nor (b) authorize your licensees to make any claims concerning their implementation's compliance with the Specification in question Reciprocity Concerning Patent Licenses a With respect to any patent claims covered by the license granted under subparagraph above that would be infringed by all technically feasible implementations of the Specification, such license is conditioned upon your offering on fair, reasonable and non-discriminatory terms, to any party seeking it from You, a perpetual, non-exclusive, non-transferable, worldwide license under Your patent rights which are or would be infringed by all technically feasible implementations of the Specification to develop, distribute and use a Compliant Implementation b With respect to any patent claims owned by Oracle and covered by the license granted under subparagraph 2, whether or not their infringement can be avoided in a technically feasible manner when implementing the Specification, such license shall terminate with respect to such claims if You initiate a claim against Oracle that it has, in the course of performing its responsibilities as the Specification Lead, induced any other entity to infringe Your patent rights c Also with respect to any patent claims owned by Oracle and covered by the license granted under subparagraph above, where the infringement of such claims can be avoided in a technically feasible manner when implementing the Specification such license, with respect to such claims, shall terminate if You initiate a claim against Oracle that its making, having made, using, offering to sell, selling or importing a Compliant Implementation infringes Your patent rights Definitions For the purposes of this Agreement: "Independent Implementation" shall mean an implementation of the Specification that neither derives from any 758 LIMITED LICENSE GRANT of Oracle's source code or binary code materials nor, except with an appropriate and separate license from Oracle, includes any of Oracle's source code or binary code materials; "Licensor Name Space" shall mean the public class or interface declarations whose names begin with "java", "javax", "com.sun" or their equivalents in any subsequent naming convention adopted by Oracle through the Java Community Process, or any recognized successors or replacements thereof; and "Technology Compatibility Kit" or "TCK" shall mean the test suite and accompanying TCK User's Guide provided by Oracle which corresponds to the Specification and that was available either (i) from Oracle 120 days before the first release of Your Independent Implementation that allows its use for commercial purposes, or (ii) more recently than 120 days from such release but against which You elect to test Your implementation of the Specification This Agreement will terminate immediately without notice from Oracle if you breach the Agreement or act outside the scope of the licenses granted above DISCLAIMER OF WARRANTIES THE SPECIFICATION IS PROVIDED "AS IS" ORACLE MAKES NO REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT (INCLUDING AS A CONSEQUENCE OF ANY PRACTICE OR IMPLEMENTATION OF THE SPECIFICATION), OR THAT THE CONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE This document does not represent any commitment to release or implement any portion of the Specification in any product In addition, the Specification could include technical inaccuracies or typographical errors LIMITATION OF LIABILITY TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL ORACLE OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED IN ANY WAY TO YOUR HAVING, IMPLEMENTING OR OTHERWISE USING THE SPECIFICATION, EVEN IF ORACLE AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES You will indemnify, hold harmless, and defend Oracle and its licensors from any claims arising or resulting from: (i) your use of the Specification; (ii) the use or distribution of your Java application, applet and/or implementation; and/or (iii) 759 LIMITED LICENSE GRANT any claims that later versions or releases of any Specification furnished to you are incompatible with the Specification provided to you under this license RESTRICTED RIGHTS LEGEND U.S Government: If this Specification is being acquired by or on behalf of the U.S Government or by a U.S Government prime contractor or subcontractor (at any tier), then the Government's rights in the Software and accompanying documentation shall be only as set forth in this license; this is in accordance with 48 C.F.R 227.7201 through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R 2.101 and 12.212 (for non-DoD acquisitions) REPORT If you provide Oracle with any comments or suggestions concerning the Specification ("Feedback"), you hereby: (i) agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Oracle a perpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiple levels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose GENERAL TERMS Any action related to this Agreement will be governed by California law and controlling U.S federal law The U.N Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply The Specification is subject to U.S export control laws and may be subject to export or import regulations in other countries Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has the responsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee This Agreement is the parties' entire agreement relating to its subject matter It supersedes all prior or contemporaneous oral or written communications, proposals, conditions, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement No modification to this Agreement will be binding, unless in writing and signed by an authorized representative of each party 760 ... Declarations 185 Classes 189 8. 1 8. 2 8. 3 8. 4 viii Class Declarations 191 8. 1.1 Class Modifiers 191 8. 1.1.1 abstract Classes 192 8. 1.1.2 final Classes 194 8. 1.1.3 strictfp Classes 194 8. 1.2 Generic Classes... 8. 8.1 Formal Parameters 257 8. 8.2 Constructor Signature 2 58 8 .8. 3 Constructor Modifiers 2 58 8 .8. 4 Generic Constructors 259 8. 8.5 Constructor Throws 259 8. 8.6 The Type of a Constructor 259 8. 8.7... Language Specification 8. 4 .8 8.5 8. 6 8. 7 8. 8 8. 9 Inheritance, Overriding, and Hiding 240 8. 4 .8. 1 Overriding (by Instance Methods) 241 8. 4 .8. 2 Hiding (by Class Methods) 245 8. 4 .8. 3 Requirements in

Ngày đăng: 11/04/2017, 17:30

TỪ KHÓA LIÊN QUAN