---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 18 Edition"
java_version: 18
chapter: "Chapter 13. Binary Compatibility"
section: "13.4.12"
heading: "13.4.12. Method and Constructor Declarations"
parent: "13.4. Evolution of Classes"
source: https://docs.oracle.com/javase/specs/jls/se18/html/jls-13.html#jls-13.4.12
id: "13.4.12"
url: https://jvm.obfuscated.software/jls/se18/13.4.12.html
raw: https://jvm.obfuscated.software/jls/se18/13.4.12.md
---

# 13.4.12. Method and Constructor Declarations

Adding a method or constructor to a class will not break compatibility with any pre-existing binaries, even in the case where a class could no longer be recompiled because an invocation previously referenced a method or constructor of a superclass with an incompatible type. The previously compiled class with such a reference will continue to reference the method or constructor declared in a superclass.

Assume a reference to a method `m` with qualifying class C. Assume further that `m` is in fact an instance (respectively `static`) method declared in a superclass of C, S.

If a new method of type X with the same signature and return type as `m` is added to a subclass of S that is a superclass of C or C itself, then a linkage error may occur. Such a linkage error will occur only if, in addition to the above, either one of the following is true:

- The new method is less accessible than the old one.
- The new method is a `static` (respectively instance) method.

Deleting a method or constructor from a class may break compatibility with any pre-existing binary that referenced this method or constructor; a `NoSuchMethodError` may be thrown when such a reference from a pre-existing binary is linked. Such an error will occur only if no method with a matching signature and return type is declared in a superclass.

If the source code for a non-inner class contains no declared constructors, then a default constructor with no parameters is implicitly declared ([§8.8.9](8.8.9.md)). Adding one or more constructor declarations to the source code of such a class will prevent this default constructor from being implicitly declared, effectively deleting a constructor, unless one of the new constructors also has no parameters, thus replacing the default constructor. The default constructor with no parameters is given the same access modifier as the class of its declaration, so any replacement should have as much or more access if compatibility with pre-existing binaries is to be preserved.
