Skip to content

Commit

Permalink
Android Oreo: update java.jang (part 1).
Browse files Browse the repository at this point in the history
	Change on 2018/12/03 by antoniocortes <antoniocortes@google.com>

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223803606
  • Loading branch information
antonio-cortes-perez committed Dec 12, 2018
1 parent 66b2cd3 commit 729c340
Show file tree
Hide file tree
Showing 28 changed files with 902 additions and 316 deletions.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,7 +29,7 @@
* Thrown to indicate that an attempt has been made to store the * Thrown to indicate that an attempt has been made to store the
* wrong type of object into an array of objects. For example, the * wrong type of object into an array of objects. For example, the
* following code generates an <code>ArrayStoreException</code>: * following code generates an <code>ArrayStoreException</code>:
* <p><blockquote><pre> * <blockquote><pre>
* Object x[] = new String[3]; * Object x[] = new String[3];
* x[0] = new Integer(0); * x[0] = new Integer(0);
* </pre></blockquote> * </pre></blockquote>
Expand Down
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -71,7 +71,7 @@ private AssertionError(String detailMessage) {
* @see Throwable#getCause() * @see Throwable#getCause()
*/ */
public AssertionError(Object detailMessage) { public AssertionError(Object detailMessage) {
this("" + detailMessage); this(String.valueOf(detailMessage));
if (detailMessage instanceof Throwable) if (detailMessage instanceof Throwable)
initCause((Throwable) detailMessage); initCause((Throwable) detailMessage);
} }
Expand All @@ -85,7 +85,7 @@ public AssertionError(Object detailMessage) {
* @param detailMessage value to be used in constructing detail message * @param detailMessage value to be used in constructing detail message
*/ */
public AssertionError(boolean detailMessage) { public AssertionError(boolean detailMessage) {
this("" + detailMessage); this(String.valueOf(detailMessage));
} }


/** /**
Expand All @@ -97,7 +97,7 @@ public AssertionError(boolean detailMessage) {
* @param detailMessage value to be used in constructing detail message * @param detailMessage value to be used in constructing detail message
*/ */
public AssertionError(char detailMessage) { public AssertionError(char detailMessage) {
this("" + detailMessage); this(String.valueOf(detailMessage));
} }


/** /**
Expand All @@ -109,7 +109,7 @@ public AssertionError(char detailMessage) {
* @param detailMessage value to be used in constructing detail message * @param detailMessage value to be used in constructing detail message
*/ */
public AssertionError(int detailMessage) { public AssertionError(int detailMessage) {
this("" + detailMessage); this(String.valueOf(detailMessage));
} }


/** /**
Expand All @@ -121,7 +121,7 @@ public AssertionError(int detailMessage) {
* @param detailMessage value to be used in constructing detail message * @param detailMessage value to be used in constructing detail message
*/ */
public AssertionError(long detailMessage) { public AssertionError(long detailMessage) {
this("" + detailMessage); this(String.valueOf(detailMessage));
} }


/** /**
Expand All @@ -133,7 +133,7 @@ public AssertionError(long detailMessage) {
* @param detailMessage value to be used in constructing detail message * @param detailMessage value to be used in constructing detail message
*/ */
public AssertionError(float detailMessage) { public AssertionError(float detailMessage) {
this("" + detailMessage); this(String.valueOf(detailMessage));
} }


/** /**
Expand All @@ -145,7 +145,7 @@ public AssertionError(float detailMessage) {
* @param detailMessage value to be used in constructing detail message * @param detailMessage value to be used in constructing detail message
*/ */
public AssertionError(double detailMessage) { public AssertionError(double detailMessage) {
this("" + detailMessage); this(String.valueOf(detailMessage));
} }


/** /**
Expand Down
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,47 +26,28 @@
package java.lang; package java.lang;


/** /**
* A resource that must be closed when it is no longer needed. * An object that may hold resources (such as file or socket handles)
* until it is closed. The {@link #close()} method of an {@code AutoCloseable}
* object is called automatically when exiting a {@code
* try}-with-resources block for which the object has been declared in
* the resource specification header. This construction ensures prompt
* release, avoiding resource exhaustion exceptions and errors that
* may otherwise occur.
*
* @apiNote
* <p>It is possible, and in fact common, for a base class to
* implement AutoCloseable even though not all of its subclasses or
* instances will hold releasable resources. For code that must operate
* in complete generality, or when it is known that the {@code AutoCloseable}
* instance requires resource release, it is recommended to use {@code
* try}-with-resources constructions. However, when using facilities such as
* {@link java.util.stream.Stream} that support both I/O-based and
* non-I/O-based forms, {@code try}-with-resources blocks are in
* general unnecessary when using non-I/O-based forms.
* *
* @author Josh Bloch * @author Josh Bloch
* @since 1.7 * @since 1.7
*/ */
public interface AutoCloseable { public interface AutoCloseable {
/**
* Closes this resource, relinquishing any underlying resources.
* This method is invoked automatically on objects managed by the
* {@code try}-with-resources statement.
*
* <p>While this interface method is declared to throw {@code
* Exception}, implementers are <em>strongly</em> encouraged to
* declare concrete implementations of the {@code close} method to
* throw more specific exceptions, or to throw no exception at all
* if the close operation cannot fail.
*
* <p><em>Implementers of this interface are also strongly advised
* to not have the {@code close} method throw {@link
* InterruptedException}.</em>
*
* This exception interacts with a thread's interrupted status,
* and runtime misbehavior is likely to occur if an {@code
* InterruptedException} is {@linkplain Throwable#addSuppressed
* suppressed}.
*
* More generally, if it would cause problems for an
* exception to be suppressed, the {@code AutoCloseable.close}
* method should not throw it.
*
* <p>Note that unlike the {@link java.io.Closeable#close close}
* method of {@link java.io.Closeable}, this {@code close} method
* is <em>not</em> required to be idempotent. In other words,
* calling this {@code close} method more than once may have some
* visible side effect, unlike {@code Closeable.close} which is
* required to have no effect if called more than once.
*
* However, implementers of this interface are strongly encouraged
* to make their {@code close} methods idempotent.
*
* @throws Exception if this resource cannot be closed
*/
void close() throws Exception; void close() throws Exception;
} }
@@ -1,5 +1,4 @@
/* /*
* Copyright (C) 2014 The Android Open Source Project
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
Expand Down Expand Up @@ -60,6 +59,7 @@ public final class Byte extends Number implements Comparable<Byte> {
* The {@code Class} instance representing the primitive type * The {@code Class} instance representing the primitive type
* {@code byte}. * {@code byte}.
*/ */
@SuppressWarnings("unchecked")
public static final Class<Byte> TYPE = (Class<Byte>) byte[].class.getComponentType(); public static final Class<Byte> TYPE = (Class<Byte>) byte[].class.getComponentType();


/** /**
Expand Down Expand Up @@ -122,8 +122,8 @@ public static Byte valueOf(byte b) {
* determined by whether {@link java.lang.Character#digit(char, * determined by whether {@link java.lang.Character#digit(char,
* int)} returns a nonnegative value) except that the first * int)} returns a nonnegative value) except that the first
* character may be an ASCII minus sign {@code '-'} * character may be an ASCII minus sign {@code '-'}
* (<code>'&#92;u002D'</code>) to indicate a negative value or an * ({@code '\u005Cu002D'}) to indicate a negative value or an
* ASCII plus sign {@code '+'} (<code>'&#92;u002B'</code>) to * ASCII plus sign {@code '+'} ({@code '\u005Cu002B'}) to
* indicate a positive value. The resulting {@code byte} value is * indicate a positive value. The resulting {@code byte} value is
* returned. * returned.
* *
Expand All @@ -139,8 +139,8 @@ public static Byte valueOf(byte b) {
* *
* <li> Any character of the string is not a digit of the * <li> Any character of the string is not a digit of the
* specified radix, except that the first character may be a minus * specified radix, except that the first character may be a minus
* sign {@code '-'} (<code>'&#92;u002D'</code>) or plus sign * sign {@code '-'} ({@code '\u005Cu002D'}) or plus sign
* {@code '+'} (<code>'&#92;u002B'</code>) provided that the * {@code '+'} ({@code '\u005Cu002B'}) provided that the
* string is longer than length 1. * string is longer than length 1.
* *
* <li> The value represented by the string is not a value of type * <li> The value represented by the string is not a value of type
Expand Down Expand Up @@ -169,9 +169,9 @@ public static byte parseByte(String s, int radix)
* Parses the string argument as a signed decimal {@code * Parses the string argument as a signed decimal {@code
* byte}. The characters in the string must all be decimal digits, * byte}. The characters in the string must all be decimal digits,
* except that the first character may be an ASCII minus sign * except that the first character may be an ASCII minus sign
* {@code '-'} (<code>'&#92;u002D'</code>) to indicate a negative * {@code '-'} ({@code '\u005Cu002D'}) to indicate a negative
* value or an ASCII plus sign {@code '+'} * value or an ASCII plus sign {@code '+'}
* (<code>'&#92;u002B'</code>) to indicate a positive value. The * ({@code '\u005Cu002B'}) to indicate a positive value. The
* resulting {@code byte} value is returned, exactly as if the * resulting {@code byte} value is returned, exactly as if the
* argument and the radix 10 were given as arguments to the {@link * argument and the radix 10 were given as arguments to the {@link
* #parseByte(java.lang.String, int)} method. * #parseByte(java.lang.String, int)} method.
Expand Down Expand Up @@ -256,7 +256,7 @@ public static Byte valueOf(String s) throws NumberFormatException {
* <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i> * <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
* <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i> * <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
* <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i> * <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
* <p> *
* <dt><i>Sign:</i> * <dt><i>Sign:</i>
* <dd>{@code -} * <dd>{@code -}
* <dd>{@code +} * <dd>{@code +}
Expand Down Expand Up @@ -337,40 +337,45 @@ public byte byteValue() {
} }


/** /**
* Returns the value of this {@code Byte} as a * Returns the value of this {@code Byte} as a {@code short} after
* {@code short}. * a widening primitive conversion.
* @jls 5.1.2 Widening Primitive Conversions
*/ */
public short shortValue() { public short shortValue() {
return (short)value; return (short)value;
} }


/** /**
* Returns the value of this {@code Byte} as an * Returns the value of this {@code Byte} as an {@code int} after
* {@code int}. * a widening primitive conversion.
* @jls 5.1.2 Widening Primitive Conversions
*/ */
public int intValue() { public int intValue() {
return (int)value; return (int)value;
} }


/** /**
* Returns the value of this {@code Byte} as a * Returns the value of this {@code Byte} as a {@code long} after
* {@code long}. * a widening primitive conversion.
* @jls 5.1.2 Widening Primitive Conversions
*/ */
public long longValue() { public long longValue() {
return (long)value; return (long)value;
} }


/** /**
* Returns the value of this {@code Byte} as a * Returns the value of this {@code Byte} as a {@code float} after
* {@code float}. * a widening primitive conversion.
* @jls 5.1.2 Widening Primitive Conversions
*/ */
public float floatValue() { public float floatValue() {
return (float)value; return (float)value;
} }


/** /**
* Returns the value of this {@code Byte} as a * Returns the value of this {@code Byte} as a {@code double}
* {@code double}. * after a widening primitive conversion.
* @jls 5.1.2 Widening Primitive Conversions
*/ */
public double doubleValue() { public double doubleValue() {
return (double)value; return (double)value;
Expand All @@ -396,6 +401,7 @@ public String toString() {
* *
* @return a hash code value for this {@code Byte} * @return a hash code value for this {@code Byte}
*/ */
@Override
public int hashCode() { public int hashCode() {
return Byte.hashCode(value); return Byte.hashCode(value);
} }
Expand Down Expand Up @@ -464,6 +470,47 @@ public static int compare(byte x, byte y) {
return x - y; return x - y;
} }


/**
* Converts the argument to an {@code int} by an unsigned
* conversion. In an unsigned conversion to an {@code int}, the
* high-order 24 bits of the {@code int} are zero and the
* low-order 8 bits are equal to the bits of the {@code byte} argument.
*
* Consequently, zero and positive {@code byte} values are mapped
* to a numerically equal {@code int} value and negative {@code
* byte} values are mapped to an {@code int} value equal to the
* input plus 2<sup>8</sup>.
*
* @param x the value to convert to an unsigned {@code int}
* @return the argument converted to {@code int} by an unsigned
* conversion
* @since 1.8
*/
public static int toUnsignedInt(byte x) {
return ((int) x) & 0xff;
}

/**
* Converts the argument to a {@code long} by an unsigned
* conversion. In an unsigned conversion to a {@code long}, the
* high-order 56 bits of the {@code long} are zero and the
* low-order 8 bits are equal to the bits of the {@code byte} argument.
*
* Consequently, zero and positive {@code byte} values are mapped
* to a numerically equal {@code long} value and negative {@code
* byte} values are mapped to a {@code long} value equal to the
* input plus 2<sup>8</sup>.
*
* @param x the value to convert to an unsigned {@code long}
* @return the argument converted to {@code long} by an unsigned
* conversion
* @since 1.8
*/
public static long toUnsignedLong(byte x) {
return ((long) x) & 0xffL;
}


/** /**
* The number of bits used to represent a {@code byte} value in two's * The number of bits used to represent a {@code byte} value in two's
* complement binary form. * complement binary form.
Expand All @@ -483,7 +530,8 @@ public static int compare(byte x, byte y) {
/** use serialVersionUID from JDK 1.1. for interoperability */ /** use serialVersionUID from JDK 1.1. for interoperability */
private static final long serialVersionUID = -7183698231559129828L; private static final long serialVersionUID = -7183698231559129828L;


/** ----- BEGIN android ----- // BEGIN Android-changed
/**
* @hide * @hide
*/ */
public static String toHexString(byte b, boolean upperCase) { public static String toHexString(byte b, boolean upperCase) {
Expand Down
Expand Up @@ -49,7 +49,7 @@
* is no guarantee that each class will be capable of testing its instances * is no guarantee that each class will be capable of testing its instances
* for equality with those of the other. It is therefore inappropriate to use * for equality with those of the other. It is therefore inappropriate to use
* arbitrary <tt>CharSequence</tt> instances as elements in a set or as keys in * arbitrary <tt>CharSequence</tt> instances as elements in a set or as keys in
* a map. <p/> * a map. </p>
* *
* @author Mike McCloskey * @author Mike McCloskey
* @since 1.4 * @since 1.4
Expand Down Expand Up @@ -87,7 +87,7 @@ public interface CharSequence {
char charAt(int index); char charAt(int index);


/** /**
* Returns a new <code>CharSequence</code> that is a subsequence of this sequence. * Returns a <code>CharSequence</code> that is a subsequence of this sequence.
* The subsequence starts with the <code>char</code> value at the specified index and * The subsequence starts with the <code>char</code> value at the specified index and
* ends with the <code>char</code> value at index <tt>end - 1</tt>. The length * ends with the <code>char</code> value at index <tt>end - 1</tt>. The length
* (in <code>char</code>s) of the * (in <code>char</code>s) of the
Expand Down
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,7 +29,7 @@
* Thrown to indicate that the code has attempted to cast an object * Thrown to indicate that the code has attempted to cast an object
* to a subclass of which it is not an instance. For example, the * to a subclass of which it is not an instance. For example, the
* following code generates a <code>ClassCastException</code>: * following code generates a <code>ClassCastException</code>:
* <p><blockquote><pre> * <blockquote><pre>
* Object x = new Integer(0); * Object x = new Integer(0);
* System.out.println((String)x); * System.out.println((String)x);
* </pre></blockquote> * </pre></blockquote>
Expand Down

0 comments on commit 729c340

Please sign in to comment.