---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 17 Edition"
java_version: 17
chapter: "Chapter 13. Binary Compatibility"
section: "13.2"
heading: "13.2. What Binary Compatibility Is and Is Not"
parent: "Chapter 13. Binary Compatibility"
source: https://docs.oracle.com/javase/specs/jls/se17/html/jls-13.html#jls-13.2
id: "13.2"
url: https://jvm.obfuscated.software/jls/se17/13.2.html
raw: https://jvm.obfuscated.software/jls/se17/13.2.md
---

# 13.2. What Binary Compatibility Is and Is Not

A change to a type is *binary compatible with* (equivalently, does not *break binary compatibility* with) pre-existing binaries if pre-existing binaries that previously linked without error will continue to link without error.

Binaries are compiled to rely on the accessible members and constructors of other classes and interfaces. To preserve binary compatibility, a class or interface should treat its accessible members and constructors, their existence and behavior, as a *contract* with its users.

The Java programming language is designed to prevent additions to contracts and accidental name collisions from breaking binary compatibility. Specifically, addition of more methods overloading a particular method name does not break compatibility with pre-existing binaries. The method signature that the pre-existing binary will use for method lookup is chosen by the overload resolution algorithm at compile time ([§15.12.2](15.12.2.md)).

If the Java programming language had been designed so that the particular method to be executed was chosen at run time, then such an ambiguity might be detected at run time. Such a rule would imply that adding an additional overloaded method so as to make ambiguity possible at a call site could break compatibility with an unknown number of pre-existing binaries. See [§13.4.23](13.4.23.md) for more discussion.

Binary compatibility is not the same as source compatibility. In particular, the example in [§13.4.6](13.4.6.md) shows that a set of compatible binaries can be produced from sources that will not compile all together. This example is typical: a new declaration is added, changing the meaning of a name in an unchanged part of the source code, while the pre-existing binary for that unchanged part of the source code retains the fully-qualified, previous meaning of the name. Producing a consistent set of source code requires providing a qualified name or field access expression corresponding to the previous meaning.
