mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-26 21:38:10 +00:00
7080020: Add conventional constructors to InternalError and VirtualMachineError
Reviewed-by: darcy
This commit is contained in:
parent
92aac562e6
commit
765c6904e3
@ -101,10 +101,7 @@ class SunConnection {
|
||||
return new URL(registerURL);
|
||||
} catch (MalformedURLException ex) {
|
||||
// should never reach here
|
||||
InternalError x =
|
||||
new InternalError(ex.getMessage());
|
||||
x.initCause(ex);
|
||||
throw x;
|
||||
throw new InternalError(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,9 +168,7 @@ class SunConnection {
|
||||
try {
|
||||
BrowserSupport.browse(url.toURI());
|
||||
} catch (URISyntaxException ex) {
|
||||
InternalError x = new InternalError("Error in registering: " + ex.getMessage());
|
||||
x.initCause(ex);
|
||||
throw x;
|
||||
throw new InternalError("Error in registering: " + ex.getMessage(), ex);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
if (Util.isVerbose()) {
|
||||
ex.printStackTrace();
|
||||
@ -232,9 +227,7 @@ class SunConnection {
|
||||
return (returnCode == HttpURLConnection.HTTP_OK);
|
||||
} catch (MalformedURLException me) {
|
||||
// should never reach here
|
||||
InternalError x = new InternalError("Error in registering: " + me.getMessage());
|
||||
x.initCause(me);
|
||||
throw x;
|
||||
throw new InternalError("Error in registering: " + me.getMessage(), me);
|
||||
} catch (Exception ioe) {
|
||||
// SocketTimeoutException, IOException or UnknownHostException
|
||||
if (Util.isVerbose()) {
|
||||
@ -262,10 +255,9 @@ class SunConnection {
|
||||
BrowserSupport.browse(registerPage.toURI());
|
||||
} catch (FileNotFoundException ex) {
|
||||
// should never reach here
|
||||
InternalError x =
|
||||
new InternalError("Error in launching " + registerPage + ": " + ex.getMessage());
|
||||
x.initCause(ex);
|
||||
throw x;
|
||||
throw new InternalError(
|
||||
"Error in launching " + registerPage + ": " + ex.getMessage()
|
||||
, ex);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
if (Util.isVerbose()) {
|
||||
ex.printStackTrace();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2011, 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
|
||||
@ -32,8 +32,7 @@ package java.lang;
|
||||
* @author unascribed
|
||||
* @since JDK1.0
|
||||
*/
|
||||
public
|
||||
class InternalError extends VirtualMachineError {
|
||||
public class InternalError extends VirtualMachineError {
|
||||
private static final long serialVersionUID = -9062593416125562365L;
|
||||
|
||||
/**
|
||||
@ -47,9 +46,45 @@ class InternalError extends VirtualMachineError {
|
||||
* Constructs an <code>InternalError</code> with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param s the detail message.
|
||||
* @param message the detail message.
|
||||
*/
|
||||
public InternalError(String s) {
|
||||
super(s);
|
||||
public InternalError(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an {@code InternalError} with the specified detail
|
||||
* message and cause. <p>Note that the detail message associated
|
||||
* with {@code cause} is <i>not</i> automatically incorporated in
|
||||
* this error's detail message.
|
||||
*
|
||||
* @param message the detail message (which is saved for later retrieval
|
||||
* by the {@link #getMessage()} method).
|
||||
* @param cause the cause (which is saved for later retrieval by the
|
||||
* {@link #getCause()} method). (A {@code null} value is
|
||||
* permitted, and indicates that the cause is nonexistent or
|
||||
* unknown.)
|
||||
* @since 1.8
|
||||
*/
|
||||
public InternalError(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an {@code InternalError} with the specified cause
|
||||
* and a detail message of {@code (cause==null ? null :
|
||||
* cause.toString())} (which typically contains the class and
|
||||
* detail message of {@code cause}).
|
||||
*
|
||||
* @param cause the cause (which is saved for later retrieval by the
|
||||
* {@link #getCause()} method). (A {@code null} value is
|
||||
* permitted, and indicates that the cause is nonexistent or
|
||||
* unknown.)
|
||||
* @since 1.8
|
||||
*/
|
||||
public InternalError(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2011, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* under the terms of the GNU General Public License version 2 only, asP
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
@ -33,8 +33,7 @@ package java.lang;
|
||||
* @author Frank Yellin
|
||||
* @since JDK1.0
|
||||
*/
|
||||
abstract public
|
||||
class VirtualMachineError extends Error {
|
||||
abstract public class VirtualMachineError extends Error {
|
||||
/**
|
||||
* Constructs a <code>VirtualMachineError</code> with no detail message.
|
||||
*/
|
||||
@ -46,9 +45,43 @@ class VirtualMachineError extends Error {
|
||||
* Constructs a <code>VirtualMachineError</code> with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param s the detail message.
|
||||
* @param message the detail message.
|
||||
*/
|
||||
public VirtualMachineError(String s) {
|
||||
super(s);
|
||||
public VirtualMachineError(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code VirtualMachineError} with the specified
|
||||
* detail message and cause. <p>Note that the detail message
|
||||
* associated with {@code cause} is <i>not</i> automatically
|
||||
* incorporated in this error's detail message.
|
||||
*
|
||||
* @param message the detail message (which is saved for later retrieval
|
||||
* by the {@link #getMessage()} method).
|
||||
* @param cause the cause (which is saved for later retrieval by the
|
||||
* {@link #getCause()} method). (A {@code null} value is
|
||||
* permitted, and indicates that the cause is nonexistent or
|
||||
* unknown.)
|
||||
* @since 1.8
|
||||
*/
|
||||
public VirtualMachineError(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an a {@code VirtualMachineError} with the specified
|
||||
* cause and a detail message of {@code (cause==null ? null :
|
||||
* cause.toString())} (which typically contains the class and
|
||||
* detail message of {@code cause}).
|
||||
*
|
||||
* @param cause the cause (which is saved for later retrieval by the
|
||||
* {@link #getCause()} method). (A {@code null} value is
|
||||
* permitted, and indicates that the cause is nonexistent or
|
||||
* unknown.)
|
||||
* @since 1.8
|
||||
*/
|
||||
public VirtualMachineError(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,11 +256,9 @@ public abstract class Preferences {
|
||||
.getContextClassLoader())
|
||||
.newInstance();
|
||||
} catch (Exception e) {
|
||||
InternalError error = new InternalError(
|
||||
throw new InternalError(
|
||||
"Can't instantiate Preferences factory "
|
||||
+ factoryName);
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
+ factoryName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -299,11 +297,9 @@ public abstract class Preferences {
|
||||
return (PreferencesFactory)
|
||||
Class.forName(platformFactory, false, null).newInstance();
|
||||
} catch (Exception e) {
|
||||
InternalError error = new InternalError(
|
||||
throw new InternalError(
|
||||
"Can't instantiate platform default Preferences factory "
|
||||
+ platformFactory);
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
+ platformFactory, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -78,20 +78,11 @@ public final class FontManagerFactory {
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||
Class fmClass = Class.forName(fmClassName, true, cl);
|
||||
instance = (FontManager) fmClass.newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
InternalError err = new InternalError();
|
||||
err.initCause(ex);
|
||||
throw err;
|
||||
} catch (ClassNotFoundException |
|
||||
InstantiationException |
|
||||
IllegalAccessException ex) {
|
||||
throw new InternalError(ex);
|
||||
|
||||
} catch (InstantiationException ex) {
|
||||
InternalError err = new InternalError();
|
||||
err.initCause(ex);
|
||||
throw err;
|
||||
|
||||
} catch (IllegalAccessException ex) {
|
||||
InternalError err = new InternalError();
|
||||
err.initCause(ex);
|
||||
throw err;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -717,7 +717,7 @@ public class URLClassPath {
|
||||
try {
|
||||
ensureOpen();
|
||||
} catch (IOException e) {
|
||||
throw (InternalError) new InternalError().initCause(e);
|
||||
throw new InternalError(e);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
@ -812,7 +812,7 @@ public class URLClassPath {
|
||||
try {
|
||||
ensureOpen();
|
||||
} catch (IOException e) {
|
||||
throw (InternalError) new InternalError().initCause(e);
|
||||
throw new InternalError(e);
|
||||
}
|
||||
final JarEntry entry = jar.getJarEntry(name);
|
||||
if (entry != null)
|
||||
@ -900,7 +900,7 @@ public class URLClassPath {
|
||||
try {
|
||||
newLoader.ensureOpen();
|
||||
} catch (IOException e) {
|
||||
throw (InternalError) new InternalError().initCause(e);
|
||||
throw new InternalError(e);
|
||||
}
|
||||
final JarEntry entry = newLoader.jar.getJarEntry(name);
|
||||
if (entry != null) {
|
||||
|
||||
@ -401,10 +401,8 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
0,
|
||||
bytes.length,
|
||||
declaringClass.getClassLoader()).newInstance();
|
||||
} catch (InstantiationException |
|
||||
IllegalAccessException e) {
|
||||
throw (InternalError)
|
||||
new InternalError().initCause(e);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -1401,8 +1401,7 @@ public class X500Name implements GeneralNameInterface, Principal {
|
||||
principalConstructor = constr;
|
||||
principalField = (Field)result[1];
|
||||
} catch (Exception e) {
|
||||
throw (InternalError)new InternalError("Could not obtain "
|
||||
+ "X500Principal access").initCause(e);
|
||||
throw new InternalError("Could not obtain X500Principal access", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -208,7 +208,7 @@ public class ProxyClient implements JConsoleContext {
|
||||
serverStubClass = Class.forName(rmiServerImplStubClassName).asSubclass(Remote.class);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// should never reach here
|
||||
throw (InternalError) new InternalError(e.getMessage()).initCause(e);
|
||||
throw new InternalError(e.getMessage(), e);
|
||||
}
|
||||
rmiServerImplStubClass = serverStubClass;
|
||||
}
|
||||
@ -395,18 +395,10 @@ public class ProxyClient implements JConsoleContext {
|
||||
} catch (MalformedObjectNameException e) {
|
||||
// should not reach here
|
||||
throw new InternalError(e.getMessage());
|
||||
} catch (IntrospectionException e) {
|
||||
InternalError ie = new InternalError(e.getMessage());
|
||||
ie.initCause(e);
|
||||
throw ie;
|
||||
} catch (InstanceNotFoundException e) {
|
||||
InternalError ie = new InternalError(e.getMessage());
|
||||
ie.initCause(e);
|
||||
throw ie;
|
||||
} catch (ReflectionException e) {
|
||||
InternalError ie = new InternalError(e.getMessage());
|
||||
ie.initCause(e);
|
||||
throw ie;
|
||||
} catch (IntrospectionException |
|
||||
InstanceNotFoundException |
|
||||
ReflectionException e) {
|
||||
throw new InternalError(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (hasPlatformMXBeans) {
|
||||
|
||||
@ -55,9 +55,7 @@ public class WindowsAsynchronousFileChannelImpl
|
||||
try {
|
||||
return new Iocp(null, ThreadPool.createDefault()).start();
|
||||
} catch (IOException ioe) {
|
||||
InternalError e = new InternalError();
|
||||
e.initCause(ioe);
|
||||
throw e;
|
||||
throw new InternalError(ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user