将枚举器添加到 Java 枚举中会破坏 ABI 吗?
Does adding enumerators into Java enum break ABI?
比如我的代码中有
public enum Color { RED, BLACK }
后面我加了一个颜色,就是
public enum Color { RED, BLACK, BLUE }
这会破坏 ABI 吗?也就是说,我的用户是否需要重新编译他的 Java 类?
没有。根据Java Language Specification:
13.4.26. Evolution of Enums
Adding or reordering constants in an enum will not break compatibility with pre-existing binaries.
请注意,即使重新排序也能保持兼容性,这与 C/C++/C# 不同。
比如我的代码中有
public enum Color { RED, BLACK }
后面我加了一个颜色,就是
public enum Color { RED, BLACK, BLUE }
这会破坏 ABI 吗?也就是说,我的用户是否需要重新编译他的 Java 类?
没有。根据Java Language Specification:
13.4.26. Evolution of Enums
Adding or reordering constants in an enum will not break compatibility with pre-existing binaries.
请注意,即使重新排序也能保持兼容性,这与 C/C++/C# 不同。