Skip to content

cross compile compatibility#5459

Closed
ahorek wants to merge 1 commit intojruby:masterfrom
ahorek:bytebuffer
Closed

cross compile compatibility#5459
ahorek wants to merge 1 commit intojruby:masterfrom
ahorek:bytebuffer

Conversation

@ahorek
Copy link
Contributor

@ahorek ahorek commented Nov 20, 2018

@headius
Copy link
Member

headius commented Nov 20, 2018

Looking good! I also started doing this and my coverage for clear seems to hit more sites than yours: https://gist.github.com/headius/08a568f5cf662ff207145e54cc0dbeb2

Other suggestions:

  • We can make the methods all generic to with T extends Buffer and just cast the return type to T as seen in my version. That avoids the grey "unnecessary cast" squiggly in most IDEs.
  • Do an IDE search for callers to these methods so we make sure we get every call site.

Otherwise this is just fine. As @enebo was saying to me, there will still be cases where we regress, but we could set up a JDK9 build + JDK8 test run in CI to help avoid that.

@headius headius self-requested a review November 20, 2018 22:16
Copy link
Member

@headius headius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Make sure all appropriate call sites get covered by using IDE tooling to find those call sites.

import org.jruby.util.StringSupport;
import org.jruby.util.io.EncodingUtils;
import org.jruby.util.unsafe.UnsafeHolder;
import static org.jruby.util.io.ChannelHelper.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand this and the others; we generally don't use * unless it's more than like 10 imports from the same place.

**/
public static Buffer clearBuffer(Buffer buffer) {
return buffer.clear();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the others can be generified like so:

public static <T extends Buffer> T clearBuffer(T buffer) {
    return (T) buffer.clear();
}

This allows methods with variadic returns to still be called and return the right type of thing (e.g. you can call ByteBuffer x = clearBuffer(byteBuffer)).

}

/**
* Java 9 introduced overridden methods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First complete sentence of javadoc (with period, so it generates right) should say what this method does. The explanation comes second.

@headius headius added this to the JRuby 9.2.5.0 milestone Nov 20, 2018
@enebo enebo modified the milestones: JRuby 9.2.5.0, JRuby 9.2.6.0 Dec 6, 2018
headius added a commit to headius/jruby that referenced this pull request Dec 6, 2018
headius added a commit that referenced this pull request Dec 6, 2018
@headius headius closed this Dec 6, 2018
@headius
Copy link
Member

headius commented Dec 6, 2018

Thanks for the help @ahorek! I made my additional small changes in #5499 and merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants