socketry / nio4r

Cross-platform asynchronous I/O primitives for scalable network clients and servers.
Other
965 stars 86 forks source link

Java Warnings #245

Closed ioquatix closed 3 years ago

ioquatix commented 3 years ago

@headius / @eregon do either of you mind helping me with these?

ext/nio4r/org/nio4r/ByteBuffer.java:27: warning: [serial] serializable class ByteBuffer has no definition of serialVersionUID
public class ByteBuffer extends RubyObject {
       ^
ext/nio4r/org/nio4r/Monitor.java:15: warning: [serial] serializable class Monitor has no definition of serialVersionUID
public class Monitor extends RubyObject {
       ^
ext/nio4r/org/nio4r/Selector.java:206: warning: [rawtypes] found raw type: RubyArray
        RubyArray array = null;
        ^
  missing type arguments for generic class RubyArray<T>
  where T is a type-variable:
    T extends IRubyObject declared in class RubyArray
ext/nio4r/org/nio4r/Selector.java:212: warning: [rawtypes] found raw type: Iterator
        Iterator selectedKeys = this.selector.selectedKeys().iterator();
        ^
  missing type arguments for generic class Iterator<E>
  where E is a type-variable:
    E extends Object declared in interface Iterator
ext/nio4r/org/nio4r/Selector.java:266: warning: [rawtypes] found raw type: Iterator
        Iterator cancelledKeys = this.cancelledKeys.entrySet().iterator();
        ^
  missing type arguments for generic class Iterator<E>
  where E is a type-variable:
    E extends Object declared in interface Iterator
ext/nio4r/org/nio4r/Selector.java:268: warning: [rawtypes] found raw type: Entry
            Map.Entry entry = (Map.Entry)cancelledKeys.next();
               ^
  missing type arguments for generic class Entry<K,V>
  where K,V are type-variables:
    K extends Object declared in interface Entry
    V extends Object declared in interface Entry
ext/nio4r/org/nio4r/Selector.java:26: warning: [serial] serializable class Selector has no definition of serialVersionUID
public class Selector extends RubyObject {
       ^
11 warnings
eregon commented 3 years ago

I have no expertise with the JRuby extension of nio4r, so can't help here.

ioquatix commented 3 years ago

It looks like just general Java warnings due to changes in the Java standard or something?

headius commented 3 years ago

I will look into this and the other issues you mentioned tomorrow, thanks for letting me know!

On Wed, Sep 9, 2020, 19:23 Samuel Williams notifications@github.com wrote:

It looks like just general Java warnings due to changes in the Java standard or something?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/socketry/nio4r/issues/245#issuecomment-689894357, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACPFZA3MZFXGRMGS6ZVVTSFAMBTANCNFSM4Q5VLXGA .

headius commented 3 years ago

@ioquatix Yes, these are just general Java warnings that anyone with Java knowledge could fix. I will submit a PR to eliminate the warnings.

headius commented 3 years ago

Note also these only come up because the compiler runs with -Xlint which prints more warnings than normal. But they're probably good to fix, I guess.

headius commented 3 years ago

Pushed #252 to fix this.

The warnings are all gone except for one related to how javac guarantees it is compiling for an earlier version (need to have earlier version installed and specify that install as the "boot" class path). This is an issue that would need to be fixed in the rake-compiler invocation of javac (it should use the "-release 8" flag on Java versions 9 or higher).

$ rake clean compile
mkdir -p tmp/java/nio4r_ext
javac -target 1.8 -source 1.8 -Xlint -d tmp/java/nio4r_ext -cp /Users/headius/.rvm/rubies/jruby-9.2.13.0/lib/jruby.jar ext/nio4r/org/nio4r/ByteBuffer.java ext/nio4r/org/nio4r/Monitor.java ext/nio4r/org/nio4r/Nio4r.java ext/nio4r/org/nio4r/Selector.java
warning: [options] bootstrap class path not set in conjunction with -source 8
1 warning
touch tmp/java/nio4r_ext/.build
jar cf tmp/java/nio4r_ext/nio4r_ext.jar -C tmp/java/nio4r_ext org/nio4r/ByteBuffer.class -C tmp/java/nio4r_ext org/nio4r/Monitor.class -C tmp/java/nio4r_ext org/nio4r/Nio4r\$1.class -C tmp/java/nio4r_ext org/nio4r/Nio4r\$2.class -C tmp/java/nio4r_ext org/nio4r/Nio4r\$3.class -C tmp/java/nio4r_ext org/nio4r/Nio4r.class -C tmp/java/nio4r_ext org/nio4r/Selector.class
install -c tmp/java/nio4r_ext/nio4r_ext.jar lib/nio4r_ext.jar
headius commented 3 years ago

The above build was done on Java 14, the most recent release.

ioquatix commented 3 years ago

Thanks so much for your help!