8325189: Enable this-escape javac warning in java.base

Reviewed-by: alanb, erikj, naoto, smarks, ihse, joehw, lancea, weijun
This commit is contained in:
Joe Darcy 2024-02-07 20:05:11 +00:00
parent 299a8ee68d
commit fbd15b2087
93 changed files with 151 additions and 2 deletions

View file

@ -71,6 +71,7 @@ public class AssertionError extends Error {
* @param detailMessage value to be used in constructing detail message
* @see Throwable#getCause()
*/
@SuppressWarnings("this-escape")
public AssertionError(Object detailMessage) {
this(String.valueOf(detailMessage));
if (detailMessage instanceof Throwable)

View file

@ -77,6 +77,7 @@ public class BootstrapMethodError extends LinkageError {
*
* @param cause the cause, may be {@code null}.
*/
@SuppressWarnings("this-escape")
public BootstrapMethodError(Throwable cause) {
// cf. Throwable(Throwable cause) constructor.
super(cause == null ? null : cause.toString());

View file

@ -431,6 +431,7 @@ public abstract class ClassLoader {
*
* @since 9
*/
@SuppressWarnings("this-escape")
protected ClassLoader(String name, ClassLoader parent) {
this(checkCreateClassLoader(name), name, parent);
}
@ -457,6 +458,7 @@ public abstract class ClassLoader {
*
* @since 1.2
*/
@SuppressWarnings("this-escape")
protected ClassLoader(ClassLoader parent) {
this(checkCreateClassLoader(), null, parent);
}
@ -476,6 +478,7 @@ public abstract class ClassLoader {
* {@code checkCreateClassLoader} method doesn't allow creation
* of a new class loader.
*/
@SuppressWarnings("this-escape")
protected ClassLoader() {
this(checkCreateClassLoader(), null, getSystemClassLoader());
}

View file

@ -52,6 +52,7 @@ public class ExceptionInInitializerError extends LinkageError {
* throwable object.
* A detail message is a String that describes this particular exception.
*/
@SuppressWarnings("this-escape")
public ExceptionInInitializerError() {
initCause(null); // Disallow subsequent initCause
}

View file

@ -162,6 +162,7 @@ public class ThreadGroup implements Thread.UncaughtExceptionHandler {
* thread in the specified thread group.
* @see java.lang.ThreadGroup#checkAccess()
*/
@SuppressWarnings("this-escape")
public ThreadGroup(ThreadGroup parent, String name) {
this(checkParentAccess(parent), parent, name);
}

View file

@ -260,6 +260,7 @@ public class Throwable implements Serializable {
* <p>The {@link #fillInStackTrace()} method is called to initialize
* the stack trace data in the newly created throwable.
*/
@SuppressWarnings("this-escape")
public Throwable() {
fillInStackTrace();
if (jfrTracing) {
@ -278,6 +279,7 @@ public class Throwable implements Serializable {
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
*/
@SuppressWarnings("this-escape")
public Throwable(String message) {
fillInStackTrace();
detailMessage = message;
@ -303,6 +305,7 @@ public class Throwable implements Serializable {
* unknown.)
* @since 1.4
*/
@SuppressWarnings("this-escape")
public Throwable(String message, Throwable cause) {
fillInStackTrace();
detailMessage = message;
@ -329,6 +332,7 @@ public class Throwable implements Serializable {
* unknown.)
* @since 1.4
*/
@SuppressWarnings("this-escape")
public Throwable(Throwable cause) {
fillInStackTrace();
detailMessage = (cause==null ? null : cause.toString());
@ -378,6 +382,7 @@ public class Throwable implements Serializable {
* @see ArithmeticException
* @since 1.7
*/
@SuppressWarnings("this-escape")
protected Throwable(String message, Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {