JDK-8065312 : javac incorrectly reports cause of error on non-static varargs call from static
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u11
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_8
  • CPU: x86
  • Submitted: 2014-08-20
  • Updated: 2014-11-19
  • Resolved: 2014-11-19
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]

A DESCRIPTION OF THE PROBLEM :
javac incorrectly reports the cause of a compilation error in the included source. The source attempts to call a non-static method from a static context. This occurs when attempting to call a varargs method with an array of the varargs type. 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attempt to compile the included source.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Test.java:5: error: non-static method prints(int...) cannot be referenced from a static context
        prints(ints);
        ^
1 error
ACTUAL -
Test.java:5: error: method prints in class Test cannot be applied to given types;
        prints(ints);
        ^
  required: int[]
  found: int[]
  reason: varargs mismatch; int[] cannot be converted to int
1 error

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class Test {
    public static void main(String[] args) {
        int[] ints = new int[]{1, 2, 3, 4, 5};
        prints(ints);
    }

    void prints(int... ints) {
        for(int i : ints) {
            System.out.println(i);
        }
    }
}
---------- END SOURCE ----------


Comments
Closing this as duplicate of JDK-8055514. Informed submitter about the resolution.
19-11-2014