JDK-5070671 : Arrays.binarySearch can't infer int[]
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2004-07-01
  • Updated: 2005-12-30
  • Resolved: 2005-11-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
Name: rmT116609			Date: 07/01/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
SunOS mary 5.9 Generic_112233-12 sun4u sparc SUNW,Sun-Blade-100

A DESCRIPTION OF THE PROBLEM :
The method <T> int binarySearch(T[] a, T key, Comparator<? super T> c)  in java.util.Arrays doesn't compile if T is an array of a primitive type (int[], long[], etc.)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the program below

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The program should compile.
ACTUAL -
Foo.java:10: cannot find symbol
symbol  : method binarySearch(int[][],int[],java.util.Comparator<int[]>)
location: class java.util.Arrays
        Arrays.binarySearch(arr, elem, c);
              ^
1 error


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.*;
class Foo {
    void foo1() {
        Comparator<int[]> c = new Comparator<int[]>() {
            public int compare(int[] c1, int[] c2) { return 0; }
        };
        int[][] arr = { { 1 } };
        int[] elem = arr[0];
        Arrays.sort(arr, c);
        Arrays.binarySearch(arr, elem, c);
    }
    void foo2() {
        Comparator<Integer[]> c = new Comparator<Integer[]>() {
            public int compare(Integer[] c1, Integer[] c2) { return 0; }
        };
        Integer[][] arr = { { 1 } };
        Integer[] elem = arr[0];
        Arrays.sort(arr, c);
        Arrays.binarySearch(arr, elem, c);
    }
}

---------- END SOURCE ----------
(Incident Review ID: 282110) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon mustang
07-09-2004

WORK AROUND Arrays.<int[]>binarySearch(arr, elem, c); ###@###.### 2004-09-06
06-09-2004

EVALUATION This is probably related to or a dup of 4941882 and/or 4942040. ###@###.### 2004-07-13 It is unclear if this is a case of the compiler being to restrictive or too loose. ###@###.### 2004-07-16
13-07-2004