Java 1.5 and varargs - private access compilation problem

Hello,

I have been browsing web for a while but haven't found any solution of my problem (or any similar problem at all :( ).

Imagine following classes in "Experiment.java" file:

publicclass Experiment{

publicstaticvoid main(String[] args){

A a =new A();

}

}

class A{

public A(int... a){

}

private A(){

}

}

Having it in Eclipse, everything seems fine and Eclipse successfully runs this code. Javac is a different story. Trying to compile it using javac (also with arguments "-source 1.5 -target 1.5") ends in the following:

Experiment.java:4: A() has private access in A

A a = new A();

However, is this a problem in javac? Or is it just some Eclipse java compiler special feature? Regardless of the answer, I think that such code should not cause any 'signature competitions' and for me it is quite straightforward to safely call the public constructor in this case.

Thanks.

[1560 byte] By [Peter-Misaka] at [2007-11-26 19:00:04]
# 1

That's a bug in Eclipse (I've seen such problems before with Eclipse).

Your public constructor takes a variable number of arguments, ranging from 0 to whatever.

It therefore conflicts with your private constructor which takes no arguments (and thus overlaps the cornercase for your public constructor).

jwentinga at 2007-7-9 20:41:56 > top of Java-index,Developer Tools,Java Compiler...