<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<tt>ICCE indicates that a _binary incompatible_ change was detected,
which by definition the client cannot recover from. Adding an
enum constant is not a binary incompatibility (though removing one
is). (Interestingly, neither is changing an enum to a class, if
you have static fields for all the constants -- I learned this
recently.)Â <br>
<br>
However, adding an enum constant is a potential _behavioral_
incompatibility -- specifically, it could cause exceptions like
this to be thrown under some circumstances. And it is only
potential because in order to have a problem, both the enum and
the client must each bring a piece of the responsibility -- it is
something the client could recover from it if it wished (by having
a default). This is an incompatibility, but also substantially
less severe in a few ways than deleting a method. (Maybe its like
a method starting to return null where it never had before.)<br>
<br>
If a client has a default in their switch, there's no problem. If
a client doesn't have a default, but provides all the known items,
the compiler builds in a default that throws, to prevent it from
being silently ignored. That's all good, and things are blowing
up in the right place with an informative message. The behavior
incompatibility is an interaction between the enum and the
client's use of that enum. So I think the exception should point
as much to the client as the enum. <br>
<br>
A concrete proposal: <br>
<br>
   UnexpectedClassChangeException <: RuntimeException<br>
   UnexpectedSwitchTarget <: UCCE // works both for enum and
sealed classes<br>
<br>
<br>
<br>
<br>
<br>
<br>
</tt><br>
<div class="moz-cite-prefix">On 3/28/2018 2:06 PM, Kevin Bourrillion
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAGKkBkuKrOrizyEjq_pvm0VHSiFLYBnELNrEL3fQzrakk03ipg@mail.gmail.com">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Wed, Mar 28, 2018 at 8:51 AM,
Brian Goetz <span dir="ltr"><<a
href="mailto:brian.goetz@oracle.com" target="_blank"
moz-do-not-send="true">brian.goetz@oracle.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex"><span
class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Adding
a new enum value is not the same sort of
obviously-incompatible change as changing a static
method to instance, or a concrete method to abstract,
which are the sorts of things that trigger ICCError.
... Adding a new enum constant isn't intrinsically
evil. If anything, the issue is on the client, who
relied on the assumption of of exhaustiveness.</blockquote>
</span>
</blockquote>
</div>
<span
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">
<div class="gmail_extra"><span
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
</span></div>
<div class="gmail_extra"><span
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Okay,
this sentiment is what I'm disagreeing with.</span></div>
<div class="gmail_extra"><span
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
</span></div>
<div class="gmail_extra"><span
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">I
think that what we are doing here is </span>turning that
change (add constant to enum) into an incompatible class
change, just as much as any of the other kinds. It's
directly analogous to adding an interface method. Clients
were required to specify how to handle all the methods of
that interface, but then one more showed up, and those
clients are now broken.</div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">Users will find this
counter-intuitive, but that's only because they won't be
used to it yet. They'll have to learn.</div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">More to the point I think: the
problem isn't "on" the client code; it's having jars in
your runtime classpath that are newer than the jars you
compiled against; that's always a dangerous idea and it
continues to be so here. Today, an experienced developer
knows that there is a category of Errors that, when you
see them in the absence of reflection, always implicate
this kind of classpath issue. I can't see why this would
not belong in that same category.</div>
</span>
<div><br>
</div>
-- <br>
<div class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div
style="line-height:1.5em;padding-top:10px;margin-top:10px;color:rgb(85,85,85);font-family:sans-serif"><span
style="border-width:2px 0px
0px;border-style:solid;border-color:rgb(213,15,37);padding-top:2px;margin-top:2px">Kevin
Bourrillion |</span><span
style="border-width:2px 0px
0px;border-style:solid;border-color:rgb(51,105,232);padding-top:2px;margin-top:2px">Â Java
Librarian |</span><span
style="border-width:2px 0px
0px;border-style:solid;border-color:rgb(0,153,57);padding-top:2px;margin-top:2px">Â Google,
Inc. |</span><span style="border-width:2px 0px
0px;border-style:solid;border-color:rgb(238,178,17);padding-top:2px;margin-top:2px">Â <a
href="mailto:kevinb@google.com"
target="_blank" moz-do-not-send="true">kevinb@google.com</a></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>