JDK-6478540 : Receive an internal error from javac when compiling a class
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P5
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-10-05
  • Updated: 2011-02-16
  • Resolved: 2009-03-13
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b01)
Java HotSpot(TM) Client VM (build 1.5.0_09-b01, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
I tried something silly with  generics and arrays that gave me a compiler internal error.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just simply compile the following class with no options

javac name\slacroix\C3.java

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
get a compilation error about some type mismatch
ACTUAL -
name\slacroix\C3.java:9: internal error; cannot instantiate <T>binarySearch(T[],T,java.util.Comparator<? super T>) at java.ut
il.Arrays to (long[][],int,java.util.Comparator<long[]>)
            int indexFound = Arrays.binarySearch(arrayMap, 1, comparator);
                                                ^
1 error


ERROR MESSAGES/STACK TRACES THAT OCCUR :
name\slacroix\C3.java:9: internal error; cannot instantiate <T>binarySearch(T[],T,java.util.Comparator<? super T>) at java.ut
il.Arrays to (long[][],int,java.util.Comparator<long[]>)
            int indexFound = Arrays.binarySearch(arrayMap, 1, comparator);
                                                ^
1 error


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package name.slacroix;

import java.util.Arrays;
import java.util.Comparator;

public class C3 {
    static protected long[][] arrayMap = new long[100][2];

    public static void main(String[] args) {
            int indexFound = Arrays.binarySearch(arrayMap, 1, comparator);
    }
    static protected Comparator<long[]> comparator = new Comparator<long[]>(){
            public int compare(long[] a, long[] b) {
                return 1;
            }
        };
}

---------- END SOURCE ----------

Comments
EVALUATION Not reproducible after jdk 7 b25 (see 6611449)
13-03-2009

EVALUATION The program should not compiler (as hinted by the submitter). However, the compiler error should be improved.
06-10-2006