Hello Stefan,

2015-01-30 20:41 GMT+01:00 Stefan Bodewig <bode...@apache.org>:

> On 2015-01-30, Gary Gregory wrote:
>
> > On Fri, Jan 30, 2015 at 6:06 AM, Stefan Bodewig <bode...@apache.org>
> wrote:
>
> >> The superclass of ZCompressorInputStream has changed from one we've
> >> removed with the old __internal__ package to a new one in the now
> >> supported lzw package.
>
> > Well, we cannot break BC in a minor release for a public class.  Are
> > we sure BC breaks?
>
> Well, not as much as my intuition had told me:
>
>     public static void main(String[] args) throws Exception {
>         try (InputStream in = new FileInputStream(args[0]);
>              OutputStream out = new FileOutputStream(args[1]);
>              ZCompressorInputStream zin = new ZCompressorInputStream(in) {
>                  @Override
>                  public void close() throws IOException {
>                      System.err.println("closing with code size " +
> codeSize);
>                      setClearCode(12);
>                      super.close();
>                  }
>              }) {
>              IOUtils.copy(zin, out);
>          }
>     }
>
> accesses a protected field and a protected method of
> InternalLZWInputStream when compiled against 1.9, a class that is no
> longer there in 1.10.  When run against trunk (without recompiling) it
> still works.  This is in line with something I once read up in the JLS
> (oh my, nine years ago, time flies)[1].  The compiler says "call the
> protected setClearCode method taking an int arg" and at runtime it
> starts searching for that method with the most derived class.  So
> changing superclasses doesn't seem to affect things.
>
> Of course we will break someting like
>
>     InternalLZWInputStream s = new ZCompressorInputStream(in)
>
> but then again you'd have used a class that we had explicitly marked as
> internal.
>
> Unless anybody comes up with a case where the change in superclass
> causes a problem, I'd say we are fine.
>

thank you for the research!

What will happen if a client has overwritten a method from
InternalLZWInputStream?

    public static void main(String[] args) throws Exception {
        try (InputStream in = new FileInputStream(args[0]);
             OutputStream out = new FileOutputStream(args[1]);
             ZCompressorInputStream zin = new ZCompressorInputStream(in) {
                 @Override
                 public void setClearCode(int code) throws IOException {
                     // reinvent the wheel here...
                 }
             }) {
             IOUtils.copy(zin, out);
         }
    }

My gut feeling tells me this will work as well, but we better double check
to avoid jar hell :-)

Benedikt


>
> Stefan
>
> [1]
> http://stefan.samaflost.de/blog/en/dotNet/difference_between_java_and_csharp.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Reply via email to