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

Cấu trúc

  • The Java® Language Specification

  • Table of Contents

  • Preface to the Java SE 8 Edition

  • 1. Introduction

    • 1.1. Organization of the Specification

    • 1.2. Example Programs

    • 1.3. Notation

    • 1.4. Relationship to Predefined Classes and Interfaces

    • 1.5. Feedback

    • 1.6. References

      • Bibliography

  • 2. Grammars

    • 2.1. Context-Free Grammars

    • 2.2. The Lexical Grammar

    • 2.3. The Syntactic Grammar

    • 2.4. Grammar Notation

  • 3. Lexical Structure

    • 3.1. Unicode

    • 3.2. Lexical Translations

    • 3.3. Unicode Escapes

    • 3.4. Line Terminators

    • 3.5. Input Elements and Tokens

    • 3.6. White Space

    • 3.7. Comments

    • 3.8. Identifiers

    • 3.9. Keywords

    • 3.10. Literals

      • 3.10.1. Integer Literals

      • 3.10.2. Floating-Point Literals

      • 3.10.3. Boolean Literals

      • 3.10.4. Character Literals

      • 3.10.5. String Literals

      • 3.10.6. Escape Sequences for Character and String Literals

      • 3.10.7. The Null Literal

    • 3.11. Separators

    • 3.12. Operators

  • 4. Types, Values, and Variables

    • 4.1. The Kinds of Types and Values

    • 4.2. Primitive Types and Values

      • 4.2.1. Integral Types and Values

      • 4.2.2. Integer Operations

      • 4.2.3. Floating-Point Types, Formats, and Values

      • 4.2.4. Floating-Point Operations

      • 4.2.5. The boolean Type and boolean Values

    • 4.3. Reference Types and Values

      • 4.3.1. Objects

      • 4.3.2. The Class Object

      • 4.3.3. The Class String

      • 4.3.4. When Reference Types Are the Same

    • 4.4. Type Variables

    • 4.5. Parameterized Types

      • 4.5.1. Type Arguments of Parameterized Types

      • 4.5.2. Members and Constructors of Parameterized Types

    • 4.6. Type Erasure

    • 4.7. Reifiable Types

    • 4.8. Raw Types

    • 4.9. Intersection Types

    • 4.10. Subtyping

      • 4.10.1. Subtyping among Primitive Types

      • 4.10.2. Subtyping among Class and Interface Types

      • 4.10.3. Subtyping among Array Types

      • 4.10.4. Least Upper Bound

    • 4.11. Where Types Are Used

    • 4.12. Variables

      • 4.12.1. Variables of Primitive Type

      • 4.12.2. Variables of Reference Type

      • 4.12.3. Kinds of Variables

      • 4.12.4. final Variables

      • 4.12.5. Initial Values of Variables

      • 4.12.6. Types, Classes, and Interfaces

  • 5. Conversions and Contexts

    • 5.1. Kinds of Conversion

      • 5.1.1. Identity Conversion

      • 5.1.2. Widening Primitive Conversion

      • 5.1.3. Narrowing Primitive Conversion

      • 5.1.4. Widening and Narrowing Primitive Conversion

      • 5.1.5. Widening Reference Conversion

      • 5.1.6. Narrowing Reference Conversion

      • 5.1.7. Boxing Conversion

      • 5.1.8. Unboxing Conversion

      • 5.1.9. Unchecked Conversion

      • 5.1.10. Capture Conversion

      • 5.1.11. String Conversion

      • 5.1.12. Forbidden Conversions

      • 5.1.13. Value Set Conversion

    • 5.2. Assignment Contexts

    • 5.3. Invocation Contexts

    • 5.4. String Contexts

    • 5.5. Casting Contexts

      • 5.5.1. Reference Type Casting

      • 5.5.2. Checked Casts and Unchecked Casts

      • 5.5.3. Checked Casts at Run Time

    • 5.6. Numeric Contexts

      • 5.6.1. Unary Numeric Promotion

      • 5.6.2. Binary Numeric Promotion

  • 6. Names

    • 6.1. Declarations

    • 6.2. Names and Identifiers

    • 6.3. Scope of a Declaration

    • 6.4. Shadowing and Obscuring

      • 6.4.1. Shadowing

      • 6.4.2. Obscuring

    • 6.5. Determining the Meaning of a Name

      • 6.5.1. Syntactic Classification of a Name According to Context

      • 6.5.2. Reclassification of Contextually Ambiguous Names

      • 6.5.3. Meaning of Package Names

        • 6.5.3.1. Simple Package Names

        • 6.5.3.2. Qualified Package Names

      • 6.5.4. Meaning of PackageOrTypeNames

        • 6.5.4.1. Simple PackageOrTypeNames

        • 6.5.4.2. Qualified PackageOrTypeNames

      • 6.5.5. Meaning of Type Names

        • 6.5.5.1. Simple Type Names

        • 6.5.5.2. Qualified Type Names

      • 6.5.6. Meaning of Expression Names

        • 6.5.6.1. Simple Expression Names

        • 6.5.6.2. Qualified Expression Names

      • 6.5.7. Meaning of Method Names

        • 6.5.7.1. Simple Method Names

    • 6.6. Access Control

      • 6.6.1. Determining Accessibility

      • 6.6.2. Details on protected Access

        • 6.6.2.1. Access to a protected Member

        • 6.6.2.2. Qualified Access to a protected Constructor

    • 6.7. Fully Qualified Names and Canonical Names

  • 7. Packages

    • 7.1. Package Members

    • 7.2. Host Support for Packages

    • 7.3. Compilation Units

    • 7.4. Package Declarations

      • 7.4.1. Named Packages

      • 7.4.2. Unnamed Packages

      • 7.4.3. Observability of a Package

    • 7.5. Import Declarations

      • 7.5.1. Single-Type-Import Declarations

      • 7.5.2. Type-Import-on-Demand Declarations

      • 7.5.3. Single-Static-Import Declarations

      • 7.5.4. Static-Import-on-Demand Declarations

    • 7.6. Top Level Type Declarations

  • 8. Classes

    • 8.1. Class Declarations

      • 8.1.1. Class Modifiers

        • 8.1.1.1. abstract Classes

        • 8.1.1.2. final Classes

        • 8.1.1.3. strictfp Classes

      • 8.1.2. Generic Classes and Type Parameters

      • 8.1.3. Inner Classes and Enclosing Instances

      • 8.1.4. Superclasses and Subclasses

      • 8.1.5. Superinterfaces

      • 8.1.6. Class Body and Member Declarations

    • 8.2. Class Members

    • 8.3. Field Declarations

      • 8.3.1. Field Modifiers

        • 8.3.1.1. static Fields

        • 8.3.1.2. final Fields

        • 8.3.1.3. transient Fields

        • 8.3.1.4. volatile Fields

      • 8.3.2. Field Initialization

      • 8.3.3. Forward References During Field Initialization

    • 8.4. Method Declarations

      • 8.4.1. Formal Parameters

      • 8.4.2. Method Signature

      • 8.4.3. Method Modifiers

        • 8.4.3.1. abstract Methods

        • 8.4.3.2. static Methods

        • 8.4.3.3. final Methods

        • 8.4.3.4. native Methods

        • 8.4.3.5. strictfp Methods

        • 8.4.3.6. synchronized Methods

      • 8.4.4. Generic Methods

      • 8.4.5. Method Result

      • 8.4.6. Method Throws

      • 8.4.7. Method Body

      • 8.4.8. Inheritance, Overriding, and Hiding

        • 8.4.8.1. Overriding (by Instance Methods)

        • 8.4.8.2. Hiding (by Class Methods)

        • 8.4.8.3. Requirements in Overriding and Hiding

        • 8.4.8.4. Inheriting Methods with Override-Equivalent Signatures

      • 8.4.9. Overloading

    • 8.5. Member Type Declarations

      • 8.5.1. Static Member Type Declarations

    • 8.6. Instance Initializers

    • 8.7. Static Initializers

    • 8.8. Constructor Declarations

      • 8.8.1. Formal Parameters

      • 8.8.2. Constructor Signature

      • 8.8.3. Constructor Modifiers

      • 8.8.4. Generic Constructors

      • 8.8.5. Constructor Throws

      • 8.8.6. The Type of a Constructor

      • 8.8.7. Constructor Body

        • 8.8.7.1. Explicit Constructor Invocations

      • 8.8.8. Constructor Overloading

      • 8.8.9. Default Constructor

      • 8.8.10. Preventing Instantiation of a Class

    • 8.9. Enum Types

      • 8.9.1. Enum Constants

      • 8.9.2. Enum Body Declarations

      • 8.9.3. Enum Members

  • 9. Interfaces

    • 9.1. Interface Declarations

      • 9.1.1. Interface Modifiers

        • 9.1.1.1. abstract Interfaces

        • 9.1.1.2. strictfp Interfaces

      • 9.1.2. Generic Interfaces and Type Parameters

      • 9.1.3. Superinterfaces and Subinterfaces

      • 9.1.4. Interface Body and Member Declarations

    • 9.2. Interface Members

    • 9.3. Field (Constant) Declarations

      • 9.3.1. Initialization of Fields in Interfaces

    • 9.4. Method Declarations

      • 9.4.1. Inheritance and Overriding

        • 9.4.1.1. Overriding (by Instance Methods)

        • 9.4.1.2. Requirements in Overriding

        • 9.4.1.3. Inheriting Methods with Override-Equivalent Signatures

      • 9.4.2. Overloading

      • 9.4.3. Interface Method Body

    • 9.5. Member Type Declarations

    • 9.6. Annotation Types

      • 9.6.1. Annotation Type Elements

      • 9.6.2. Defaults for Annotation Type Elements

      • 9.6.3. Repeatable Annotation Types

      • 9.6.4. Predefined Annotation Types

        • 9.6.4.1. @Target

        • 9.6.4.2. @Retention

        • 9.6.4.3. @Inherited

        • 9.6.4.4. @Override

        • 9.6.4.5. @SuppressWarnings

        • 9.6.4.6. @Deprecated

        • 9.6.4.7. @SafeVarargs

        • 9.6.4.8. @Repeatable

        • 9.6.4.9. @FunctionalInterface

    • 9.7. Annotations

      • 9.7.1. Normal Annotations

      • 9.7.2. Marker Annotations

      • 9.7.3. Single-Element Annotations

      • 9.7.4. Where Annotations May Appear

      • 9.7.5. Multiple Annotations Of The Same Type

    • 9.8. Functional Interfaces

    • 9.9. Function Types

  • 10. Arrays

    • 10.1. Array Types

    • 10.2. Array Variables

    • 10.3. Array Creation

    • 10.4. Array Access

    • 10.5. Array Store Exception

    • 10.6. Array Initializers

    • 10.7. Array Members

    • 10.8. Class Objects for Arrays

    • 10.9. An Array of Characters is Not a String

  • 11. Exceptions

    • 11.1. The Kinds and Causes of Exceptions

      • 11.1.1. The Kinds of Exceptions

      • 11.1.2. The Causes of Exceptions

      • 11.1.3. Asynchronous Exceptions

    • 11.2. Compile-Time Checking of Exceptions

      • 11.2.1. Exception Analysis of Expressions

      • 11.2.2. Exception Analysis of Statements

      • 11.2.3. Exception Checking

    • 11.3. Run-Time Handling of an Exception

  • 12. Execution

    • 12.1. Java Virtual Machine Startup

      • 12.1.1. Load the Class Test

      • 12.1.2. Link Test: Verify, Prepare, (Optionally) Resolve

      • 12.1.3. Initialize Test: Execute Initializers

      • 12.1.4. Invoke Test.main

    • 12.2. Loading of Classes and Interfaces

      • 12.2.1. The Loading Process

    • 12.3. Linking of Classes and Interfaces

      • 12.3.1. Verification of the Binary Representation

      • 12.3.2. Preparation of a Class or Interface Type

      • 12.3.3. Resolution of Symbolic References

    • 12.4. Initialization of Classes and Interfaces

      • 12.4.1. When Initialization Occurs

      • 12.4.2. Detailed Initialization Procedure

    • 12.5. Creation of New Class Instances

    • 12.6. Finalization of Class Instances

      • 12.6.1. Implementing Finalization

      • 12.6.2. Interaction with the Memory Model

    • 12.7. Unloading of Classes and Interfaces

    • 12.8. Program Exit

  • 13. Binary Compatibility

    • 13.1. The Form of a Binary

    • 13.2. What Binary Compatibility Is and Is Not

    • 13.3. Evolution of Packages

    • 13.4. Evolution of Classes

      • 13.4.1. abstract Classes

      • 13.4.2. final Classes

      • 13.4.3. public Classes

      • 13.4.4. Superclasses and Superinterfaces

      • 13.4.5. Class Type Parameters

      • 13.4.6. Class Body and Member Declarations

      • 13.4.7. Access to Members and Constructors

      • 13.4.8. Field Declarations

      • 13.4.9. final Fields and static Constant Variables

      • 13.4.10. static Fields

      • 13.4.11. transient Fields

      • 13.4.12. Method and Constructor Declarations

      • 13.4.13. Method and Constructor Type Parameters

      • 13.4.14. Method and Constructor Formal Parameters

      • 13.4.15. Method Result Type

      • 13.4.16. abstract Methods

      • 13.4.17. final Methods

      • 13.4.18. native Methods

      • 13.4.19. static Methods

      • 13.4.20. synchronized Methods

      • 13.4.21. Method and Constructor Throws

      • 13.4.22. Method and Constructor Body

      • 13.4.23. Method and Constructor Overloading

      • 13.4.24. Method Overriding

      • 13.4.25. Static Initializers

      • 13.4.26. Evolution of Enums

    • 13.5. Evolution of Interfaces

      • 13.5.1. public Interfaces

      • 13.5.2. Superinterfaces

      • 13.5.3. Interface Members

      • 13.5.4. Interface Type Parameters

      • 13.5.5. Field Declarations

      • 13.5.6. Interface Method Declarations

      • 13.5.7. Evolution of Annotation Types

  • 14. Blocks and Statements

    • 14.1. Normal and Abrupt Completion of Statements

    • 14.2. Blocks

    • 14.3. Local Class Declarations

    • 14.4. Local Variable Declaration Statements

      • 14.4.1. Local Variable Declarators and Types

      • 14.4.2. Execution of Local Variable Declarations

    • 14.5. Statements

    • 14.6. The Empty Statement

    • 14.7. Labeled Statements

    • 14.8. Expression Statements

    • 14.9. The if Statement

      • 14.9.1. The if-then Statement

      • 14.9.2. The if-then-else Statement

    • 14.10. The assert Statement

    • 14.11. The switch Statement

    • 14.12. The while Statement

      • 14.12.1. Abrupt Completion of while Statement

    • 14.13. The do Statement

      • 14.13.1. Abrupt Completion of do Statement

    • 14.14. The for Statement

      • 14.14.1. The basic for Statement

        • 14.14.1.1. Initialization of for Statement

        • 14.14.1.2. Iteration of for Statement

        • 14.14.1.3. Abrupt Completion of for Statement

      • 14.14.2. The enhanced for statement

    • 14.15. The break Statement

    • 14.16. The continue Statement

    • 14.17. The return Statement

    • 14.18. The throw Statement

    • 14.19. The synchronized Statement

    • 14.20. The try statement

      • 14.20.1. Execution of try-catch

      • 14.20.2. Execution of try-finally and try-catch-finally

      • 14.20.3. try-with-resources

        • 14.20.3.1. Basic try-with-resources

        • 14.20.3.2. Extended try-with-resources

    • 14.21. Unreachable Statements

  • 15. Expressions

    • 15.1. Evaluation, Denotation, and Result

    • 15.2. Forms of Expressions

    • 15.3. Type of an Expression

    • 15.4. FP-strict Expressions

    • 15.5. Expressions and Run-Time Checks

    • 15.6. Normal and Abrupt Completion of Evaluation

    • 15.7. Evaluation Order

      • 15.7.1. Evaluate Left-Hand Operand First

      • 15.7.2. Evaluate Operands before Operation

      • 15.7.3. Evaluation Respects Parentheses and Precedence

      • 15.7.4. Argument Lists are Evaluated Left-to-Right

      • 15.7.5. Evaluation Order for Other Expressions

    • 15.8. Primary Expressions

      • 15.8.1. Lexical Literals

      • 15.8.2. Class Literals

      • 15.8.3. this

      • 15.8.4. Qualified this

      • 15.8.5. Parenthesized Expressions

    • 15.9. Class Instance Creation Expressions

      • 15.9.1. Determining the Class being Instantiated

      • 15.9.2. Determining Enclosing Instances

      • 15.9.3. Choosing the Constructor and its Arguments

      • 15.9.4. Run-Time Evaluation of Class Instance Creation Expressions

      • 15.9.5. Anonymous Class Declarations

        • 15.9.5.1. Anonymous Constructors

    • 15.10. Array Creation and Access Expressions

      • 15.10.1. Array Creation Expressions

      • 15.10.2. Run-Time Evaluation of Array Creation Expressions

      • 15.10.3. Array Access Expressions

      • 15.10.4. Run-Time Evaluation of Array Access Expressions

    • 15.11. Field Access Expressions

      • 15.11.1. Field Access Using a Primary

      • 15.11.2. Accessing Superclass Members using super

    • 15.12. Method Invocation Expressions

      • 15.12.1. Compile-Time Step 1: Determine Class or Interface to Search

      • 15.12.2. Compile-Time Step 2: Determine Method Signature

        • 15.12.2.1. Identify Potentially Applicable Methods

        • 15.12.2.2. Phase 1: Identify Matching Arity Methods Applicable by Strict Invocation

        • 15.12.2.3. Phase 2: Identify Matching Arity Methods Applicable by Loose Invocation

        • 15.12.2.4. Phase 3: Identify Methods Applicable by Variable Arity Invocation

        • 15.12.2.5. Choosing the Most Specific Method

        • 15.12.2.6. Method Invocation Type

      • 15.12.3. Compile-Time Step 3: Is the Chosen Method Appropriate?

      • 15.12.4. Run-Time Evaluation of Method Invocation

        • 15.12.4.1. Compute Target Reference (If Necessary)

        • 15.12.4.2. Evaluate Arguments

        • 15.12.4.3. Check Accessibility of Type and Method

        • 15.12.4.4. Locate Method to Invoke

        • 15.12.4.5. Create Frame, Synchronize, Transfer Control

    • 15.13. Method Reference Expressions

      • 15.13.1. Compile-Time Declaration of a Method Reference

      • 15.13.2. Type of a Method Reference

      • 15.13.3. Run-time Evaluation of Method References

    • 15.14. Postfix Expressions

      • 15.14.1. Expression Names

      • 15.14.2. Postfix Increment Operator ++

      • 15.14.3. Postfix Decrement Operator --

    • 15.15. Unary Operators

      • 15.15.1. Prefix Increment Operator ++

      • 15.15.2. Prefix Decrement Operator --

      • 15.15.3. Unary Plus Operator +

      • 15.15.4. Unary Minus Operator -

      • 15.15.5. Bitwise Complement Operator ~

      • 15.15.6. Logical Complement Operator !

    • 15.16. Cast Expressions

    • 15.17. Multiplicative Operators

      • 15.17.1. Multiplication Operator *

      • 15.17.2. Division Operator /

      • 15.17.3. Remainder Operator %

    • 15.18. Additive Operators

      • 15.18.1. String Concatenation Operator +

      • 15.18.2. Additive Operators (+ and -) for Numeric Types

    • 15.19. Shift Operators

    • 15.20. Relational Operators

      • 15.20.1. Numerical Comparison Operators <, <=, >, and >=

      • 15.20.2. Type Comparison Operator instanceof

    • 15.21. Equality Operators

      • 15.21.1. Numerical Equality Operators == and !=

      • 15.21.2. Boolean Equality Operators == and !=

      • 15.21.3. Reference Equality Operators == and !=

    • 15.22. Bitwise and Logical Operators

      • 15.22.1. Integer Bitwise Operators &, ^, and |

      • 15.22.2. Boolean Logical Operators &, ^, and |

    • 15.23. Conditional-And Operator &&

    • 15.24. Conditional-Or Operator ||

    • 15.25. Conditional Operator ? :

      • 15.25.1. Boolean Conditional Expressions

      • 15.25.2. Numeric Conditional Expressions

      • 15.25.3. Reference Conditional Expressions

    • 15.26. Assignment Operators

      • 15.26.1. Simple Assignment Operator =

      • 15.26.2. Compound Assignment Operators

    • 15.27. Lambda Expressions

      • 15.27.1. Lambda Parameters

      • 15.27.2. Lambda Body

      • 15.27.3. Type of a Lambda Expression

      • 15.27.4. Run-time Evaluation of Lambda Expressions

    • 15.28. Constant Expressions

  • 16. Definite Assignment

    • 16.1. Definite Assignment and Expressions

      • 16.1.1. Boolean Constant Expressions

      • 16.1.2. Conditional-And Operator &&

      • 16.1.3. Conditional-Or Operator ||

      • 16.1.4. Logical Complement Operator !

      • 16.1.5. Conditional Operator ? :

      • 16.1.6. Conditional Operator ? :

      • 16.1.7. Other Expressions of Type boolean

      • 16.1.8. Assignment Expressions

      • 16.1.9. Operators ++ and --

      • 16.1.10. Other Expressions

    • 16.2. Definite Assignment and Statements

      • 16.2.1. Empty Statements

      • 16.2.2. Blocks

      • 16.2.3. Local Class Declaration Statements

      • 16.2.4. Local Variable Declaration Statements

      • 16.2.5. Labeled Statements

      • 16.2.6. Expression Statements

      • 16.2.7. if Statements

      • 16.2.8. assert Statements

      • 16.2.9. switch Statements

      • 16.2.10. while Statements

      • 16.2.11. do Statements

      • 16.2.12. for Statements

        • 16.2.12.1. Initialization Part of for Statement

        • 16.2.12.2. Incrementation Part of for Statement

      • 16.2.13. break, continue, return, and throw Statements

      • 16.2.14. synchronized Statements

      • 16.2.15. try Statements

    • 16.3. Definite Assignment and Parameters

    • 16.4. Definite Assignment and Array Initializers

    • 16.5. Definite Assignment and Enum Constants

    • 16.6. Definite Assignment and Anonymous Classes

    • 16.7. Definite Assignment and Member Types

    • 16.8. Definite Assignment and Static Initializers

    • 16.9. Definite Assignment, Constructors, and Instance Initializers

  • 17. Threads and Locks

    • 17.1. Synchronization

    • 17.2. Wait Sets and Notification

      • 17.2.1. Wait

      • 17.2.2. Notification

      • 17.2.3. Interruptions

      • 17.2.4. Interactions of Waits, Notification, and Interruption

    • 17.3. Sleep and Yield

    • 17.4. Memory Model

      • 17.4.1. Shared Variables

      • 17.4.2. Actions

      • 17.4.3. Programs and Program Order

      • 17.4.4. Synchronization Order

      • 17.4.5. Happens-before Order

      • 17.4.6. Executions

      • 17.4.7. Well-Formed Executions

      • 17.4.8. Executions and Causality Requirements

      • 17.4.9. Observable Behavior and Nonterminating Executions

    • 17.5. final Field Semantics

      • 17.5.1. Semantics of final Fields

      • 17.5.2. Reading final Fields During Construction

      • 17.5.3. Subsequent Modification of final Fields

      • 17.5.4. Write-protected Fields

    • 17.6. Word Tearing

    • 17.7. Non-atomic Treatment of double and long

  • 18. Type Inference

    • 18.1. Concepts and Notation

      • 18.1.1. Inference Variables

      • 18.1.2. Constraint Formulas

      • 18.1.3. Bounds

    • 18.2. Reduction

      • 18.2.1. Expression Compatibility Constraints

      • 18.2.2. Type Compatibility Constraints

      • 18.2.3. Subtyping Constraints

      • 18.2.4. Type Equality Constraints

      • 18.2.5. Checked Exception Constraints

    • 18.3. Incorporation

      • 18.3.1. Complementary Pairs of Bounds

      • 18.3.2. Bounds Involving Capture Conversion

    • 18.4. Resolution

    • 18.5. Uses of Inference

      • 18.5.1. Invocation Applicability Inference

      • 18.5.2. Invocation Type Inference

      • 18.5.3. Functional Interface Parameterization Inference

      • 18.5.4. More Specific Method Inference

  • 19. Syntax

  • Index

  • A. Limited License Grant

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