当在静态上下文中使用实例方法时,为什么javac会发出“错误:类中的方法无法应用于给定类型”?

考虑以下(无效)Java程序:

public class Test { public static void main(String[] args) { int[] ints = {1, 2, 3, 4, 5}; print(ints); } public void print(int... ints) { for (int i : ints) { System.out.print(i); } } } 

我希望有类似这样的错误:

 Cannot make a static reference to the non-static method print(int[]) from the type Test at Test.main(Test.java:5) 

但相反,javac发出:

 Test.java:5: error: method print in class Test cannot be applied to given types; print(ints); ^ required: int[] found: int[] reason: varargs mismatch; int[] cannot be converted to int 1 error 

javac -version javac 1.8.0_11 java -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) 

这是在这个问题中出现的 。 这是javac中的错误吗? 或者我错过了一些明显死亡的东西?

这是一个错误,已被报告为JDK-8055514 。 (由你?)