13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.internal.misc;
27
28 import java.lang.annotation.Annotation;
29 import java.lang.module.ModuleDescriptor;
30 import java.lang.reflect.Executable;
31 import java.lang.reflect.Method;
32 import java.net.URI;
33 import java.nio.charset.Charset;
34 import java.security.AccessControlContext;
35 import java.security.ProtectionDomain;
36 import java.util.Iterator;
37 import java.util.List;
38 import java.util.Map;
39 import java.util.concurrent.ConcurrentHashMap;
40 import java.util.stream.Stream;
41
42 import jdk.internal.module.ServicesCatalog;
43 import jdk.internal.reflect.ConstantPool;
44 import sun.reflect.annotation.AnnotationType;
45 import sun.nio.ch.Interruptible;
46
47 public interface JavaLangAccess {
48
49 /**
50 * Returns the list of {@code Method} objects for the declared public
51 * methods of this class or interface that have the specified method name
52 * and parameter types.
249 * given layer, the remaining elements are its parents, in DFS order.
250 */
251 Stream<ModuleLayer> layers(ModuleLayer layer);
252
253 /**
254 * Returns a stream of the layers that have modules defined to the
255 * given class loader.
256 */
257 Stream<ModuleLayer> layers(ClassLoader loader);
258
259 /**
260 * Constructs a new {@code String} by decoding the specified subarray of
261 * bytes using the specified {@linkplain java.nio.charset.Charset charset}.
262 *
263 * The caller of this method shall relinquish and transfer the ownership of
264 * the byte array to the callee since the later will not make a copy.
265 *
266 * @param bytes the byte array source
267 * @param cs the Charset
268 * @return the newly created string
269 * @throws IllegalArgumentException for malformed or unmappable bytes
270 */
271 String newStringNoRepl(byte[] bytes, Charset cs);
272
273 /**
274 * Encode the given string into a sequence of bytes using the specified Charset.
275 *
276 * This method avoids copying the String's internal representation if the input
277 * is ASCII.
278 *
279 * This method throws IllegalArgumentException instead of replacing when
280 * malformed input or unmappable characters are encountered.
281 *
282 * @param s the string to encode
283 * @param cs the charset
284 * @return the encoded bytes
285 * @throws IllegalArgumentException for malformed input or unmappable characters
286 */
287 byte[] getBytesNoRepl(String s, Charset cs);
288
289 /**
290 * Returns a new string by decoding from the given utf8 bytes array.
291 *
292 * @param off the index of the first byte to decode
293 * @param len the number of bytes to decode
294 * @return the newly created string
295 * @throws IllegalArgumentException for malformed or unmappable bytes.
296 */
297 String newStringUTF8NoRepl(byte[] bytes, int off, int len);
298
299 /**
300 * Encode the given string into a sequence of bytes using utf8.
301 *
302 * @param s the string to encode
303 * @return the encoded bytes in utf8
304 * @throws IllegalArgumentException for malformed surrogates
305 */
306 byte[] getBytesUTF8NoRepl(String s);
307 }
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.internal.misc;
27
28 import java.lang.annotation.Annotation;
29 import java.lang.module.ModuleDescriptor;
30 import java.lang.reflect.Executable;
31 import java.lang.reflect.Method;
32 import java.net.URI;
33 import java.nio.charset.CharacterCodingException;
34 import java.nio.charset.Charset;
35 import java.security.AccessControlContext;
36 import java.security.ProtectionDomain;
37 import java.util.Iterator;
38 import java.util.List;
39 import java.util.Map;
40 import java.util.concurrent.ConcurrentHashMap;
41 import java.util.stream.Stream;
42
43 import jdk.internal.module.ServicesCatalog;
44 import jdk.internal.reflect.ConstantPool;
45 import sun.reflect.annotation.AnnotationType;
46 import sun.nio.ch.Interruptible;
47
48 public interface JavaLangAccess {
49
50 /**
51 * Returns the list of {@code Method} objects for the declared public
52 * methods of this class or interface that have the specified method name
53 * and parameter types.
250 * given layer, the remaining elements are its parents, in DFS order.
251 */
252 Stream<ModuleLayer> layers(ModuleLayer layer);
253
254 /**
255 * Returns a stream of the layers that have modules defined to the
256 * given class loader.
257 */
258 Stream<ModuleLayer> layers(ClassLoader loader);
259
260 /**
261 * Constructs a new {@code String} by decoding the specified subarray of
262 * bytes using the specified {@linkplain java.nio.charset.Charset charset}.
263 *
264 * The caller of this method shall relinquish and transfer the ownership of
265 * the byte array to the callee since the later will not make a copy.
266 *
267 * @param bytes the byte array source
268 * @param cs the Charset
269 * @return the newly created string
270 * @throws CharacterCodingException for malformed or unmappable bytes
271 */
272 String newStringNoRepl(byte[] bytes, Charset cs) throws CharacterCodingException;
273
274 /**
275 * Encode the given string into a sequence of bytes using the specified Charset.
276 *
277 * This method avoids copying the String's internal representation if the input
278 * is ASCII.
279 *
280 * This method throws CharacterCodingException instead of replacing when
281 * malformed input or unmappable characters are encountered.
282 *
283 * @param s the string to encode
284 * @param cs the charset
285 * @return the encoded bytes
286 * @throws CharacterCodingException for malformed input or unmappable characters
287 */
288 byte[] getBytesNoRepl(String s, Charset cs) throws CharacterCodingException;
289
290 /**
291 * Returns a new string by decoding from the given utf8 bytes array.
292 *
293 * @param off the index of the first byte to decode
294 * @param len the number of bytes to decode
295 * @return the newly created string
296 * @throws IllegalArgumentException for malformed or unmappable bytes.
297 */
298 String newStringUTF8NoRepl(byte[] bytes, int off, int len);
299
300 /**
301 * Encode the given string into a sequence of bytes using utf8.
302 *
303 * @param s the string to encode
304 * @return the encoded bytes in utf8
305 * @throws IllegalArgumentException for malformed surrogates
306 */
307 byte[] getBytesUTF8NoRepl(String s);
308 }
|