---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 16 Edition"
java_version: 16
chapter: "Chapter 13. Binary Compatibility"
section: "13.4.17"
heading: "13.4.17. final Methods"
parent: "13.4. Evolution of Classes"
source: https://docs.oracle.com/javase/specs/jls/se16/html/jls-13.html#jls-13.4.17
id: "13.4.17"
url: https://jvm.obfuscated.software/jls/se16/13.4.17.html
raw: https://jvm.obfuscated.software/jls/se16/13.4.17.md
---

# 13.4.17. `final` Methods

Changing a method that is declared `final` to no longer be declared `final` does not break compatibility with pre-existing binaries.

Changing an instance method that is not declared `final` to be declared `final` may break compatibility with existing binaries that depend on the ability to override the method.

**Example 13.4.17-1. Changing A Method To Be `final`**

```
class Super { void out() { System.out.println("out"); } }
class Test extends Super {
    public static void main(String[] args) {
        Test t = new Test();
        t.out();
    }
    void out() { super.out(); }
}
```

This program produces the output:

```
out
```

Suppose that a new version of class `Super` is produced:

```
class Super { final void out() { System.out.println("!"); } }
```

If `Super` is recompiled but not `Test`, then running the new binary with the existing binary of `Test` results in an `IncompatibleClassChangeError` because the class `Test` improperly tries to override the instance method `out`.

Changing a class (`static`) method that is not declared `final` to be declared `final` does not break compatibility with existing binaries, because the method could not have been overridden.
