Tuesday, 15 February 2011

java - What is binary compatibility -



java - What is binary compatibility -

i reading effective java joshua bloch.

in item 17: utilize interfaces define types, came across explanation not advised utilize interfaces storing constants. putting explanation below.

"worse, represents commitment: if in future release class modified no longer needs utilize constants, still must implement interface ensure binary compatibility."

what bianry compatibility mean here?

can guide me illustration in java show code binary compatible.

in short, binary compatibility means when alter class, not need recompile classes utilize it. example, removed or renamed public or protected method class

public class logger implements constants { public logger getlogger(string name) { homecoming logmanager.getlogger(name); } }

from log-1.jar library , released new version log-2.jar. when users of log-1.jar download new version break apps when seek utilize missing getlogger(string name) method.

and if remove constants interface (item 17) break binary compatibility either, due same reason.

but can remove / rename private or bundle private fellow member of class without breaking binary compatibility, because external apps cannot (or should not) utilize it.

java

No comments:

Post a Comment