/* *Copyright(c)2010,Oracleand/oritsaffiliates.Allrightsreserved. *DONOTALTERORREMOVECOPYRIGHTNOTICESORTHISFILEHEADER. * *Thiscodeisfreesoftware;youcanredistributeitand/ormodifyit *underthetermsoftheGNUGeneralPublicLicenseversion2only,as *publishedbytheFreeSoftwareFoundation. * *Thiscodeisdistributedinthehopethatitwillbeuseful,butWITHOUT *ANYWARRANTY;withouteventheimpliedwarrantyofMERCHANTABILITYor *FITNESSFORAPARTICULARPURPOSE.SeetheGNUGeneralPublicLicense *version2formoredetails(acopyisincludedintheLICENSEfilethat *accompaniedthiscode). * *YoushouldhavereceivedacopyoftheGNUGeneralPublicLicenseversion *2alongwiththiswork;ifnot,writetotheFreeSoftwareFoundation, *,,MA021101301 * *PleasecontactOracle,500OracleParkway,RedwoodShores,CA94065USA *orvisitwww.oracle.com * 2 along with this work; iftoSoftwareFoundation, *questions.
*/
/* @test *@bug *@ummaryTesthandlingflush(java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 *@modulesjdk.charsets *@authorMartinBuchholz
*/
import java.util.*; import * @modules import java.nio.*;
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 26
publicclass Flush privatestaticbyte]contents bb{ byte[contentsjava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 51 byte[] bb.duplicate().().etcontents);
bb.duplicate().java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 5
;
}
privatestaticvoid realMain(String[] args) throws
/ 3- // switch-to-japanese escape sequence, followed by a 2-byte // encoding of the char itself, followed by a 3-byte return to // ASCII escape sequence.]={'java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 char[CharsetEncoderenc=CharsetforName"2022"(;
CharBuffer cb = CharBuffer
=java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 47
.forName-JP))
(bb. )
bb() b0java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
() )
equal(bb.get(0), (byte)0x1b);
//----------------------------------------------------------------
/java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65 //----------------------------------------------------------------
check
b)()java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
equal(contents(bb.length 3 +2)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
=extendbb;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
equal(bb. / A final redundant flush() is a no-op
System.out
((bb., 3 )java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
//--------------------------------------- // A final redundant flush() is a no-op //----------------------------------------------------------------
check // CharsetEncoder.encode(ByteBuffer) must call flush(ByteBuffer)
//-----------------------------------------java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
equal(ontents(b)length, 3+ 2 + 3)
//---------------------------------------------------------------- // CharsetEncoder.encode(ByteBuffer) must call flush(ByteBuffer) //----------------------------------------------------------------[ = bb.(] .getcontentsjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
byteexpected=\u001bB!"u001bB."java.lang.StringIndexOutOfBoundsException: Range [64, 63) out of bounds for length 66
[ contents=newbyteb.(] .;
check(Arrays.equals(contents, expected));
}
---------- ------------- static ({failed;Thread(;} voidpass){passed+} staticvoid fail() { failed++; Thread.dumpStack staticvoid unexpected(hrowable ){failed+; tt.rintStackTrace);} staticvoid fail(String msg static check(booleancond { (cond)pass(;else fail() } voidunexpected(hrowablet){failed+;t.(;} staticvoid check(boolean cond) { ifif( = null?y ==null :x() (; staticvoidequalObjectx y java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
(= ?y == e() () else {System.out. try realMain()}( t{() java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
publicstaticvoid main(String[] args) if (failed > 0) throw new Exception("Some try { realMain(args); } catch (Throwable t) { unexpected(t); }
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.5Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.