-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8361299: (bf) CharBuffer.getChars(int,int,char[],int) violates pre-existing specification #26104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ | |
|
||
/** | ||
* @test | ||
* @bug 8343110 | ||
* @bug 8343110 8361299 | ||
* @summary Check for expected behavior of CharBuffer.getChars(). | ||
* @run testng GetChars | ||
* @key randomness | ||
|
@@ -71,6 +71,19 @@ public void testSrcBeginIsNegative() { | |
() -> CB.getChars(-1, 3, new char[4], 0)); | ||
} | ||
|
||
@Test | ||
public void testSrcBeginIsNegationOfPosition() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I skimmed through GetChars and I see it only tests a CB created with CharBuffer.wrap, only testGetChars tests all char buffers. All the test methods should be tested all char buffer implementations. So maybe we can create a follow-up issue to improve this test (and probably migrate it to a JUnit test too). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agreed. I also noticed it is TestNG now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, let's create a follow-up issue for that. |
||
CB.position(1); | ||
Assert.assertThrows(IndexOutOfBoundsException.class, | ||
() -> { | ||
try { | ||
CB.getChars(-1, 3, new char[4], 0); | ||
} finally { | ||
CB.position(0); | ||
} | ||
}); | ||
} | ||
|
||
@Test | ||
public void testDstBeginIsNegative() { | ||
Assert.assertThrows(IndexOutOfBoundsException.class, | ||
|
@@ -200,7 +213,7 @@ public void testGetChars(String type, CharBuffer cb) { | |
System.out.format("%s position=%d, limit=%d%n", type, cb.position(), cb.limit()); | ||
int expected = intSum(cb); | ||
var dst = new char[cb.remaining()]; | ||
cb.getChars(cb.position(), cb.limit(), dst, 0); | ||
cb.getChars(0, cb.remaining(), dst, 0); | ||
int actual = intSum(dst); | ||
assertEquals(actual, expected); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use an implSpec for this and keep "This method is equivalent to".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following the existing convention elsewhere in the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why JDK-8343110 put the implSpec after the param/return/throws tags so happy it has been fixed. Maybe at some point we can use implSpec to these methods.