Skip to content

Commit

Permalink
Provide type specialized array() implementations (that simply throw)
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed May 15, 2024
1 parent 73b81c7 commit f82f6a5
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/java/nio/ByteBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -958,4 +958,9 @@ public int getElementType() {
public boolean isReadOnly() {
return false;
}

@Override
public final byte[] array() {
return (byte[]) super.array();
}
}
5 changes: 5 additions & 0 deletions src/main/java/java/nio/CharBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,9 @@ public int read (CharBuffer target) throws IOException {
target.put(chars);
return result;
}

@Override
public final char[] array() {
return (char[]) super.array();
}
}
5 changes: 5 additions & 0 deletions src/main/java/java/nio/DoubleBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,9 @@ public String toString () {
buf.append(limit());
return buf.toString();
}

@Override
public final double[] array() {
return (double[]) super.array();
}
}
5 changes: 5 additions & 0 deletions src/main/java/java/nio/FloatBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,9 @@ public int getElementType() {
public boolean isReadOnly() {
return false;
}

@Override
public final float[] array() {
return (float[]) super.array();
}
}
5 changes: 5 additions & 0 deletions src/main/java/java/nio/IntBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,9 @@ public int getElementType() {
public boolean isReadOnly() {
return false;
}

@Override
public final int[] array() {
return (int[]) super.array();
}
}
5 changes: 5 additions & 0 deletions src/main/java/java/nio/LongBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,9 @@ public String toString () {
buf.append(limit());
return buf.toString();
}

@Override
public final long[] array() {
return (long[]) super.array();
}
}
5 changes: 5 additions & 0 deletions src/main/java/java/nio/ShortBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,9 @@ public int getElementType() {
public boolean isReadOnly() {
return false;
}

@Override
public final short[] array() {
return (short[]) super.array();
}
}

0 comments on commit f82f6a5

Please sign in to comment.