JDK-8063054 : Incorrect raw type warning for method reference
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-11-05
  • Updated: 2019-06-13
  • Resolved: 2017-10-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10
10 b26Fixed
Related Reports
Relates :  
Relates :  
The following produces a rawtype warning, even though the type is used as a qualifier of a method reference.  Generally, rawtype warnings do not occur in this context, but something strange about this case is triggering it.  (Hint: removing the wildcard will make the warning go away.)

    void test(Box<? extends Box<Number>> b) {
        Number n = b.<Number>map(Box::get).get();

    interface Func<S,T> { T apply(S arg); }

    interface Box<T> {
        T get();
        <R> Box<R> map(Func<T,R> f);

warning: [rawtypes] found raw type: Box
        Number n = b.<Number>map(Box::get).get();
  missing type arguments for generic class Box<T>
  where T is a type-variable:
    T extends Object declared in interface Box
compiler-dev discussion, including a possible fix: http://mail.openjdk.java.net/pipermail/compiler-dev/2017-February/010815.html http://mail.openjdk.java.net/pipermail/compiler-dev/2017-March/010888.html

Here's another case, this time with no wildcards: interface Consumer<T> { void accept(T arg); } interface Parent<P> { void foo(); } interface Child extends Parent<String> {} static <T> void m(T arg, Consumer<T> f) {} public void test(Child c) { m(c, Parent::foo); } It's important that i) Parent is generic (of course); ii) the first argument to 'm' is a Child; and iii) the method reference is via Parent.