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

Support Array Operator Overloading

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: specification
    • Labels:

      Description

      A DESCRIPTION OF THE PROBLEM :
      It would be nice if objects (like ByteBuffer) could implement array operator overloading.
      This way ByteBuffers could be a drop-in replacement for standard arrays making it easy to switch between normal arrays and ByteBuffers acting as arrays.
      I'm sure other objects would benefit from this as well.

      Maybe a special interface could be created that would require a getter/setter methods.

      class ByteBuffer implements ArrayOperator<byte> {
        public byte get(int idx) {return ...;}
        public void set(int idx, byte value) { ... }
      };

      Then the following would be allowed:

      ByteBuffer bb = ByteBuffer.alloc(1024);
      bb[123] = 123;

      Thanks,


        Attachments

          Activity

            People

            • Assignee:
              smarks Stuart Marks
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: