Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8360552

Use long as an array index

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • None
    • specification
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      As indicated in the Java Specification Language (JLS, Chapter 10.4 Array Access):

      "Arrays must be indexed by int values; short, byte, or char values may also be used as index values because they are subjected to unary numeric promotion (§5.6.1) and become int values.

      An attempt to access an array component with a long index value results in a compile-time error."

      But, I wish that Java supports large array index, then I can use java to build my HPC system to process over 2^31-1 data size, not only in C or C++, like the example shown in the source code section.

      ---------- BEGIN SOURCE ----------
      import java.io.IOException;

      public class Experiment {

      public static void main(String[] args) throws IOException {
      long l=4*1024*1024*1024L;
      int[]i=new int[l];
      }
      }
      ---------- END SOURCE ----------

            abuckley Alex Buckley
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: