restlet / restlet-framework-java

The first REST API framework for Java
https://restlet.talend.com
Other
653 stars 284 forks source link

Varargs compile error for Buffer.process #11

Closed ansell closed 7 years ago

ansell commented 12 years ago

I am trying to compile restlet using OpenJDK-7 and it fails to differentiate between Buffer.process(BufferProcessor, int, Object... args) and Buffer.process(BufferProcessor, Object... args) when trying to compile NbChannelInputStream

It may be due to the fact that the int can be autoboxed to Integer and would then match both methods. I am not an expert on varargs, but there may be a difference in interpretation between OpenJDK and other JDKs.

The maven error is:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project org.restlet: Compilation failure [ERROR] /home/peter/gitrepos/restlet-framework-java/modules/org.restlet/src/org/restlet/engine/io/NbChannelInputStream.java:[305,26] error: reference to process is ambiguous, both method process(BufferProcessor,int,Object...) in Buffer and method process(BufferProcessor,Object...) in Buffer match

The ant error is:

[javac] /home/peter/gitrepos/restlet-framework-java/build/temp/jse/modules/org.restlet/src/org/restlet/engine/io/NbChannelInputStream.java:305: error: reference to process is ambiguous, both method process(BufferProcessor,int,Object...) in Buffer and method process(BufferProcessor,Object...) in Buffer match
[javac]         return getBuffer().process(this, length, targetArray, offset);

$ java -version java version "1.7.0_147-icedtea" OpenJDK Runtime Environment (IcedTea7 2.0) (7~b147-2.0-0ubuntu0.11.10.1) OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)

$ mvn -version Apache Maven 3.0.3 (r1075438; 2011-03-01 03:31:09+1000) Maven home: /usr/local/apache-maven Java version: 1.7.0_147-icedtea, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre Default locale: en_AU, platform encoding: UTF-8 OS name: "linux", version: "3.0.0-16-generic", arch: "amd64", family: "unix"

$ ant -version Apache Ant(TM) version 1.8.2 compiled on August 19 2011

BryanHunt commented 12 years ago

This same problem also occurs when compiling with Eclipse.

ansell commented 12 years ago

I forgot to mention that I am trying to compile the 2.1 branch.

ansell commented 12 years ago

This bug still exists in the 2.1 branch. The method signatures are ambiguous due to autoboxing of the int in one version to Integer (which is a subclass of Object) in the second.