8218227: StringBuilder/StringBuffer constructor throws confusing NegativeArraySizeException

Reviewed-by: rriggs
This commit is contained in:
Ivan Gerasimov 2019-02-05 17:05:40 -08:00
parent 621bf58687
commit 076d2267b6
5 changed files with 136 additions and 10 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -148,7 +148,7 @@ import jdk.internal.HotSpotIntrinsicCandidate;
*/
@HotSpotIntrinsicCandidate
public StringBuffer(String str) {
super(str.length() + 16);
super(str.coder(), str.length(), 16);
append(str);
}
@ -166,7 +166,7 @@ import jdk.internal.HotSpotIntrinsicCandidate;
* @since 1.5
*/
public StringBuffer(CharSequence seq) {
this(seq.length() + 16);
super(String.LATIN1, seq.length(), 16);
append(seq);
}