restlet/restlet-framework-java — Issue #11: Varargs compile error for Buffer.process
Author: ansell
Created: 2012-03-01 01:51:59+00:00
State: open

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