mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8284161: Implementation of Virtual Threads (Preview)
Co-authored-by: Ron Pressler <rpressler@openjdk.org> Co-authored-by: Alan Bateman <alanb@openjdk.org> Co-authored-by: Erik Österlund <eosterlund@openjdk.org> Co-authored-by: Andrew Haley <aph@openjdk.org> Co-authored-by: Rickard Bäckman <rbackman@openjdk.org> Co-authored-by: Markus Grönlund <mgronlun@openjdk.org> Co-authored-by: Leonid Mesnik <lmesnik@openjdk.org> Co-authored-by: Serguei Spitsyn <sspitsyn@openjdk.org> Co-authored-by: Chris Plummer <cjplummer@openjdk.org> Co-authored-by: Coleen Phillimore <coleenp@openjdk.org> Co-authored-by: Robbin Ehn <rehn@openjdk.org> Co-authored-by: Stefan Karlsson <stefank@openjdk.org> Co-authored-by: Thomas Schatzl <tschatzl@openjdk.org> Co-authored-by: Sergey Kuksenko <skuksenko@openjdk.org> Reviewed-by: lancea, eosterlund, rehn, sspitsyn, stefank, tschatzl, dfuchs, lmesnik, dcubed, kevinw, amenkov, dlong, mchung, psandoz, bpb, coleenp, smarks, egahlin, mseledtsov, coffeys, darcy
This commit is contained in:
parent
5212535a27
commit
9583e3657e
1133 changed files with 95935 additions and 8335 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2022, 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
|
||||
|
@ -28,9 +28,9 @@ package java.io;
|
|||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import jdk.internal.misc.InternalLock;
|
||||
import sun.nio.cs.StreamDecoder;
|
||||
|
||||
|
||||
/**
|
||||
* An InputStreamReader is a bridge from byte streams to character streams: It
|
||||
* reads bytes and decodes them into characters using a specified {@link
|
||||
|
@ -61,9 +61,22 @@ import sun.nio.cs.StreamDecoder;
|
|||
*/
|
||||
|
||||
public class InputStreamReader extends Reader {
|
||||
|
||||
private final StreamDecoder sd;
|
||||
|
||||
/**
|
||||
* Return the lock object for the given reader's stream decoder.
|
||||
* If the reader type is trusted then an internal lock can be used. If the
|
||||
* reader type is not trusted then the reader object is the lock.
|
||||
*/
|
||||
private static Object lockFor(InputStreamReader reader) {
|
||||
Class<?> clazz = reader.getClass();
|
||||
if (clazz == InputStreamReader.class || clazz == FileReader.class) {
|
||||
return InternalLock.newLockOr(reader);
|
||||
} else {
|
||||
return reader;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an InputStreamReader that uses the
|
||||
* {@link Charset#defaultCharset() default charset}.
|
||||
|
@ -74,8 +87,8 @@ public class InputStreamReader extends Reader {
|
|||
*/
|
||||
public InputStreamReader(InputStream in) {
|
||||
super(in);
|
||||
sd = StreamDecoder.forInputStreamReader(in, this,
|
||||
Charset.defaultCharset()); // ## check lock object
|
||||
Charset cs = Charset.defaultCharset();
|
||||
sd = StreamDecoder.forInputStreamReader(in, lockFor(this), cs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,7 +109,7 @@ public class InputStreamReader extends Reader {
|
|||
super(in);
|
||||
if (charsetName == null)
|
||||
throw new NullPointerException("charsetName");
|
||||
sd = StreamDecoder.forInputStreamReader(in, this, charsetName);
|
||||
sd = StreamDecoder.forInputStreamReader(in, lockFor(this), charsetName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,7 +124,7 @@ public class InputStreamReader extends Reader {
|
|||
super(in);
|
||||
if (cs == null)
|
||||
throw new NullPointerException("charset");
|
||||
sd = StreamDecoder.forInputStreamReader(in, this, cs);
|
||||
sd = StreamDecoder.forInputStreamReader(in, lockFor(this), cs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +139,7 @@ public class InputStreamReader extends Reader {
|
|||
super(in);
|
||||
if (dec == null)
|
||||
throw new NullPointerException("charset decoder");
|
||||
sd = StreamDecoder.forInputStreamReader(in, this, dec);
|
||||
sd = StreamDecoder.forInputStreamReader(in, lockFor(this), dec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue