提交 a09538be 编写于 作者: A asaha

Merge

/* /*
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, 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
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#define JVM_ERROR1 "Error: Could not create the Java Virtual Machine.\n" GEN_ERROR #define JVM_ERROR1 "Error: Could not create the Java Virtual Machine.\n" GEN_ERROR
#define JVM_ERROR2 "Error: Could not detach main thread.\n" JNI_ERROR #define JVM_ERROR2 "Error: Could not detach main thread.\n" JNI_ERROR
#define JVM_ERROR3 "Error: SPARC V8 processor detected; Server compiler requires V9 or better.\nUse Client compiler on V8 processors.\nCould not create the Java virtual machine." #define JVM_ERROR3 "Error: SPARC V8 processor detected; Required V9 processors or better.\nUse JDK5 client compiler for V8 processors.\n" JVM_ERROR1
#define JAR_ERROR1 "Error: Failed to load Main-Class manifest attribute from\n%s\n%s" #define JAR_ERROR1 "Error: Failed to load Main-Class manifest attribute from\n%s\n%s"
#define JAR_ERROR2 "Error: Unable to access jarfile %s" #define JAR_ERROR2 "Error: Unable to access jarfile %s"
...@@ -69,7 +69,8 @@ ...@@ -69,7 +69,8 @@
#define CFG_ERROR5 "Error: Could not determine application home." #define CFG_ERROR5 "Error: Could not determine application home."
#define CFG_ERROR6 "Error: could not open `%s'" #define CFG_ERROR6 "Error: could not open `%s'"
#define CFG_ERROR7 "Error: no known VMs. (check for corrupt jvm.cfg file)" #define CFG_ERROR7 "Error: no known VMs. (check for corrupt jvm.cfg file)"
#define CFG_ERROR8 "Error: no `%s' JVM at `%s'." #define CFG_ERROR8 "Error: missing `%s' JVM at `%s'.\nPlease install or use the JRE or JDK that contains these missing components."
#define CFG_ERROR9 "Error: could not determine JVM type."
#define SPC_ERROR1 "Error: Syntax error in version specification \"%s\"" #define SPC_ERROR1 "Error: Syntax error in version specification \"%s\""
......
/* /*
* Copyright (c) 1995, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2010, 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
...@@ -192,8 +192,8 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ ...@@ -192,8 +192,8 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
int ret; int ret;
InvocationFunctions ifn; InvocationFunctions ifn;
jlong start, end; jlong start, end;
char jrepath[MAXPATHLEN], jvmpath[MAXPATHLEN]; char jvmpath[MAXPATHLEN];
char ** original_argv = argv; char jrepath[MAXPATHLEN];
_fVersion = fullversion; _fVersion = fullversion;
_dVersion = dotversion; _dVersion = dotversion;
...@@ -225,14 +225,17 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ ...@@ -225,14 +225,17 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
*/ */
SelectVersion(argc, argv, &main_class); SelectVersion(argc, argv, &main_class);
/* copy original argv */ if (JLI_IsTraceLauncher()) {
JLI_TraceLauncher("Command line Args:\n"); int i;
original_argv = (JLI_CopyArgs(argc, (const char**)argv)); printf("Command line args:\n");
for (i = 0; i < argc ; i++) {
printf("argv[%d] = %s\n", i, argv[i]);
}
}
CreateExecutionEnvironment(&argc, &argv, CreateExecutionEnvironment(&argc, &argv,
jrepath, sizeof(jrepath), jrepath, sizeof(jrepath),
jvmpath, sizeof(jvmpath), jvmpath, sizeof(jvmpath));
original_argv);
ifn.CreateJavaVM = 0; ifn.CreateJavaVM = 0;
ifn.GetDefaultJavaVMInitArgs = 0; ifn.GetDefaultJavaVMInitArgs = 0;
...@@ -301,22 +304,43 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ ...@@ -301,22 +304,43 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
return ContinueInNewThread(&ifn, argc, argv, jarfile, classname, ret); return ContinueInNewThread(&ifn, argc, argv, jarfile, classname, ret);
} }
/*
* Always detach the main thread so that it appears to have ended when
* the application's main method exits. This will invoke the
* uncaught exception handler machinery if main threw an
* exception. An uncaught exception handler cannot change the
* launcher's return code except by calling System.exit.
*
* Wait for all non-daemon threads to end, then destroy the VM.
* This will actually create a trivial new Java waiter thread
* named "DestroyJavaVM", but this will be seen as a different
* thread from the one that executed main, even though they are
* the same C thread. This allows mainThread.join() and
* mainThread.isAlive() to work as expected.
*/
#define LEAVE() \
if ((*vm)->DetachCurrentThread(vm) != 0) { \
JLI_ReportErrorMessage(JVM_ERROR2); \
ret = 1; \
} \
(*vm)->DestroyJavaVM(vm); \
return ret \
#define CHECK_EXCEPTION_NULL_LEAVE(e) \ #define CHECK_EXCEPTION_NULL_LEAVE(e) \
if ((*env)->ExceptionOccurred(env)) { \ if ((*env)->ExceptionOccurred(env)) { \
JLI_ReportExceptionDescription(env); \ JLI_ReportExceptionDescription(env); \
goto leave; \ LEAVE(); \
} \ } \
if ((e) == NULL) { \ if ((e) == NULL) { \
JLI_ReportErrorMessage(JNI_ERROR); \ JLI_ReportErrorMessage(JNI_ERROR); \
goto leave; \ LEAVE(); \
} }
#define CHECK_EXCEPTION_LEAVE(rv) \ #define CHECK_EXCEPTION_LEAVE(rv) \
if ((*env)->ExceptionOccurred(env)) { \ if ((*env)->ExceptionOccurred(env)) { \
JLI_ReportExceptionDescription(env); \ JLI_ReportExceptionDescription(env); \
ret = (rv); \ ret = (rv); \
goto leave; \ LEAVE(); \
} }
int JNICALL int JNICALL
...@@ -349,8 +373,7 @@ JavaMain(void * _args) ...@@ -349,8 +373,7 @@ JavaMain(void * _args)
PrintJavaVersion(env, showVersion); PrintJavaVersion(env, showVersion);
CHECK_EXCEPTION_LEAVE(0); CHECK_EXCEPTION_LEAVE(0);
if (printVersion) { if (printVersion) {
ret = 0; LEAVE();
goto leave;
} }
} }
...@@ -358,7 +381,7 @@ JavaMain(void * _args) ...@@ -358,7 +381,7 @@ JavaMain(void * _args)
if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) { if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) {
PrintUsage(env, printXUsage); PrintUsage(env, printXUsage);
CHECK_EXCEPTION_LEAVE(1); CHECK_EXCEPTION_LEAVE(1);
goto leave; LEAVE();
} }
FreeKnownVMs(); /* after last possible PrintUsage() */ FreeKnownVMs(); /* after last possible PrintUsage() */
...@@ -430,30 +453,7 @@ JavaMain(void * _args) ...@@ -430,30 +453,7 @@ JavaMain(void * _args)
* System.exit) will be non-zero if main threw an exception. * System.exit) will be non-zero if main threw an exception.
*/ */
ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
LEAVE();
leave:
/*
* Always detach the main thread so that it appears to have ended when
* the application's main method exits. This will invoke the
* uncaught exception handler machinery if main threw an
* exception. An uncaught exception handler cannot change the
* launcher's return code except by calling System.exit.
*/
if ((*vm)->DetachCurrentThread(vm) != 0) {
JLI_ReportErrorMessage(JVM_ERROR2);
ret = 1;
}
/*
* Wait for all non-daemon threads to end, then destroy the VM.
* This will actually create a trivial new Java waiter thread
* named "DestroyJavaVM", but this will be seen as a different
* thread from the one that executed main, even though they are
* the same C thread. This allows mainThread.join() and
* mainThread.isAlive() to work as expected.
*/
(*vm)->DestroyJavaVM(vm);
return ret;
} }
/* /*
...@@ -1076,15 +1076,17 @@ ParseArguments(int *pargc, char ***pargv, char **pjarfile, ...@@ -1076,15 +1076,17 @@ ParseArguments(int *pargc, char ***pargv, char **pjarfile,
if (--argc >= 0) { if (--argc >= 0) {
if (jarflag) { if (jarflag) {
*pjarfile = *argv++; *pjarfile = *argv++;
*pclassname = 0; *pclassname = NULL;
} else { } else {
*pjarfile = 0; *pjarfile = NULL;
*pclassname = *argv++; *pclassname = *argv++;
} }
*pargc = argc; *pargc = argc;
*pargv = argv; *pargv = argv;
} }
if (*pjarfile == NULL && *pclassname == NULL) {
*pret = 1;
}
return JNI_TRUE; return JNI_TRUE;
} }
......
/* /*
* Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2010, 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
...@@ -114,13 +114,19 @@ GetApplicationHome(char *buf, jint bufsize); ...@@ -114,13 +114,19 @@ GetApplicationHome(char *buf, jint bufsize);
#define GetArch() GetArchPath(CURRENT_DATA_MODEL) #define GetArch() GetArchPath(CURRENT_DATA_MODEL)
void CreateExecutionEnvironment(int *_argc, /*
char ***_argv, * Different platforms will implement this, here
char jrepath[], * pargc is a pointer to the original argc,
jint so_jrepath, * pargv is a pointer to the original argv,
char jvmpath[], * jrepath is an accessible path to the jre as determined by the call
jint so_jvmpath, * so_jrepath is the length of the buffer jrepath
char **original_argv); * jvmpath is an accessible path to the jvm as determined by the call
* so_jvmpath is the length of the buffer jvmpath
*/
void CreateExecutionEnvironment(int *argc, char ***argv,
char *jrepath, jint so_jrepath,
char *jvmpath, jint so_jvmpath);
/* Reports an error message to stderr or a window as appropriate. */ /* Reports an error message to stderr or a window as appropriate. */
void JLI_ReportErrorMessage(const char * message, ...); void JLI_ReportErrorMessage(const char * message, ...);
......
/* /*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, 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
...@@ -84,23 +84,6 @@ JLI_MemFree(void *ptr) ...@@ -84,23 +84,6 @@ JLI_MemFree(void *ptr)
free(ptr); free(ptr);
} }
/*
* Makes a copy of arguments
*/
char**
JLI_CopyArgs(int argc, const char **iargv)
{
int i;
char** oargv = (char**)JLI_MemAlloc(sizeof(char*)*(argc+1));
for (i = 0 ; i < argc+1 ; i++) {
oargv[i] = (iargv[i] == NULL) ? NULL : JLI_StringDup(iargv[i]);
if (iargv[i] != NULL && JLI_IsTraceLauncher() == JNI_TRUE) {
printf("\targv[%d] = '%s'\n",i,iargv[i]);
}
}
return oargv;
}
/* /*
* debug helpers we use * debug helpers we use
*/ */
......
/* /*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, 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
...@@ -33,7 +33,6 @@ void *JLI_MemAlloc(size_t size); ...@@ -33,7 +33,6 @@ void *JLI_MemAlloc(size_t size);
void *JLI_MemRealloc(void *ptr, size_t size); void *JLI_MemRealloc(void *ptr, size_t size);
char *JLI_StringDup(const char *s1); char *JLI_StringDup(const char *s1);
void JLI_MemFree(void *ptr); void JLI_MemFree(void *ptr);
char **JLI_CopyArgs(int argc, const char **iargv);
int JLI_StrCCmp(const char *s1, const char* s2); int JLI_StrCCmp(const char *s1, const char* s2);
...@@ -56,10 +55,12 @@ int JLI_StrCCmp(const char *s1, const char* s2); ...@@ -56,10 +55,12 @@ int JLI_StrCCmp(const char *s1, const char* s2);
#include <io.h> #include <io.h>
#define JLI_StrCaseCmp(p1, p2) stricmp((p1), (p2)) #define JLI_StrCaseCmp(p1, p2) stricmp((p1), (p2))
#define JLI_StrNCaseCmp(p1, p2, p3) strnicmp((p1), (p2), (p3)) #define JLI_StrNCaseCmp(p1, p2, p3) strnicmp((p1), (p2), (p3))
#define JLI_Snprintf _snprintf
#else #else
#include <unistd.h> #include <unistd.h>
#define JLI_StrCaseCmp(p1, p2) strcasecmp((p1), (p2)) #define JLI_StrCaseCmp(p1, p2) strcasecmp((p1), (p2))
#define JLI_StrNCaseCmp(p1, p2, p3) strncasecmp((p1), (p2), (p3)) #define JLI_StrNCaseCmp(p1, p2, p3) strncasecmp((p1), (p2), (p3))
#define JLI_Snprintf snprintf
#endif /* _WIN32 */ #endif /* _WIN32 */
/* /*
......
...@@ -41,6 +41,13 @@ public interface AutoCloseable { ...@@ -41,6 +41,13 @@ public interface AutoCloseable {
* be declared to throw more specific exceptions (or no exception * be declared to throw more specific exceptions (or no exception
* at all, if the close cannot fail). * at all, if the close cannot fail).
* *
* <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.
*
* @throws Exception if this resource cannot be closed * @throws Exception if this resource cannot be closed
*/ */
void close() throws Exception; void close() throws Exception;
......
...@@ -69,7 +69,7 @@ public final class System { ...@@ -69,7 +69,7 @@ public final class System {
* corresponds to keyboard input or another input source specified by * corresponds to keyboard input or another input source specified by
* the host environment or user. * the host environment or user.
*/ */
public final static InputStream in = nullInputStream(); public final static InputStream in = null;
/** /**
* The "standard" output stream. This stream is already * The "standard" output stream. This stream is already
...@@ -96,7 +96,7 @@ public final class System { ...@@ -96,7 +96,7 @@ public final class System {
* @see java.io.PrintStream#println(java.lang.Object) * @see java.io.PrintStream#println(java.lang.Object)
* @see java.io.PrintStream#println(java.lang.String) * @see java.io.PrintStream#println(java.lang.String)
*/ */
public final static PrintStream out = nullPrintStream(); public final static PrintStream out = null;
/** /**
* The "standard" error output stream. This stream is already * The "standard" error output stream. This stream is already
...@@ -110,7 +110,7 @@ public final class System { ...@@ -110,7 +110,7 @@ public final class System {
* variable <code>out</code>, has been redirected to a file or other * variable <code>out</code>, has been redirected to a file or other
* destination that is typically not continuously monitored. * destination that is typically not continuously monitored.
*/ */
public final static PrintStream err = nullPrintStream(); public final static PrintStream err = null;
/* The security manager for the system. /* The security manager for the system.
*/ */
...@@ -1092,26 +1092,6 @@ public final class System { ...@@ -1092,26 +1092,6 @@ public final class System {
*/ */
public static native String mapLibraryName(String libname); public static native String mapLibraryName(String libname);
/**
* The following two methods exist because in, out, and err must be
* initialized to null. The compiler, however, cannot be permitted to
* inline access to them, since they are later set to more sensible values
* by initializeSystemClass().
*/
private static InputStream nullInputStream() throws NullPointerException {
if (currentTimeMillis() > 0) {
return null;
}
throw new NullPointerException();
}
private static PrintStream nullPrintStream() throws NullPointerException {
if (currentTimeMillis() > 0) {
return null;
}
throw new NullPointerException();
}
/** /**
* Initialize the system class. Called after thread initialization. * Initialize the system class. Called after thread initialization.
*/ */
......
...@@ -28,12 +28,12 @@ import java.io.*; ...@@ -28,12 +28,12 @@ import java.io.*;
import java.util.*; import java.util.*;
/** /**
* The <code>Throwable</code> class is the superclass of all errors and * The {@code Throwable} class is the superclass of all errors and
* exceptions in the Java language. Only objects that are instances of this * exceptions in the Java language. Only objects that are instances of this
* class (or one of its subclasses) are thrown by the Java Virtual Machine or * class (or one of its subclasses) are thrown by the Java Virtual Machine or
* can be thrown by the Java <code>throw</code> statement. Similarly, only * can be thrown by the Java {@code throw} statement. Similarly, only
* this class or one of its subclasses can be the argument type in a * this class or one of its subclasses can be the argument type in a
* <code>catch</code> clause. * {@code catch} clause.
* *
* For the purposes of compile-time checking of exceptions, {@code * For the purposes of compile-time checking of exceptions, {@code
* Throwable} and any subclass of {@code Throwable} that is not also a * Throwable} and any subclass of {@code Throwable} that is not also a
...@@ -73,11 +73,11 @@ import java.util.*; ...@@ -73,11 +73,11 @@ import java.util.*;
* permit the method to throw the cause directly. For example, suppose * permit the method to throw the cause directly. For example, suppose
* a persistent collection conforms to the {@link java.util.Collection * a persistent collection conforms to the {@link java.util.Collection
* Collection} interface, and that its persistence is implemented atop * Collection} interface, and that its persistence is implemented atop
* <tt>java.io</tt>. Suppose the internals of the <tt>add</tt> method * {@code java.io}. Suppose the internals of the {@code add} method
* can throw an {@link java.io.IOException IOException}. The implementation * can throw an {@link java.io.IOException IOException}. The implementation
* can communicate the details of the <tt>IOException</tt> to its caller * can communicate the details of the {@code IOException} to its caller
* while conforming to the <tt>Collection</tt> interface by wrapping the * while conforming to the {@code Collection} interface by wrapping the
* <tt>IOException</tt> in an appropriate unchecked exception. (The * {@code IOException} in an appropriate unchecked exception. (The
* specification for the persistent collection should indicate that it is * specification for the persistent collection should indicate that it is
* capable of throwing such exceptions.) * capable of throwing such exceptions.)
* *
...@@ -86,7 +86,7 @@ import java.util.*; ...@@ -86,7 +86,7 @@ import java.util.*;
* {@link #initCause(Throwable)} method. New throwable classes that * {@link #initCause(Throwable)} method. New throwable classes that
* wish to allow causes to be associated with them should provide constructors * wish to allow causes to be associated with them should provide constructors
* that take a cause and delegate (perhaps indirectly) to one of the * that take a cause and delegate (perhaps indirectly) to one of the
* <tt>Throwable</tt> constructors that takes a cause. For example: * {@code Throwable} constructors that takes a cause. For example:
* <pre> * <pre>
* try { * try {
* lowLevelOp(); * lowLevelOp();
...@@ -94,10 +94,10 @@ import java.util.*; ...@@ -94,10 +94,10 @@ import java.util.*;
* throw new HighLevelException(le); // Chaining-aware constructor * throw new HighLevelException(le); // Chaining-aware constructor
* } * }
* </pre> * </pre>
* Because the <tt>initCause</tt> method is public, it allows a cause to be * Because the {@code initCause} method is public, it allows a cause to be
* associated with any throwable, even a "legacy throwable" whose * associated with any throwable, even a "legacy throwable" whose
* implementation predates the addition of the exception chaining mechanism to * implementation predates the addition of the exception chaining mechanism to
* <tt>Throwable</tt>. For example: * {@code Throwable}. For example:
* <pre> * <pre>
* try { * try {
* lowLevelOp(); * lowLevelOp();
...@@ -121,28 +121,28 @@ import java.util.*; ...@@ -121,28 +121,28 @@ import java.util.*;
* use the standard exception chaining mechanism, while continuing to * use the standard exception chaining mechanism, while continuing to
* implement their "legacy" chaining mechanisms for compatibility. * implement their "legacy" chaining mechanisms for compatibility.
* *
* <p>Further, as of release 1.4, many general purpose <tt>Throwable</tt> * <p>Further, as of release 1.4, many general purpose {@code Throwable}
* classes (for example {@link Exception}, {@link RuntimeException}, * classes (for example {@link Exception}, {@link RuntimeException},
* {@link Error}) have been retrofitted with constructors that take * {@link Error}) have been retrofitted with constructors that take
* a cause. This was not strictly necessary, due to the existence of the * a cause. This was not strictly necessary, due to the existence of the
* <tt>initCause</tt> method, but it is more convenient and expressive to * {@code initCause} method, but it is more convenient and expressive to
* delegate to a constructor that takes a cause. * delegate to a constructor that takes a cause.
* *
* <p>By convention, class <code>Throwable</code> and its subclasses have two * <p>By convention, class {@code Throwable} and its subclasses have two
* constructors, one that takes no arguments and one that takes a * constructors, one that takes no arguments and one that takes a
* <code>String</code> argument that can be used to produce a detail message. * {@code String} argument that can be used to produce a detail message.
* Further, those subclasses that might likely have a cause associated with * Further, those subclasses that might likely have a cause associated with
* them should have two more constructors, one that takes a * them should have two more constructors, one that takes a
* <code>Throwable</code> (the cause), and one that takes a * {@code Throwable} (the cause), and one that takes a
* <code>String</code> (the detail message) and a <code>Throwable</code> (the * {@code String} (the detail message) and a {@code Throwable} (the
* cause). * cause).
* *
* <p>Also introduced in release 1.4 is the {@link #getStackTrace()} method, * <p>Also introduced in release 1.4 is the {@link #getStackTrace()} method,
* which allows programmatic access to the stack trace information that was * which allows programmatic access to the stack trace information that was
* previously available only in text form, via the various forms of the * previously available only in text form, via the various forms of the
* {@link #printStackTrace()} method. This information has been added to the * {@link #printStackTrace()} method. This information has been added to the
* <i>serialized representation</i> of this class so <tt>getStackTrace</tt> * <i>serialized representation</i> of this class so {@code getStackTrace}
* and <tt>printStackTrace</tt> will operate properly on a throwable that * and {@code printStackTrace} will operate properly on a throwable that
* was obtained by deserialization. * was obtained by deserialization.
* *
* @author unascribed * @author unascribed
...@@ -162,7 +162,7 @@ public class Throwable implements Serializable { ...@@ -162,7 +162,7 @@ public class Throwable implements Serializable {
/** /**
* Specific details about the Throwable. For example, for * Specific details about the Throwable. For example, for
* <tt>FileNotFoundException</tt>, this contains the name of * {@code FileNotFoundException}, this contains the name of
* the file that could not be found. * the file that could not be found.
* *
* @serial * @serial
...@@ -212,7 +212,7 @@ public class Throwable implements Serializable { ...@@ -212,7 +212,7 @@ public class Throwable implements Serializable {
private static final String SUPPRESSED_CAPTION = "Suppressed: "; private static final String SUPPRESSED_CAPTION = "Suppressed: ";
/** /**
* Constructs a new throwable with <code>null</code> as its detail message. * Constructs a new throwable with {@code null} as its detail message.
* The cause is not initialized, and may subsequently be initialized by a * The cause is not initialized, and may subsequently be initialized by a
* call to {@link #initCause}. * call to {@link #initCause}.
* *
...@@ -242,7 +242,7 @@ public class Throwable implements Serializable { ...@@ -242,7 +242,7 @@ public class Throwable implements Serializable {
/** /**
* Constructs a new throwable with the specified detail message and * Constructs a new throwable with the specified detail message and
* cause. <p>Note that the detail message associated with * cause. <p>Note that the detail message associated with
* <code>cause</code> is <i>not</i> automatically incorporated in * {@code cause} is <i>not</i> automatically incorporated in
* this throwable's detail message. * this throwable's detail message.
* *
* <p>The {@link #fillInStackTrace()} method is called to initialize * <p>The {@link #fillInStackTrace()} method is called to initialize
...@@ -251,7 +251,7 @@ public class Throwable implements Serializable { ...@@ -251,7 +251,7 @@ public class Throwable implements Serializable {
* @param message the detail message (which is saved for later retrieval * @param message the detail message (which is saved for later retrieval
* by the {@link #getMessage()} method). * by the {@link #getMessage()} method).
* @param cause the cause (which is saved for later retrieval by the * @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is * {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or * permitted, and indicates that the cause is nonexistent or
* unknown.) * unknown.)
* @since 1.4 * @since 1.4
...@@ -264,8 +264,8 @@ public class Throwable implements Serializable { ...@@ -264,8 +264,8 @@ public class Throwable implements Serializable {
/** /**
* Constructs a new throwable with the specified cause and a detail * Constructs a new throwable with the specified cause and a detail
* message of <tt>(cause==null ? null : cause.toString())</tt> (which * message of {@code (cause==null ? null : cause.toString())} (which
* typically contains the class and detail message of <tt>cause</tt>). * typically contains the class and detail message of {@code cause}).
* This constructor is useful for throwables that are little more than * This constructor is useful for throwables that are little more than
* wrappers for other throwables (for example, {@link * wrappers for other throwables (for example, {@link
* java.security.PrivilegedActionException}). * java.security.PrivilegedActionException}).
...@@ -274,7 +274,7 @@ public class Throwable implements Serializable { ...@@ -274,7 +274,7 @@ public class Throwable implements Serializable {
* the stack trace data in the newly created throwable. * the stack trace data in the newly created throwable.
* *
* @param cause the cause (which is saved for later retrieval by the * @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is * {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or * permitted, and indicates that the cause is nonexistent or
* unknown.) * unknown.)
* @since 1.4 * @since 1.4
...@@ -288,8 +288,8 @@ public class Throwable implements Serializable { ...@@ -288,8 +288,8 @@ public class Throwable implements Serializable {
/** /**
* Returns the detail message string of this throwable. * Returns the detail message string of this throwable.
* *
* @return the detail message string of this <tt>Throwable</tt> instance * @return the detail message string of this {@code Throwable} instance
* (which may be <tt>null</tt>). * (which may be {@code null}).
*/ */
public String getMessage() { public String getMessage() {
return detailMessage; return detailMessage;
...@@ -300,7 +300,7 @@ public class Throwable implements Serializable { ...@@ -300,7 +300,7 @@ public class Throwable implements Serializable {
* Subclasses may override this method in order to produce a * Subclasses may override this method in order to produce a
* locale-specific message. For subclasses that do not override this * locale-specific message. For subclasses that do not override this
* method, the default implementation returns the same result as * method, the default implementation returns the same result as
* <code>getMessage()</code>. * {@code getMessage()}.
* *
* @return The localized description of this throwable. * @return The localized description of this throwable.
* @since JDK1.1 * @since JDK1.1
...@@ -310,22 +310,22 @@ public class Throwable implements Serializable { ...@@ -310,22 +310,22 @@ public class Throwable implements Serializable {
} }
/** /**
* Returns the cause of this throwable or <code>null</code> if the * Returns the cause of this throwable or {@code null} if the
* cause is nonexistent or unknown. (The cause is the throwable that * cause is nonexistent or unknown. (The cause is the throwable that
* caused this throwable to get thrown.) * caused this throwable to get thrown.)
* *
* <p>This implementation returns the cause that was supplied via one of * <p>This implementation returns the cause that was supplied via one of
* the constructors requiring a <tt>Throwable</tt>, or that was set after * the constructors requiring a {@code Throwable}, or that was set after
* creation with the {@link #initCause(Throwable)} method. While it is * creation with the {@link #initCause(Throwable)} method. While it is
* typically unnecessary to override this method, a subclass can override * typically unnecessary to override this method, a subclass can override
* it to return a cause set by some other means. This is appropriate for * it to return a cause set by some other means. This is appropriate for
* a "legacy chained throwable" that predates the addition of chained * a "legacy chained throwable" that predates the addition of chained
* exceptions to <tt>Throwable</tt>. Note that it is <i>not</i> * exceptions to {@code Throwable}. Note that it is <i>not</i>
* necessary to override any of the <tt>PrintStackTrace</tt> methods, * necessary to override any of the {@code PrintStackTrace} methods,
* all of which invoke the <tt>getCause</tt> method to determine the * all of which invoke the {@code getCause} method to determine the
* cause of a throwable. * cause of a throwable.
* *
* @return the cause of this throwable or <code>null</code> if the * @return the cause of this throwable or {@code null} if the
* cause is nonexistent or unknown. * cause is nonexistent or unknown.
* @since 1.4 * @since 1.4
*/ */
...@@ -345,11 +345,11 @@ public class Throwable implements Serializable { ...@@ -345,11 +345,11 @@ public class Throwable implements Serializable {
* even once. * even once.
* *
* @param cause the cause (which is saved for later retrieval by the * @param cause the cause (which is saved for later retrieval by the
* {@link #getCause()} method). (A <tt>null</tt> value is * {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or * permitted, and indicates that the cause is nonexistent or
* unknown.) * unknown.)
* @return a reference to this <code>Throwable</code> instance. * @return a reference to this {@code Throwable} instance.
* @throws IllegalArgumentException if <code>cause</code> is this * @throws IllegalArgumentException if {@code cause} is this
* throwable. (A throwable cannot be its own cause.) * throwable. (A throwable cannot be its own cause.)
* @throws IllegalStateException if this throwable was * @throws IllegalStateException if this throwable was
* created with {@link #Throwable(Throwable)} or * created with {@link #Throwable(Throwable)} or
...@@ -375,7 +375,7 @@ public class Throwable implements Serializable { ...@@ -375,7 +375,7 @@ public class Throwable implements Serializable {
* <li> the result of invoking this object's {@link #getLocalizedMessage} * <li> the result of invoking this object's {@link #getLocalizedMessage}
* method * method
* </ul> * </ul>
* If <tt>getLocalizedMessage</tt> returns <tt>null</tt>, then just * If {@code getLocalizedMessage} returns {@code null}, then just
* the class name is returned. * the class name is returned.
* *
* @return a string representation of this throwable. * @return a string representation of this throwable.
...@@ -389,8 +389,8 @@ public class Throwable implements Serializable { ...@@ -389,8 +389,8 @@ public class Throwable implements Serializable {
/** /**
* Prints this throwable and its backtrace to the * Prints this throwable and its backtrace to the
* standard error stream. This method prints a stack trace for this * standard error stream. This method prints a stack trace for this
* <code>Throwable</code> object on the error output stream that is * {@code Throwable} object on the error output stream that is
* the value of the field <code>System.err</code>. The first line of * the value of the field {@code System.err}. The first line of
* output contains the result of the {@link #toString()} method for * output contains the result of the {@link #toString()} method for
* this object. Remaining lines represent data previously recorded by * this object. Remaining lines represent data previously recorded by
* the method {@link #fillInStackTrace()}. The format of this * the method {@link #fillInStackTrace()}. The format of this
...@@ -435,7 +435,7 @@ public class Throwable implements Serializable { ...@@ -435,7 +435,7 @@ public class Throwable implements Serializable {
* at Junk.c(Junk.java:21) * at Junk.c(Junk.java:21)
* ... 3 more * ... 3 more
* </pre> * </pre>
* Note the presence of lines containing the characters <tt>"..."</tt>. * Note the presence of lines containing the characters {@code "..."}.
* These lines indicate that the remainder of the stack trace for this * These lines indicate that the remainder of the stack trace for this
* exception matches the indicated number of frames from the bottom of the * exception matches the indicated number of frames from the bottom of the
* stack trace of the exception that was caused by this exception (the * stack trace of the exception that was caused by this exception (the
...@@ -542,14 +542,17 @@ public class Throwable implements Serializable { ...@@ -542,14 +542,17 @@ public class Throwable implements Serializable {
/** /**
* Prints this throwable and its backtrace to the specified print stream. * Prints this throwable and its backtrace to the specified print stream.
* *
* @param s <code>PrintStream</code> to use for output * @param s {@code PrintStream} to use for output
*/ */
public void printStackTrace(PrintStream s) { public void printStackTrace(PrintStream s) {
printStackTrace(new WrappedPrintStream(s)); printStackTrace(new WrappedPrintStream(s));
} }
private void printStackTrace(PrintStreamOrWriter s) { private void printStackTrace(PrintStreamOrWriter s) {
Set<Throwable> dejaVu = new HashSet<Throwable>(); // Guard against malicious overrides of Throwable.equals by
// using a Set with identity equality semantics.
Set<Throwable> dejaVu =
Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>());
dejaVu.add(this); dejaVu.add(this);
synchronized (s.lock()) { synchronized (s.lock()) {
...@@ -616,7 +619,7 @@ public class Throwable implements Serializable { ...@@ -616,7 +619,7 @@ public class Throwable implements Serializable {
* Prints this throwable and its backtrace to the specified * Prints this throwable and its backtrace to the specified
* print writer. * print writer.
* *
* @param s <code>PrintWriter</code> to use for output * @param s {@code PrintWriter} to use for output
* @since JDK1.1 * @since JDK1.1
*/ */
public void printStackTrace(PrintWriter s) { public void printStackTrace(PrintWriter s) {
...@@ -669,10 +672,10 @@ public class Throwable implements Serializable { ...@@ -669,10 +672,10 @@ public class Throwable implements Serializable {
/** /**
* Fills in the execution stack trace. This method records within this * Fills in the execution stack trace. This method records within this
* <code>Throwable</code> object information about the current state of * {@code Throwable} object information about the current state of
* the stack frames for the current thread. * the stack frames for the current thread.
* *
* @return a reference to this <code>Throwable</code> instance. * @return a reference to this {@code Throwable} instance.
* @see java.lang.Throwable#printStackTrace() * @see java.lang.Throwable#printStackTrace()
*/ */
public synchronized native Throwable fillInStackTrace(); public synchronized native Throwable fillInStackTrace();
...@@ -694,7 +697,7 @@ public class Throwable implements Serializable { ...@@ -694,7 +697,7 @@ public class Throwable implements Serializable {
* this throwable is permitted to return a zero-length array from this * this throwable is permitted to return a zero-length array from this
* method. Generally speaking, the array returned by this method will * method. Generally speaking, the array returned by this method will
* contain one element for every frame that would be printed by * contain one element for every frame that would be printed by
* <tt>printStackTrace</tt>. * {@code printStackTrace}.
* *
* @return an array of stack trace elements representing the stack trace * @return an array of stack trace elements representing the stack trace
* pertaining to this throwable. * pertaining to this throwable.
...@@ -727,14 +730,14 @@ public class Throwable implements Serializable { ...@@ -727,14 +730,14 @@ public class Throwable implements Serializable {
* read from a serialization stream. * read from a serialization stream.
* *
* @param stackTrace the stack trace elements to be associated with * @param stackTrace the stack trace elements to be associated with
* this <code>Throwable</code>. The specified array is copied by this * this {@code Throwable}. The specified array is copied by this
* call; changes in the specified array after the method invocation * call; changes in the specified array after the method invocation
* returns will have no affect on this <code>Throwable</code>'s stack * returns will have no affect on this {@code Throwable}'s stack
* trace. * trace.
* *
* @throws NullPointerException if <code>stackTrace</code> is * @throws NullPointerException if {@code stackTrace} is
* <code>null</code>, or if any of the elements of * {@code null}, or if any of the elements of
* <code>stackTrace</code> are <code>null</code> * {@code stackTrace} are {@code null}
* *
* @since 1.4 * @since 1.4
*/ */
...@@ -761,8 +764,8 @@ public class Throwable implements Serializable { ...@@ -761,8 +764,8 @@ public class Throwable implements Serializable {
* package-protection for use by SharedSecrets. * package-protection for use by SharedSecrets.
* *
* @param index index of the element to return. * @param index index of the element to return.
* @throws IndexOutOfBoundsException if <tt>index &lt; 0 || * @throws IndexOutOfBoundsException if {@code index < 0 ||
* index &gt;= getStackTraceDepth() </tt> * index >= getStackTraceDepth() }
*/ */
native StackTraceElement getStackTraceElement(int index); native StackTraceElement getStackTraceElement(int index);
...@@ -794,14 +797,27 @@ public class Throwable implements Serializable { ...@@ -794,14 +797,27 @@ public class Throwable implements Serializable {
* were suppressed, typically by the automatic resource management * were suppressed, typically by the automatic resource management
* statement, in order to deliver this exception. * statement, in order to deliver this exception.
* *
* <p>Note that when one exception {@linkplain
* #initCause(Throwable) causes} another exception, the first
* exception is usually caught and then the second exception is
* thrown in response. In contrast, when one exception suppresses
* another, two exceptions are thrown in sibling code blocks, such
* as in a {@code try} block and in its {@code finally} block, and
* control flow can only continue with one exception so the second
* is recorded as a suppressed exception of the first.
*
* @param exception the exception to be added to the list of * @param exception the exception to be added to the list of
* suppressed exceptions * suppressed exceptions
* @throws NullPointerException if {@code exception} is null * @throws NullPointerException if {@code exception} is null
* @throws IllegalArgumentException if {@code exception} is this
* throwable; a throwable cannot suppress itself.
* @since 1.7 * @since 1.7
*/ */
public synchronized void addSuppressedException(Throwable exception) { public synchronized void addSuppressedException(Throwable exception) {
if (exception == null) if (exception == null)
throw new NullPointerException(NULL_CAUSE_MESSAGE); throw new NullPointerException(NULL_CAUSE_MESSAGE);
if (exception == this)
throw new IllegalArgumentException("Self-suppression not permitted");
if (suppressedExceptions.size() == 0) if (suppressedExceptions.size() == 0)
suppressedExceptions = new ArrayList<Throwable>(); suppressedExceptions = new ArrayList<Throwable>();
......
...@@ -427,8 +427,9 @@ class Inet6Address extends InetAddress { ...@@ -427,8 +427,9 @@ class Inet6Address extends InetAddress {
try { try {
scope_id = deriveNumericScope (scope_ifname); scope_id = deriveNumericScope (scope_ifname);
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
// should not happen // typically should not happen, but it may be that
assert false; // the machine being used for deserialization has
// the same interface name but without IPv6 configured.
} }
} }
} catch (SocketException e) {} } catch (SocketException e) {}
......
...@@ -52,14 +52,16 @@ class ExchangeImpl { ...@@ -52,14 +52,16 @@ class ExchangeImpl {
boolean http10 = false; boolean http10 = false;
/* for formatting the Date: header */ /* for formatting the Date: header */
static TimeZone tz; private static final String pattern = "EEE, dd MMM yyyy HH:mm:ss zzz";
static DateFormat df; private static final TimeZone gmtTZ = TimeZone.getTimeZone("GMT");
static { private static final ThreadLocal<DateFormat> dateFormat =
String pattern = "EEE, dd MMM yyyy HH:mm:ss zzz"; new ThreadLocal<DateFormat>() {
tz = TimeZone.getTimeZone ("GMT"); @Override protected DateFormat initialValue() {
df = new SimpleDateFormat (pattern, Locale.US); DateFormat df = new SimpleDateFormat(pattern, Locale.US);
df.setTimeZone (tz); df.setTimeZone(gmtTZ);
return df;
} }
};
private static final String HEAD = "HEAD"; private static final String HEAD = "HEAD";
...@@ -206,7 +208,7 @@ class ExchangeImpl { ...@@ -206,7 +208,7 @@ class ExchangeImpl {
PlaceholderOutputStream o = getPlaceholderResponseBody(); PlaceholderOutputStream o = getPlaceholderResponseBody();
tmpout.write (bytes(statusLine, 0), 0, statusLine.length()); tmpout.write (bytes(statusLine, 0), 0, statusLine.length());
boolean noContentToSend = false; // assume there is content boolean noContentToSend = false; // assume there is content
rspHdrs.set ("Date", df.format (new Date())); rspHdrs.set ("Date", dateFormat.get().format (new Date()));
/* check for response type that is not allowed to send a body */ /* check for response type that is not allowed to send a body */
......
/* /*
* Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2010, 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
...@@ -25,17 +25,16 @@ ...@@ -25,17 +25,16 @@
package sun.security.util; package sun.security.util;
import java.io.FilterOutputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.Vector;
import java.util.Comparator; import java.util.Comparator;
import java.util.Arrays; import java.util.Arrays;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Locale;
/** /**
...@@ -501,7 +500,7 @@ extends ByteArrayOutputStream implements DerEncoder { ...@@ -501,7 +500,7 @@ extends ByteArrayOutputStream implements DerEncoder {
pattern = "yyyyMMddHHmmss'Z'"; pattern = "yyyyMMddHHmmss'Z'";
} }
SimpleDateFormat sdf = new SimpleDateFormat(pattern); SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.US);
sdf.setTimeZone(tz); sdf.setTimeZone(tz);
byte[] time = (sdf.format(d)).getBytes("ISO-8859-1"); byte[] time = (sdf.format(d)).getBytes("ISO-8859-1");
......
/* /*
* Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2010, 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
...@@ -183,13 +183,9 @@ GetArchPath(int nbits) ...@@ -183,13 +183,9 @@ GetArchPath(int nbits)
} }
void void
CreateExecutionEnvironment(int *_argcp, CreateExecutionEnvironment(int *pargc, char ***pargv,
char ***_argvp, char jrepath[], jint so_jrepath,
char jrepath[], char jvmpath[], jint so_jvmpath) {
jint so_jrepath,
char jvmpath[],
jint so_jvmpath,
char **original_argv) {
/* /*
* First, determine if we are running the desired data model. If we * First, determine if we are running the desired data model. If we
* are running the desired data model, all the error messages * are running the desired data model, all the error messages
...@@ -200,18 +196,17 @@ CreateExecutionEnvironment(int *_argcp, ...@@ -200,18 +196,17 @@ CreateExecutionEnvironment(int *_argcp,
* os/processor combination has dual mode capabilities. * os/processor combination has dual mode capabilities.
*/ */
int original_argc = *_argcp;
jboolean jvmpathExists; jboolean jvmpathExists;
/* Compute/set the name of the executable */ /* Compute/set the name of the executable */
SetExecname(*_argvp); SetExecname(*pargv);
/* Check data model flags, and exec process, if needed */ /* Check data model flags, and exec process, if needed */
{ {
char *arch = (char *)GetArch(); /* like sparc or sparcv9 */ char *arch = (char *)GetArch(); /* like sparc or sparcv9 */
char * jvmtype = NULL; char * jvmtype = NULL;
int argc = *_argcp; int argc = *pargc;
char **argv = original_argv; char **argv = *pargv;
int running = CURRENT_DATA_MODEL; int running = CURRENT_DATA_MODEL;
...@@ -233,7 +228,7 @@ CreateExecutionEnvironment(int *_argcp, ...@@ -233,7 +228,7 @@ CreateExecutionEnvironment(int *_argcp,
{ /* open new scope to declare local variables */ { /* open new scope to declare local variables */
int i; int i;
newargv = (char **)JLI_MemAlloc((argc+1) * sizeof(*newargv)); newargv = (char **)JLI_MemAlloc((argc+1) * sizeof(char*));
newargv[newargc++] = argv[0]; newargv[newargc++] = argv[0];
/* scan for data model arguments and remove from argument list; /* scan for data model arguments and remove from argument list;
...@@ -293,7 +288,11 @@ CreateExecutionEnvironment(int *_argcp, ...@@ -293,7 +288,11 @@ CreateExecutionEnvironment(int *_argcp,
} }
jvmpath[0] = '\0'; jvmpath[0] = '\0';
jvmtype = CheckJvmType(_argcp, _argvp, JNI_FALSE); jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
JLI_ReportErrorMessage(CFG_ERROR9);
exit(4);
}
if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, arch )) { if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, arch )) {
JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
...@@ -309,7 +308,9 @@ CreateExecutionEnvironment(int *_argcp, ...@@ -309,7 +308,9 @@ CreateExecutionEnvironment(int *_argcp,
if (running != wanted) { if (running != wanted) {
/* Find out where the JRE is that we will be using. */ /* Find out where the JRE is that we will be using. */
if (!GetJREPath(jrepath, so_jrepath, GetArchPath(wanted), JNI_TRUE)) { if (!GetJREPath(jrepath, so_jrepath, GetArchPath(wanted), JNI_TRUE)) {
goto EndDataModelSpeculate; /* give up and let other code report error message */
JLI_ReportErrorMessage(JRE_ERROR2, wanted);
exit(1);
} }
/* /*
...@@ -317,16 +318,21 @@ CreateExecutionEnvironment(int *_argcp, ...@@ -317,16 +318,21 @@ CreateExecutionEnvironment(int *_argcp,
* selection options. * selection options.
*/ */
if (ReadKnownVMs(jrepath, GetArchPath(wanted), JNI_TRUE) < 1) { if (ReadKnownVMs(jrepath, GetArchPath(wanted), JNI_TRUE) < 1) {
goto EndDataModelSpeculate; /* give up and let other code report error message */
JLI_ReportErrorMessage(JRE_ERROR2, wanted);
exit(1);
} }
jvmpath[0] = '\0'; jvmpath[0] = '\0';
jvmtype = CheckJvmType(_argcp, _argvp, JNI_TRUE); jvmtype = CheckJvmType(pargc, pargv, JNI_TRUE);
if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
JLI_ReportErrorMessage(CFG_ERROR9);
exit(4);
}
/* exec child can do error checking on the existence of the path */ /* exec child can do error checking on the existence of the path */
jvmpathExists = GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, GetArchPath(wanted)); jvmpathExists = GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, GetArchPath(wanted));
} }
EndDataModelSpeculate: /* give up and let other code report error message */
;
#else #else
JLI_ReportErrorMessage(JRE_ERROR2, wanted); JLI_ReportErrorMessage(JRE_ERROR2, wanted);
exit(1); exit(1);
...@@ -398,9 +404,9 @@ GetJVMPath(const char *jrepath, const char *jvmtype, ...@@ -398,9 +404,9 @@ GetJVMPath(const char *jrepath, const char *jvmtype,
struct stat s; struct stat s;
if (JLI_StrChr(jvmtype, '/')) { if (JLI_StrChr(jvmtype, '/')) {
sprintf(jvmpath, "%s/" JVM_DLL, jvmtype); JLI_Snprintf(jvmpath, jvmpathsize, "%s/" JVM_DLL, jvmtype);
} else { } else {
sprintf(jvmpath, "%s/lib/%s/%s/" JVM_DLL, jrepath, arch, jvmtype); JLI_Snprintf(jvmpath, jvmpathsize, "%s/lib/%s/%s/" JVM_DLL, jrepath, arch, jvmtype);
} }
JLI_TraceLauncher("Does `%s' exist ... ", jvmpath); JLI_TraceLauncher("Does `%s' exist ... ", jvmpath);
...@@ -424,26 +430,24 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative) ...@@ -424,26 +430,24 @@ GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative)
if (GetApplicationHome(path, pathsize)) { if (GetApplicationHome(path, pathsize)) {
/* Is JRE co-located with the application? */ /* Is JRE co-located with the application? */
sprintf(libjava, "%s/lib/%s/" JAVA_DLL, path, arch); JLI_Snprintf(libjava, sizeof(libjava), "%s/lib/%s/" JAVA_DLL, path, arch);
if (access(libjava, F_OK) == 0) { if (access(libjava, F_OK) == 0) {
goto found; JLI_TraceLauncher("JRE path is %s\n", path);
return JNI_TRUE;
} }
/* Does the app ship a private JRE in <apphome>/jre directory? */ /* Does the app ship a private JRE in <apphome>/jre directory? */
sprintf(libjava, "%s/jre/lib/%s/" JAVA_DLL, path, arch); JLI_Snprintf(libjava, sizeof(libjava), "%s/jre/lib/%s/" JAVA_DLL, path, arch);
if (access(libjava, F_OK) == 0) { if (access(libjava, F_OK) == 0) {
JLI_StrCat(path, "/jre"); JLI_StrCat(path, "/jre");
goto found; JLI_TraceLauncher("JRE path is %s\n", path);
return JNI_TRUE;
} }
} }
if (!speculative) if (!speculative)
JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
return JNI_FALSE; return JNI_FALSE;
found:
JLI_TraceLauncher("JRE path is %s\n", path);
return JNI_TRUE;
} }
jboolean jboolean
...@@ -463,14 +467,18 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) ...@@ -463,14 +467,18 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
int location; int location;
fp = fopen(jvmpath, "r"); fp = fopen(jvmpath, "r");
if(fp == NULL) if (fp == NULL) {
goto error; JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
return JNI_FALSE;
}
/* read in elf header */ /* read in elf header */
count = fread((void*)(&elf_head), sizeof(Elf32_Ehdr), 1, fp); count = fread((void*)(&elf_head), sizeof(Elf32_Ehdr), 1, fp);
fclose(fp); fclose(fp);
if(count < 1) if (count < 1) {
goto error; JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
return JNI_FALSE;
}
/* /*
* Check for running a server vm (compiled with -xarch=v8plus) * Check for running a server vm (compiled with -xarch=v8plus)
...@@ -481,16 +489,16 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) ...@@ -481,16 +489,16 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
* does not have to be checked for in binaries with an LP64 data * does not have to be checked for in binaries with an LP64 data
* model. * model.
*/ */
if(elf_head.e_machine == EM_SPARC32PLUS) { if (elf_head.e_machine == EM_SPARC32PLUS) {
char buf[257]; /* recommended buffer size from sysinfo man char buf[257]; /* recommended buffer size from sysinfo man
page */ page */
long length; long length;
char* location; char* location;
length = sysinfo(SI_ISALIST, buf, 257); length = sysinfo(SI_ISALIST, buf, 257);
if(length > 0) { if (length > 0) {
location = JLI_StrStr(buf, "sparcv8plus "); location = JLI_StrStr(buf, "sparcv8plus ");
if(location == NULL) { if (location == NULL) {
JLI_ReportErrorMessage(JVM_ERROR3); JLI_ReportErrorMessage(JVM_ERROR3);
return JNI_FALSE; return JNI_FALSE;
} }
...@@ -498,24 +506,25 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) ...@@ -498,24 +506,25 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
} }
#endif #endif
JLI_ReportErrorMessage(DLL_ERROR1, __LINE__); JLI_ReportErrorMessage(DLL_ERROR1, __LINE__);
goto error; JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
return JNI_FALSE;
} }
ifn->CreateJavaVM = (CreateJavaVM_t) ifn->CreateJavaVM = (CreateJavaVM_t)
dlsym(libjvm, "JNI_CreateJavaVM"); dlsym(libjvm, "JNI_CreateJavaVM");
if (ifn->CreateJavaVM == NULL) if (ifn->CreateJavaVM == NULL) {
goto error; JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
return JNI_FALSE;
}
ifn->GetDefaultJavaVMInitArgs = (GetDefaultJavaVMInitArgs_t) ifn->GetDefaultJavaVMInitArgs = (GetDefaultJavaVMInitArgs_t)
dlsym(libjvm, "JNI_GetDefaultJavaVMInitArgs"); dlsym(libjvm, "JNI_GetDefaultJavaVMInitArgs");
if (ifn->GetDefaultJavaVMInitArgs == NULL) if (ifn->GetDefaultJavaVMInitArgs == NULL) {
goto error;
return JNI_TRUE;
error:
JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror()); JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
return JNI_FALSE; return JNI_FALSE;
}
return JNI_TRUE;
} }
/* /*
...@@ -575,7 +584,7 @@ Resolve(char *indir, char *cmd) ...@@ -575,7 +584,7 @@ Resolve(char *indir, char *cmd)
char name[PATH_MAX + 2], *real; char name[PATH_MAX + 2], *real;
if ((JLI_StrLen(indir) + JLI_StrLen(cmd) + 1) > PATH_MAX) return 0; if ((JLI_StrLen(indir) + JLI_StrLen(cmd) + 1) > PATH_MAX) return 0;
sprintf(name, "%s%c%s", indir, FILE_SEPARATOR, cmd); JLI_Snprintf(name, sizeof(name), "%s%c%s", indir, FILE_SEPARATOR, cmd);
if (!ProgramExists(name)) return 0; if (!ProgramExists(name)) return 0;
real = JLI_MemAlloc(PATH_MAX + 2); real = JLI_MemAlloc(PATH_MAX + 2);
if (!realpath(name, real)) if (!realpath(name, real))
...@@ -622,7 +631,7 @@ FindExecName(char *program) ...@@ -622,7 +631,7 @@ FindExecName(char *program)
else { else {
/* relative path element */ /* relative path element */
char dir[2*PATH_MAX]; char dir[2*PATH_MAX];
sprintf(dir, "%s%c%s", getcwd(cwdbuf, sizeof(cwdbuf)), JLI_Snprintf(dir, sizeof(dir), "%s%c%s", getcwd(cwdbuf, sizeof(cwdbuf)),
FILE_SEPARATOR, s); FILE_SEPARATOR, s);
result = Resolve(dir, program); result = Resolve(dir, program);
} }
...@@ -746,7 +755,7 @@ CheckSanity(char *path, char *dir) ...@@ -746,7 +755,7 @@ CheckSanity(char *path, char *dir)
if (JLI_StrLen(path) + JLI_StrLen(dir) + 11 > PATH_MAX) if (JLI_StrLen(path) + JLI_StrLen(dir) + 11 > PATH_MAX)
return (0); /* Silently reject "impossibly" long paths */ return (0); /* Silently reject "impossibly" long paths */
sprintf(buffer, "%s/%s/bin/java", path, dir); JLI_Snprintf(buffer, sizeof(buffer), "%s/%s/bin/java", path, dir);
return ((access(buffer, X_OK) == 0) ? 1 : 0); return ((access(buffer, X_OK) == 0) ? 1 : 0);
} }
......
...@@ -129,7 +129,7 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname); ...@@ -129,7 +129,7 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname);
static struct sockaddr *getBroadcast(JNIEnv *env, int sock, const char *name, struct sockaddr *brdcast_store); static struct sockaddr *getBroadcast(JNIEnv *env, int sock, const char *name, struct sockaddr *brdcast_store);
static short getSubnet(JNIEnv *env, int sock, const char *ifname); static short getSubnet(JNIEnv *env, int sock, const char *ifname);
static int getIndex(JNIEnv *env, int sock, const char *ifname); static int getIndex(int sock, const char *ifname);
static int getFlags(JNIEnv *env, int sock, const char *ifname); static int getFlags(JNIEnv *env, int sock, const char *ifname);
static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct in_addr* addr, unsigned char *buf); static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct in_addr* addr, unsigned char *buf);
...@@ -753,6 +753,12 @@ static netif *enumInterfaces(JNIEnv *env) { ...@@ -753,6 +753,12 @@ static netif *enumInterfaces(JNIEnv *env) {
* If IPv6 is available then enumerate IPv6 addresses. * If IPv6 is available then enumerate IPv6 addresses.
*/ */
#ifdef AF_INET6 #ifdef AF_INET6
/* User can disable ipv6 expicitly by -Djava.net.preferIPv4Stack=true,
* so we have to call ipv6_available()
*/
if (ipv6_available()) {
sock = openSocket(env, AF_INET6); sock = openSocket(env, AF_INET6);
if (sock < 0 && (*env)->ExceptionOccurred(env)) { if (sock < 0 && (*env)->ExceptionOccurred(env)) {
freeif(ifs); freeif(ifs);
...@@ -766,6 +772,8 @@ static netif *enumInterfaces(JNIEnv *env) { ...@@ -766,6 +772,8 @@ static netif *enumInterfaces(JNIEnv *env) {
freeif(ifs); freeif(ifs);
return NULL; return NULL;
} }
}
#endif #endif
return ifs; return ifs;
...@@ -911,7 +919,7 @@ netif *addif(JNIEnv *env, int sock, const char * if_name, netif *ifs, struct soc ...@@ -911,7 +919,7 @@ netif *addif(JNIEnv *env, int sock, const char * if_name, netif *ifs, struct soc
CHECKED_MALLOC3(currif, netif *, sizeof(netif)+IFNAMSIZ ); CHECKED_MALLOC3(currif, netif *, sizeof(netif)+IFNAMSIZ );
currif->name = (char *) currif+sizeof(netif); currif->name = (char *) currif+sizeof(netif);
strcpy(currif->name, name); strcpy(currif->name, name);
currif->index = getIndex(env,sock,name); currif->index = getIndex(sock, name);
currif->addr = NULL; currif->addr = NULL;
currif->childs = NULL; currif->childs = NULL;
currif->virtual = isVirtual; currif->virtual = isVirtual;
...@@ -946,7 +954,7 @@ netif *addif(JNIEnv *env, int sock, const char * if_name, netif *ifs, struct soc ...@@ -946,7 +954,7 @@ netif *addif(JNIEnv *env, int sock, const char * if_name, netif *ifs, struct soc
CHECKED_MALLOC3(currif, netif *, sizeof(netif)+ IFNAMSIZ ); CHECKED_MALLOC3(currif, netif *, sizeof(netif)+ IFNAMSIZ );
currif->name = (char *) currif + sizeof(netif); currif->name = (char *) currif + sizeof(netif);
strcpy(currif->name, vname); strcpy(currif->name, vname);
currif->index = getIndex(env,sock,vname); currif->index = getIndex(sock, vname);
currif->addr = NULL; currif->addr = NULL;
/* Need to duplicate the addr entry? */ /* Need to duplicate the addr entry? */
currif->virtual = 1; currif->virtual = 1;
...@@ -1133,7 +1141,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { ...@@ -1133,7 +1141,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
#endif #endif
static int getIndex(JNIEnv *env, int sock, const char *name){ static int getIndex(int sock, const char *name){
/* /*
* Try to get the interface index * Try to get the interface index
* (Not supported on Solaris 2.6 or 7) * (Not supported on Solaris 2.6 or 7)
...@@ -1390,6 +1398,13 @@ static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family) ...@@ -1390,6 +1398,13 @@ static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family)
continue; continue;
} }
#ifdef AF_INET6
if (ifr->lifr_addr.ss_family == AF_INET6) {
struct sockaddr_in6 *s6= (struct sockaddr_in6 *)&(ifr->lifr_addr);
s6->sin6_scope_id = getIndex(sock, ifr->lifr_name);
}
#endif
/* add to the list */ /* add to the list */
ifs = addif(env, sock,ifr->lifr_name, ifs, (struct sockaddr *)&(ifr->lifr_addr),family, (short) ifr->lifr_addrlen); ifs = addif(env, sock,ifr->lifr_name, ifs, (struct sockaddr *)&(ifr->lifr_addr),family, (short) ifr->lifr_addrlen);
...@@ -1407,7 +1422,7 @@ static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family) ...@@ -1407,7 +1422,7 @@ static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family)
return ifs; return ifs;
} }
static int getIndex(JNIEnv *env, int sock, const char *name){ static int getIndex(int sock, const char *name){
/* /*
* Try to get the interface index * Try to get the interface index
* (Not supported on Solaris 2.6 or 7) * (Not supported on Solaris 2.6 or 7)
......
/* /*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, 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
...@@ -80,26 +80,22 @@ GetArchPath(int nbits) ...@@ -80,26 +80,22 @@ GetArchPath(int nbits)
* *
*/ */
void void
CreateExecutionEnvironment(int *_argc, CreateExecutionEnvironment(int *pargc, char ***pargv,
char ***_argv, char *jrepath, jint so_jrepath,
char jrepath[], char *jvmpath, jint so_jvmpath) {
jint so_jrepath,
char jvmpath[],
jint so_jvmpath,
char **original_argv) {
char * jvmtype; char * jvmtype;
int i = 0; int i = 0;
char** pargv = *_argv;
int running = CURRENT_DATA_MODEL; int running = CURRENT_DATA_MODEL;
int wanted = running; int wanted = running;
for (i = 0; i < *_argc ; i++) { char** argv = *pargv;
if (JLI_StrCmp(pargv[i], "-J-d64") == 0 || JLI_StrCmp(pargv[i], "-d64") == 0) { for (i = 0; i < *pargc ; i++) {
if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) {
wanted = 64; wanted = 64;
continue; continue;
} }
if (JLI_StrCmp(pargv[i], "-J-d32") == 0 || JLI_StrCmp(pargv[i], "-d32") == 0) { if (JLI_StrCmp(argv[i], "-J-d32") == 0 || JLI_StrCmp(argv[i], "-d32") == 0) {
wanted = 32; wanted = 32;
continue; continue;
} }
...@@ -123,7 +119,12 @@ CreateExecutionEnvironment(int *_argc, ...@@ -123,7 +119,12 @@ CreateExecutionEnvironment(int *_argc,
JLI_ReportErrorMessage(CFG_ERROR7); JLI_ReportErrorMessage(CFG_ERROR7);
exit(1); exit(1);
} }
jvmtype = CheckJvmType(_argc, _argv, JNI_FALSE);
jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
JLI_ReportErrorMessage(CFG_ERROR9);
exit(4);
}
jvmpath[0] = '\0'; jvmpath[0] = '\0';
if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) { if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
...@@ -131,7 +132,6 @@ CreateExecutionEnvironment(int *_argc, ...@@ -131,7 +132,6 @@ CreateExecutionEnvironment(int *_argc,
exit(4); exit(4);
} }
/* If we got here, jvmpath has been correctly initialized. */ /* If we got here, jvmpath has been correctly initialized. */
} }
...@@ -203,19 +203,21 @@ EnsureJreInstallation(const char* jrepath) ...@@ -203,19 +203,21 @@ EnsureJreInstallation(const char* jrepath)
PREJVMSTART PreJVMStart; PREJVMSTART PreJVMStart;
struct stat s; struct stat s;
/* Make sure the jrepath contains something */
if (jrepath[0] == NULL) {
return;
}
/* 32 bit windows only please */ /* 32 bit windows only please */
if (strcmp(GetArch(), "i386") != 0 ) { if (JLI_StrCmp(GetArch(), "i386") != 0 ) {
return; return;
} }
/* Does our bundle directory exist ? */ /* Does our bundle directory exist ? */
strcpy(tmpbuf, jrepath); JLI_Snprintf(tmpbuf, sizeof(tmpbuf), "%s\\lib\\bundles", jrepath);
strcat(tmpbuf, "\\lib\\bundles");
if (stat(tmpbuf, &s) != 0) { if (stat(tmpbuf, &s) != 0) {
return; return;
} }
/* Does our jkernel dll exist ? */ /* Does our jkernel dll exist ? */
strcpy(tmpbuf, jrepath); JLI_Snprintf(tmpbuf, sizeof(tmpbuf), "%s\\bin\\jkernel.dll", jrepath);
strcat(tmpbuf, "\\bin\\jkernel.dll");
if (stat(tmpbuf, &s) != 0) { if (stat(tmpbuf, &s) != 0) {
return; return;
} }
...@@ -249,30 +251,30 @@ GetJREPath(char *path, jint pathsize) ...@@ -249,30 +251,30 @@ GetJREPath(char *path, jint pathsize)
if (GetApplicationHome(path, pathsize)) { if (GetApplicationHome(path, pathsize)) {
/* Is JRE co-located with the application? */ /* Is JRE co-located with the application? */
sprintf(javadll, "%s\\bin\\" JAVA_DLL, path); JLI_Snprintf(javadll, sizeof(javadll), "%s\\bin\\" JAVA_DLL, path);
if (stat(javadll, &s) == 0) { if (stat(javadll, &s) == 0) {
goto found; JLI_TraceLauncher("JRE path is %s\n", path);
return JNI_TRUE;
} }
/* Does this app ship a private JRE in <apphome>\jre directory? */ /* Does this app ship a private JRE in <apphome>\jre directory? */
sprintf(javadll, "%s\\jre\\bin\\" JAVA_DLL, path); JLI_Snprintf(javadll, sizeof (javadll), "%s\\jre\\bin\\" JAVA_DLL, path);
if (stat(javadll, &s) == 0) { if (stat(javadll, &s) == 0) {
JLI_StrCat(path, "\\jre"); JLI_StrCat(path, "\\jre");
goto found; JLI_TraceLauncher("JRE path is %s\n", path);
return JNI_TRUE;
} }
} }
/* Look for a public JRE on this machine. */ /* Look for a public JRE on this machine. */
if (GetPublicJREHome(path, pathsize)) { if (GetPublicJREHome(path, pathsize)) {
goto found; JLI_TraceLauncher("JRE path is %s\n", path);
return JNI_TRUE;
} }
JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
return JNI_FALSE; return JNI_FALSE;
found:
JLI_TraceLauncher("JRE path is %s\n", path);
return JNI_TRUE;
} }
/* /*
...@@ -286,9 +288,9 @@ GetJVMPath(const char *jrepath, const char *jvmtype, ...@@ -286,9 +288,9 @@ GetJVMPath(const char *jrepath, const char *jvmtype,
{ {
struct stat s; struct stat s;
if (JLI_StrChr(jvmtype, '/') || JLI_StrChr(jvmtype, '\\')) { if (JLI_StrChr(jvmtype, '/') || JLI_StrChr(jvmtype, '\\')) {
sprintf(jvmpath, "%s\\" JVM_DLL, jvmtype); JLI_Snprintf(jvmpath, jvmpathsize, "%s\\" JVM_DLL, jvmtype);
} else { } else {
sprintf(jvmpath, "%s\\bin\\%s\\" JVM_DLL, jrepath, jvmtype); JLI_Snprintf(jvmpath, jvmpathsize, "%s\\bin\\%s\\" JVM_DLL, jrepath, jvmtype);
} }
if (stat(jvmpath, &s) == 0) { if (stat(jvmpath, &s) == 0) {
return JNI_TRUE; return JNI_TRUE;
......
...@@ -26,7 +26,7 @@ import java.util.*; ...@@ -26,7 +26,7 @@ import java.util.*;
/* /*
* @test * @test
* @bug 6911258 6962571 * @bug 6911258 6962571 6963622
* @summary Basic tests of suppressed exceptions * @summary Basic tests of suppressed exceptions
* @author Joseph D. Darcy * @author Joseph D. Darcy
*/ */
...@@ -35,11 +35,22 @@ public class SuppressedExceptions { ...@@ -35,11 +35,22 @@ public class SuppressedExceptions {
private static String message = "Bad suppressed exception information"; private static String message = "Bad suppressed exception information";
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
noSelfSuppression();
basicSupressionTest(); basicSupressionTest();
serializationTest(); serializationTest();
selfReference(); selfReference();
} }
private static void noSelfSuppression() {
Throwable throwable = new Throwable();
try {
throwable.addSuppressedException(throwable);
throw new RuntimeException("IllegalArgumentException for self-suppresion not thrown.");
} catch (IllegalArgumentException iae) {
; // Expected
}
}
private static void basicSupressionTest() { private static void basicSupressionTest() {
Throwable throwable = new Throwable(); Throwable throwable = new Throwable();
RuntimeException suppressed = new RuntimeException("A suppressed exception."); RuntimeException suppressed = new RuntimeException("A suppressed exception.");
...@@ -156,9 +167,8 @@ public class SuppressedExceptions { ...@@ -156,9 +167,8 @@ public class SuppressedExceptions {
throwable1.printStackTrace(); throwable1.printStackTrace();
throwable1.addSuppressedException(throwable1);
throwable1.addSuppressedException(throwable2); throwable1.addSuppressedException(throwable2);
throwable2.addSuppressedException(throwable1);
throwable1.printStackTrace(); throwable1.printStackTrace();
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/** /**
* @test * @test
* @bug 6214234 * @bug 6214234 6967937
* @summary IPv6 scope_id for local addresses not set in Solaris 10 * @summary IPv6 scope_id for local addresses not set in Solaris 10
*/ */
...@@ -51,6 +51,7 @@ public class B6214234 { ...@@ -51,6 +51,7 @@ public class B6214234 {
return; return;
} }
if (addr.getScopeId() == 0) { if (addr.getScopeId() == 0) {
System.out.println("addr: "+ addr);
throw new RuntimeException ("Non zero scope_id expected"); throw new RuntimeException ("Non zero scope_id expected");
} }
} }
......
/*
* Copyright (c) 2010, 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
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 6964714
* @run main/othervm NetworkInterfaceV6List
* @summary Test the networkinterface listing with java.net.preferIPv4Stack=true.
*/
import java.net.*;
import java.util.*;
public class IPv4Only {
public static void main(String[] args) throws Exception {
System.setProperty("java.net.preferIPv4Stack","true");
Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
while (nifs.hasMoreElements()) {
NetworkInterface nif = nifs.nextElement();
Enumeration<InetAddress> addrs = nif.getInetAddresses();
while (addrs.hasMoreElements()) {
InetAddress hostAddr = addrs.nextElement();
if ( hostAddr instanceof Inet6Address ){
throw new RuntimeException( "NetworkInterfaceV6List failed - found v6 address " + hostAddr.getHostAddress() );
}
}
}
}
}
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
# @test # @test
# @bug 6942989 # @bug 6942989
# @ignore until 6964018 is fixed
# @summary Check for WeakReference leak in anonymous Logger objects # @summary Check for WeakReference leak in anonymous Logger objects
# @author Daniel D. Daugherty # @author Daniel D. Daugherty
# #
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
# @test # @test
# @bug 6942989 # @bug 6942989
# @ignore until 6964018 is fixed
# @summary Check for WeakReference leak in Logger objects # @summary Check for WeakReference leak in Logger objects
# @author Daniel D. Daugherty # @author Daniel D. Daugherty
# #
......
/*
* Copyright (c) 2010, 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
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6670889
* @summary Keystore created under Hindi Locale causing ArrayIndexOutOfBoundsException
* @run main/othervm -Duser.language=hi -Duser.region=IN LocaleInTime
*/
import java.util.Date;
import sun.security.util.DerOutputStream;
import sun.security.util.DerValue;
public class LocaleInTime {
public static void main(String args[]) throws Exception {
DerOutputStream out = new DerOutputStream();
out.putUTCTime(new Date());
DerValue val = new DerValue(out.toByteArray());
System.out.println(val.getUTCTime());
}
}
/* /*
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, 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
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/** /**
* @test * @test
* @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
* @summary Argument parsing validation. * @summary Argument parsing validation.
* @compile -XDignore.symbol.file Arrrghs.java TestHelper.java * @compile -XDignore.symbol.file Arrrghs.java TestHelper.java
* @run main Arrrghs * @run main Arrrghs
...@@ -223,6 +223,20 @@ public class Arrrghs { ...@@ -223,6 +223,20 @@ public class Arrrghs {
tr.checkPositive(); tr.checkPositive();
tr.isNotZeroOutput(); tr.isNotZeroOutput();
System.out.println(tr); System.out.println(tr);
// 6753938, test for non-negative exit value for an incorrectly formed
// command line, '% java'
tr = TestHelper.doExec(TestHelper.javaCmd);
tr.checkNegative();
tr.isNotZeroOutput();
System.out.println(tr);
// 6753938, test for non-negative exit value for an incorrectly formed
// command line, '% java -Xcomp'
tr = TestHelper.doExec(TestHelper.javaCmd, "-Xcomp");
tr.checkNegative();
tr.isNotZeroOutput();
System.out.println(tr);
} }
/* /*
......
# Copyright (c) 2007, 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
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# This is a not quite automated Makefile to generate the Solaris
# binaries used for the SolarisRunpath.sh test. First,
# libraryCaller.java program must be compiled. Next, javah is called
# on the class file to generate the needed header file for the jni
# code. Then, 2 Solaris executables are generated in separate
# directories, a default one meant to be pointed to by LD_LIBRARY_PATH
# (this function returns 0) and another one for the data model
# specific LD_LIBRARY_PATH (this function returns the size of integers
# in the data model, 32 or 64). A better makefile would run, say
# isainfo -v, and generated binaries for all supported data models.
# To do this a mapping would be needed from data models to
# architecture dependent compiler options; e.g. 64 bit on sparc =>
# -xarch=v9. Also, the settings for JINCLUDE, JAVAC, and JAVAH should
# come from the current build. The C compiler should be the one
# approved for the build. To be extra safe, the binaries should be
# generated on the oldest Solaris release supported by the current
# Java build.
# Include directory in JRE or JDK install; e.g.
JINCLUDE=/java/re/jdk/1.4.1/latest/binaries/solaris-sparc/include
# Path to javac executable; e.g.
JAVAC=/java/re/jdk/1.4.1/promoted/fcs/b21/binaries/solaris-sparc/bin/javac
# Path to javah executable; e.g.
JAVAH=/java/re/jdk/1.4.1/promoted/fcs/b21/binaries/solaris-sparc/bin/javah
# Path to C compiler; e.g.
CC=/java/devtools/sparc/SUNWspro/SC6.1/bin/cc
ARCH=`uname -p`
# 32-bit Solaris Options
DM=32
# Default architecture is fine for both sparc and x86 32-bit builds
OPTIONS=
# 64-bit Solaris Options
#DM=64
#OPTIONS=-xarch=v9
all: libraryCaller.java libraryCaller.c
$(JAVAC) libraryCaller.java; \
$(JAVAH) libraryCaller; \
$(CC) -G -I$(JINCLUDE) -I$(JINCLUDE)/solaris -DRETURN_VALUE=0 \
$(OPTIONS) libraryCaller.c \
-o lib/$(ARCH)/lib$(DM)/liblibrary.so; \
$(CC) -G -I$(JINCLUDE) -I$(JINCLUDE)/solaris -DRETURN_VALUE=$(DM)\
$(OPTIONS) libraryCaller.c \
-o lib/$(ARCH)/lib$(DM)/lib$(DM)/liblibrary.so;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册