diff --git a/jdk/src/share/bin/emessages.h b/jdk/src/share/bin/emessages.h
index 008cc1f906a..311a8fa61ce 100644
--- a/jdk/src/share/bin/emessages.h
+++ b/jdk/src/share/bin/emessages.h
@@ -50,11 +50,6 @@
#define JAR_ERROR2 "Error: Unable to access jarfile %s"
#define JAR_ERROR3 "Error: Invalid or corrupt jarfile %s"
-#define CLS_ERROR1 "Error: Could not find the main class %s.\n" JNI_ERROR
-#define CLS_ERROR2 "Error: Failed to load Main Class: %s\n%s"
-#define CLS_ERROR3 "Error: No main method found in specified class.\n" GEN_ERROR
-#define CLS_ERROR4 "Error: Main method not public\n" GEN_ERROR
-
#define CFG_WARN1 "Warning: %s VM not supported; %s VM will be used"
#define CFG_WARN2 "Warning: No leading - on line %d of `%s'"
#define CFG_WARN3 "Warning: Missing VM type on line %d of `%s'"
diff --git a/jdk/src/share/bin/java.c b/jdk/src/share/bin/java.c
index 89ae857b136..0feafc1ed41 100644
--- a/jdk/src/share/bin/java.c
+++ b/jdk/src/share/bin/java.c
@@ -102,8 +102,7 @@ static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv,
InvocationFunctions *ifn);
static jstring NewPlatformString(JNIEnv *env, char *s);
static jobjectArray NewPlatformStringArray(JNIEnv *env, char **strv, int strc);
-static jclass LoadClass(JNIEnv *env, char *name);
-static jstring GetMainClassName(JNIEnv *env, char *jarname);
+static jclass LoadMainClass(JNIEnv *env, jboolean isJar, char *name);
static void TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***pargv);
static jboolean AddApplicationOptions(int cpathc, const char **cpathv);
@@ -301,6 +300,22 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
}
+#define CHECK_EXCEPTION_NULL_LEAVE(e) \
+ if ((*env)->ExceptionOccurred(env)) { \
+ JLI_ReportExceptionDescription(env); \
+ goto leave; \
+ } \
+ if ((e) == NULL) { \
+ JLI_ReportErrorMessage(JNI_ERROR); \
+ goto leave; \
+ }
+
+#define CHECK_EXCEPTION_LEAVE(rv) \
+ if ((*env)->ExceptionOccurred(env)) { \
+ JLI_ReportExceptionDescription(env); \
+ ret = (rv); \
+ goto leave; \
+ }
int JNICALL
JavaMain(void * _args)
@@ -321,9 +336,7 @@ JavaMain(void * _args)
int ret = 0;
jlong start, end;
-
/* Initialize the virtual machine */
-
start = CounterGet();
if (!InitializeJVM(&vm, &env, &ifn)) {
JLI_ReportErrorMessage(JVM_ERROR1);
@@ -332,11 +345,7 @@ JavaMain(void * _args)
if (printVersion || showVersion) {
PrintJavaVersion(env, showVersion);
- if ((*env)->ExceptionOccurred(env)) {
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(JNI_ERROR);
- goto leave;
- }
+ CHECK_EXCEPTION_LEAVE(0);
if (printVersion) {
ret = 0;
goto leave;
@@ -346,11 +355,7 @@ JavaMain(void * _args)
/* If the user specified neither a class name nor a JAR file */
if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) {
PrintUsage(env, printXUsage);
- if ((*env)->ExceptionOccurred(env)) {
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(JNI_ERROR);
- ret=1;
- }
+ CHECK_EXCEPTION_LEAVE(1);
goto leave;
}
@@ -395,99 +400,25 @@ JavaMain(void * _args)
* the environment (and remove these comments).
*/
if (jarfile != 0) {
- mainClassName = GetMainClassName(env, jarfile);
- if ((*env)->ExceptionOccurred(env)) {
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(JNI_ERROR);
- goto leave;
- }
- if (mainClassName == NULL) {
- JLI_ReportErrorMessage(JAR_ERROR1,jarfile, GEN_ERROR);
- goto leave;
- }
- classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
- if (classname == NULL) {
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(JNI_ERROR);
- goto leave;
- }
- mainClass = LoadClass(env, classname);
- if(mainClass == NULL) { /* exception occured */
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(CLS_ERROR1, classname);
- goto leave;
- }
- (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
+ mainClass = LoadMainClass(env, JNI_TRUE, jarfile);
} else {
- mainClassName = NewPlatformString(env, classname);
- if (mainClassName == NULL) {
- JLI_ReportErrorMessage(CLS_ERROR2, classname, GEN_ERROR);
- goto leave;
- }
- classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
- if (classname == NULL) {
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(JNI_ERROR);
- goto leave;
- }
- mainClass = LoadClass(env, classname);
- if(mainClass == NULL) { /* exception occured */
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(CLS_ERROR1, classname);
- goto leave;
- }
- (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
+ mainClass = LoadMainClass(env, JNI_FALSE, classname);
}
+ CHECK_EXCEPTION_NULL_LEAVE(mainClass);
- /* Get the application's main method */
+ /*
+ * The LoadMainClass not only loads the main class, it will also ensure
+ * that the main method's signature is correct, therefore further checking
+ * is not required. The main method is invoked here so that extraneous java
+ * stacks are not in the application stack trace.
+ */
mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
"([Ljava/lang/String;)V");
- if (mainID == NULL) {
- if ((*env)->ExceptionOccurred(env)) {
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(JNI_ERROR);
- } else {
- JLI_ReportErrorMessage(CLS_ERROR3);
- }
- goto leave;
- }
-
- { /* Make sure the main method is public */
- jint mods;
- jmethodID mid;
- jobject obj = (*env)->ToReflectedMethod(env, mainClass,
- mainID, JNI_TRUE);
-
- if( obj == NULL) { /* exception occurred */
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(JNI_ERROR);
- goto leave;
- }
-
- mid =
- (*env)->GetMethodID(env,
- (*env)->GetObjectClass(env, obj),
- "getModifiers", "()I");
- if ((*env)->ExceptionOccurred(env)) {
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(JNI_ERROR);
- goto leave;
- }
-
- mods = (*env)->CallIntMethod(env, obj, mid);
- if ((mods & 1) == 0) { /* if (!Modifier.isPublic(mods)) ... */
- JLI_ReportErrorMessage(CLS_ERROR4);
- goto leave;
- }
- }
+ CHECK_EXCEPTION_NULL_LEAVE(mainID);
/* Build argument array */
mainArgs = NewPlatformStringArray(env, argv, argc);
- if (mainArgs == NULL) {
- JLI_ReportExceptionDescription(env);
- JLI_ReportErrorMessage(JNI_ERROR);
- goto leave;
- }
+ CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
/* Invoke main method. */
(*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
@@ -498,8 +429,9 @@ JavaMain(void * _args)
*/
ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
+leave:
/*
- * Detach the main thread so that it appears to have ended when
+ * 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
@@ -508,10 +440,7 @@ JavaMain(void * _args)
if ((*vm)->DetachCurrentThread(vm) != 0) {
JLI_ReportErrorMessage(JVM_ERROR2);
ret = 1;
- goto leave;
}
-
- leave:
/*
* Wait for all non-daemon threads to end, then destroy the VM.
* This will actually create a trivial new Java waiter thread
@@ -525,7 +454,6 @@ JavaMain(void * _args)
return ret;
}
-
/*
* Checks the command line options to find which JVM type was
* specified. If no command line option was given for the JVM type,
@@ -1159,7 +1087,7 @@ static jstring getPlatformEncoding(JNIEnv *env) {
if (propname) {
jclass cls;
jmethodID mid;
- NULL_CHECK0 (cls = (*env)->FindClass(env, "java/lang/System"));
+ NULL_CHECK0 (cls = FindBootStrapClass(env, "java/lang/System"));
NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
env, cls,
"getProperty",
@@ -1174,7 +1102,7 @@ static jstring getPlatformEncoding(JNIEnv *env) {
static jboolean isEncodingSupported(JNIEnv *env, jstring enc) {
jclass cls;
jmethodID mid;
- NULL_CHECK0 (cls = (*env)->FindClass(env, "java/nio/charset/Charset"));
+ NULL_CHECK0 (cls = FindBootStrapClass(env, "java/nio/charset/Charset"));
NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
env, cls,
"isSupported",
@@ -1203,8 +1131,8 @@ NewPlatformString(JNIEnv *env, char *s)
jstring str = 0;
(*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
if (!(*env)->ExceptionOccurred(env)) {
+ NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String"));
if (isEncodingSupported(env, enc) == JNI_TRUE) {
- NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "EOFException
with null
* as its error detail message.
diff --git a/jdk/src/share/classes/java/io/FileNotFoundException.java b/jdk/src/share/classes/java/io/FileNotFoundException.java
index 18ed3f18cb2..198bbba8166 100644
--- a/jdk/src/share/classes/java/io/FileNotFoundException.java
+++ b/jdk/src/share/classes/java/io/FileNotFoundException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -41,6 +41,7 @@ package java.io;
*/
public class FileNotFoundException extends IOException {
+ private static final long serialVersionUID = -897856973823710492L;
/**
* Constructs a FileNotFoundException
with
diff --git a/jdk/src/share/classes/java/io/InterruptedIOException.java b/jdk/src/share/classes/java/io/InterruptedIOException.java
index 41cedf6b87a..054fe2bb133 100644
--- a/jdk/src/share/classes/java/io/InterruptedIOException.java
+++ b/jdk/src/share/classes/java/io/InterruptedIOException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2000 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -41,6 +41,8 @@ package java.io;
*/
public
class InterruptedIOException extends IOException {
+ private static final long serialVersionUID = 4020568460727500567L;
+
/**
* Constructs an InterruptedIOException
with
* null
as its error detail message.
diff --git a/jdk/src/share/classes/java/io/SyncFailedException.java b/jdk/src/share/classes/java/io/SyncFailedException.java
index b2583ad2bdc..b08c8d97dbf 100644
--- a/jdk/src/share/classes/java/io/SyncFailedException.java
+++ b/jdk/src/share/classes/java/io/SyncFailedException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2008 Sun Microsystems, Inc. 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
@@ -34,6 +34,8 @@ package java.io;
* @since JDK1.1
*/
public class SyncFailedException extends IOException {
+ private static final long serialVersionUID = -2353342684412443330L;
+
/**
* Constructs an SyncFailedException with a detail message.
* A detail message is a String that describes this particular exception.
diff --git a/jdk/src/share/classes/java/io/UTFDataFormatException.java b/jdk/src/share/classes/java/io/UTFDataFormatException.java
index bb89c164521..2f789a0192f 100644
--- a/jdk/src/share/classes/java/io/UTFDataFormatException.java
+++ b/jdk/src/share/classes/java/io/UTFDataFormatException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -44,6 +44,8 @@ package java.io;
*/
public
class UTFDataFormatException extends IOException {
+ private static final long serialVersionUID = 420743449228280612L;
+
/**
* Constructs a UTFDataFormatException
with
* null
as its error detail message.
diff --git a/jdk/src/share/classes/java/io/UnsupportedEncodingException.java b/jdk/src/share/classes/java/io/UnsupportedEncodingException.java
index 2ee9cb647be..9ccdd2ee603 100644
--- a/jdk/src/share/classes/java/io/UnsupportedEncodingException.java
+++ b/jdk/src/share/classes/java/io/UnsupportedEncodingException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2008 Sun Microsystems, Inc. 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
@@ -33,6 +33,8 @@ package java.io;
public class UnsupportedEncodingException
extends IOException
{
+ private static final long serialVersionUID = -4274276298326136670L;
+
/**
* Constructs an UnsupportedEncodingException without a detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/AbstractMethodError.java b/jdk/src/share/classes/java/lang/AbstractMethodError.java
index 15dcb96a78f..a8f11e7abc9 100644
--- a/jdk/src/share/classes/java/lang/AbstractMethodError.java
+++ b/jdk/src/share/classes/java/lang/AbstractMethodError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -37,6 +37,8 @@ package java.lang;
*/
public
class AbstractMethodError extends IncompatibleClassChangeError {
+ private static final long serialVersionUID = -1654391082989018462L;
+
/**
* Constructs an AbstractMethodError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/ArithmeticException.java b/jdk/src/share/classes/java/lang/ArithmeticException.java
index a90cda11c9e..a51d95db821 100644
--- a/jdk/src/share/classes/java/lang/ArithmeticException.java
+++ b/jdk/src/share/classes/java/lang/ArithmeticException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -35,6 +35,8 @@ package java.lang;
*/
public
class ArithmeticException extends RuntimeException {
+ private static final long serialVersionUID = 2256477558314496007L;
+
/**
* Constructs an ArithmeticException
with no detail
* message.
diff --git a/jdk/src/share/classes/java/lang/ArrayIndexOutOfBoundsException.java b/jdk/src/share/classes/java/lang/ArrayIndexOutOfBoundsException.java
index 5c96020bf44..cc51bdd043b 100644
--- a/jdk/src/share/classes/java/lang/ArrayIndexOutOfBoundsException.java
+++ b/jdk/src/share/classes/java/lang/ArrayIndexOutOfBoundsException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -35,6 +35,8 @@ package java.lang;
*/
public
class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException {
+ private static final long serialVersionUID = -5116101128118950844L;
+
/**
* Constructs an ArrayIndexOutOfBoundsException
with no
* detail message.
diff --git a/jdk/src/share/classes/java/lang/ArrayStoreException.java b/jdk/src/share/classes/java/lang/ArrayStoreException.java
index 9aa4f7a9874..af24f1ac2f6 100644
--- a/jdk/src/share/classes/java/lang/ArrayStoreException.java
+++ b/jdk/src/share/classes/java/lang/ArrayStoreException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -39,6 +39,8 @@ package java.lang;
*/
public
class ArrayStoreException extends RuntimeException {
+ private static final long serialVersionUID = -4522193890499838241L;
+
/**
* Constructs an ArrayStoreException
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/AssertionError.java b/jdk/src/share/classes/java/lang/AssertionError.java
index 0e6e45c210b..b64b7cbae3d 100644
--- a/jdk/src/share/classes/java/lang/AssertionError.java
+++ b/jdk/src/share/classes/java/lang/AssertionError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2008 Sun Microsystems, Inc. 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
@@ -43,6 +43,8 @@ package java.lang;
* @since 1.4
*/
public class AssertionError extends Error {
+ private static final long serialVersionUID = -5013299493970297370L;
+
/**
* Constructs an AssertionError with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/ClassCastException.java b/jdk/src/share/classes/java/lang/ClassCastException.java
index 057b55bb5e3..310c87f94d9 100644
--- a/jdk/src/share/classes/java/lang/ClassCastException.java
+++ b/jdk/src/share/classes/java/lang/ClassCastException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -39,6 +39,8 @@ package java.lang;
*/
public
class ClassCastException extends RuntimeException {
+ private static final long serialVersionUID = -9223365651070458532L;
+
/**
* Constructs a ClassCastException
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/ClassCircularityError.java b/jdk/src/share/classes/java/lang/ClassCircularityError.java
index 5d522626d30..27d5dfbf08c 100644
--- a/jdk/src/share/classes/java/lang/ClassCircularityError.java
+++ b/jdk/src/share/classes/java/lang/ClassCircularityError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -33,6 +33,8 @@ package java.lang;
* @since JDK1.0
*/
public class ClassCircularityError extends LinkageError {
+ private static final long serialVersionUID = 1054362542914539689L;
+
/**
* Constructs a {@code ClassCircularityError} with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/ClassFormatError.java b/jdk/src/share/classes/java/lang/ClassFormatError.java
index d2e61a4e290..75a042118be 100644
--- a/jdk/src/share/classes/java/lang/ClassFormatError.java
+++ b/jdk/src/share/classes/java/lang/ClassFormatError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -35,6 +35,8 @@ package java.lang;
*/
public
class ClassFormatError extends LinkageError {
+ private static final long serialVersionUID = -8420114879011949195L;
+
/**
* Constructs a ClassFormatError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/CloneNotSupportedException.java b/jdk/src/share/classes/java/lang/CloneNotSupportedException.java
index d3b7b3373dc..cfa643fc475 100644
--- a/jdk/src/share/classes/java/lang/CloneNotSupportedException.java
+++ b/jdk/src/share/classes/java/lang/CloneNotSupportedException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -43,6 +43,8 @@ package java.lang;
public
class CloneNotSupportedException extends Exception {
+ private static final long serialVersionUID = 5195511250079656443L;
+
/**
* Constructs a CloneNotSupportedException
with no
* detail message.
diff --git a/jdk/src/share/classes/java/lang/EnumConstantNotPresentException.java b/jdk/src/share/classes/java/lang/EnumConstantNotPresentException.java
index c09a9129656..4807691b210 100644
--- a/jdk/src/share/classes/java/lang/EnumConstantNotPresentException.java
+++ b/jdk/src/share/classes/java/lang/EnumConstantNotPresentException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2004-2008 Sun Microsystems, Inc. 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
@@ -33,6 +33,8 @@ package java.lang;
* @since 1.5
*/
public class EnumConstantNotPresentException extends RuntimeException {
+ private static final long serialVersionUID = -6046998521960521108L;
+
/**
* The type of the missing enum constant.
*/
diff --git a/jdk/src/share/classes/java/lang/IllegalAccessError.java b/jdk/src/share/classes/java/lang/IllegalAccessError.java
index 58812dbffec..959c9421913 100644
--- a/jdk/src/share/classes/java/lang/IllegalAccessError.java
+++ b/jdk/src/share/classes/java/lang/IllegalAccessError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -37,6 +37,8 @@ package java.lang;
* @since JDK1.0
*/
public class IllegalAccessError extends IncompatibleClassChangeError {
+ private static final long serialVersionUID = -8988904074992417891L;
+
/**
* Constructs an IllegalAccessError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/IllegalAccessException.java b/jdk/src/share/classes/java/lang/IllegalAccessException.java
index 8f3ca867725..19b51b90fef 100644
--- a/jdk/src/share/classes/java/lang/IllegalAccessException.java
+++ b/jdk/src/share/classes/java/lang/IllegalAccessException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2000 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -57,6 +57,8 @@ package java.lang;
* @since JDK1.0
*/
public class IllegalAccessException extends Exception {
+ private static final long serialVersionUID = 6616958222490762034L;
+
/**
* Constructs an IllegalAccessException
without a
* detail message.
diff --git a/jdk/src/share/classes/java/lang/IllegalMonitorStateException.java b/jdk/src/share/classes/java/lang/IllegalMonitorStateException.java
index b719afa0fce..6375a10b2c6 100644
--- a/jdk/src/share/classes/java/lang/IllegalMonitorStateException.java
+++ b/jdk/src/share/classes/java/lang/IllegalMonitorStateException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -40,6 +40,8 @@ package java.lang;
*/
public
class IllegalMonitorStateException extends RuntimeException {
+ private static final long serialVersionUID = 3713306369498869069L;
+
/**
* Constructs an IllegalMonitorStateException
with no
* detail message.
diff --git a/jdk/src/share/classes/java/lang/IllegalThreadStateException.java b/jdk/src/share/classes/java/lang/IllegalThreadStateException.java
index 7f76da0dd0b..56ced227adb 100644
--- a/jdk/src/share/classes/java/lang/IllegalThreadStateException.java
+++ b/jdk/src/share/classes/java/lang/IllegalThreadStateException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -37,6 +37,8 @@ package java.lang;
* @since JDK1.0
*/
public class IllegalThreadStateException extends IllegalArgumentException {
+ private static final long serialVersionUID = -7626246362397460174L;
+
/**
* Constructs an IllegalThreadStateException
with no
* detail message.
diff --git a/jdk/src/share/classes/java/lang/IncompatibleClassChangeError.java b/jdk/src/share/classes/java/lang/IncompatibleClassChangeError.java
index a2688c0c101..a92a18b7a79 100644
--- a/jdk/src/share/classes/java/lang/IncompatibleClassChangeError.java
+++ b/jdk/src/share/classes/java/lang/IncompatibleClassChangeError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -35,6 +35,8 @@ package java.lang;
*/
public
class IncompatibleClassChangeError extends LinkageError {
+ private static final long serialVersionUID = -4914975503642802119L;
+
/**
* Constructs an IncompatibleClassChangeError
with no
* detail message.
diff --git a/jdk/src/share/classes/java/lang/IndexOutOfBoundsException.java b/jdk/src/share/classes/java/lang/IndexOutOfBoundsException.java
index 72a8b67f0e0..1375204df70 100644
--- a/jdk/src/share/classes/java/lang/IndexOutOfBoundsException.java
+++ b/jdk/src/share/classes/java/lang/IndexOutOfBoundsException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -36,6 +36,8 @@ package java.lang;
*/
public
class IndexOutOfBoundsException extends RuntimeException {
+ private static final long serialVersionUID = 234122996006267687L;
+
/**
* Constructs an IndexOutOfBoundsException
with no
* detail message.
diff --git a/jdk/src/share/classes/java/lang/InstantiationError.java b/jdk/src/share/classes/java/lang/InstantiationError.java
index 4824b3d4347..9724fc48722 100644
--- a/jdk/src/share/classes/java/lang/InstantiationError.java
+++ b/jdk/src/share/classes/java/lang/InstantiationError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -40,6 +40,8 @@ package java.lang;
public
class InstantiationError extends IncompatibleClassChangeError {
+ private static final long serialVersionUID = -4885810657349421204L;
+
/**
* Constructs an InstantiationError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/InstantiationException.java b/jdk/src/share/classes/java/lang/InstantiationException.java
index ab008ab6b9e..ace382ae437 100644
--- a/jdk/src/share/classes/java/lang/InstantiationException.java
+++ b/jdk/src/share/classes/java/lang/InstantiationException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -44,6 +44,8 @@ package java.lang;
*/
public
class InstantiationException extends Exception {
+ private static final long serialVersionUID = -8441929162975509110L;
+
/**
* Constructs an {@code InstantiationException} with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/InternalError.java b/jdk/src/share/classes/java/lang/InternalError.java
index d712af5e2bf..b49f7d755f4 100644
--- a/jdk/src/share/classes/java/lang/InternalError.java
+++ b/jdk/src/share/classes/java/lang/InternalError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -34,6 +34,8 @@ package java.lang;
*/
public
class InternalError extends VirtualMachineError {
+ private static final long serialVersionUID = -9062593416125562365L;
+
/**
* Constructs an InternalError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/InterruptedException.java b/jdk/src/share/classes/java/lang/InterruptedException.java
index d57bb62d523..d8ddd36547e 100644
--- a/jdk/src/share/classes/java/lang/InterruptedException.java
+++ b/jdk/src/share/classes/java/lang/InterruptedException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -48,6 +48,8 @@ package java.lang;
*/
public
class InterruptedException extends Exception {
+ private static final long serialVersionUID = 6700697376100628473L;
+
/**
* Constructs an InterruptedException
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/LinkageError.java b/jdk/src/share/classes/java/lang/LinkageError.java
index 237188f3662..39d09467814 100644
--- a/jdk/src/share/classes/java/lang/LinkageError.java
+++ b/jdk/src/share/classes/java/lang/LinkageError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -36,6 +36,8 @@ package java.lang;
*/
public
class LinkageError extends Error {
+ private static final long serialVersionUID = 3579600108157160122L;
+
/**
* Constructs a LinkageError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/NegativeArraySizeException.java b/jdk/src/share/classes/java/lang/NegativeArraySizeException.java
index 64b76354615..903409b8248 100644
--- a/jdk/src/share/classes/java/lang/NegativeArraySizeException.java
+++ b/jdk/src/share/classes/java/lang/NegativeArraySizeException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -33,6 +33,8 @@ package java.lang;
*/
public
class NegativeArraySizeException extends RuntimeException {
+ private static final long serialVersionUID = -8960118058596991861L;
+
/**
* Constructs a NegativeArraySizeException
with no
* detail message.
diff --git a/jdk/src/share/classes/java/lang/NoClassDefFoundError.java b/jdk/src/share/classes/java/lang/NoClassDefFoundError.java
index a8a1273e1be..c9cf976717e 100644
--- a/jdk/src/share/classes/java/lang/NoClassDefFoundError.java
+++ b/jdk/src/share/classes/java/lang/NoClassDefFoundError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-2000 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -40,6 +40,8 @@ package java.lang;
*/
public
class NoClassDefFoundError extends LinkageError {
+ private static final long serialVersionUID = 9095859863287012458L;
+
/**
* Constructs a NoClassDefFoundError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/NoSuchFieldError.java b/jdk/src/share/classes/java/lang/NoSuchFieldError.java
index 5dc7f9c1bc6..8b77c71b18c 100644
--- a/jdk/src/share/classes/java/lang/NoSuchFieldError.java
+++ b/jdk/src/share/classes/java/lang/NoSuchFieldError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -38,6 +38,8 @@ package java.lang;
*/
public
class NoSuchFieldError extends IncompatibleClassChangeError {
+ private static final long serialVersionUID = -3456430195886129035L;
+
/**
* Constructs a NoSuchFieldException
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/NoSuchFieldException.java b/jdk/src/share/classes/java/lang/NoSuchFieldException.java
index c75113a8c09..b44fb173ebb 100644
--- a/jdk/src/share/classes/java/lang/NoSuchFieldException.java
+++ b/jdk/src/share/classes/java/lang/NoSuchFieldException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2008 Sun Microsystems, Inc. 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,6 +32,8 @@ package java.lang;
* @since JDK1.1
*/
public class NoSuchFieldException extends Exception {
+ private static final long serialVersionUID = -6143714805279938260L;
+
/**
* Constructor.
*/
diff --git a/jdk/src/share/classes/java/lang/NoSuchMethodError.java b/jdk/src/share/classes/java/lang/NoSuchMethodError.java
index 5f3a798144b..74de82f3c16 100644
--- a/jdk/src/share/classes/java/lang/NoSuchMethodError.java
+++ b/jdk/src/share/classes/java/lang/NoSuchMethodError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1998 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -39,6 +39,8 @@ package java.lang;
*/
public
class NoSuchMethodError extends IncompatibleClassChangeError {
+ private static final long serialVersionUID = -3765521442372831335L;
+
/**
* Constructs a NoSuchMethodError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/NoSuchMethodException.java b/jdk/src/share/classes/java/lang/NoSuchMethodException.java
index 0fc7113ad1c..720fbfcbbc6 100644
--- a/jdk/src/share/classes/java/lang/NoSuchMethodException.java
+++ b/jdk/src/share/classes/java/lang/NoSuchMethodException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -33,6 +33,8 @@ package java.lang;
*/
public
class NoSuchMethodException extends Exception {
+ private static final long serialVersionUID = 5034388446362600923L;
+
/**
* Constructs a NoSuchMethodException
without a detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/NullPointerException.java b/jdk/src/share/classes/java/lang/NullPointerException.java
index 68fef23ac28..15e899cf0c9 100644
--- a/jdk/src/share/classes/java/lang/NullPointerException.java
+++ b/jdk/src/share/classes/java/lang/NullPointerException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -46,6 +46,8 @@ package java.lang;
*/
public
class NullPointerException extends RuntimeException {
+ private static final long serialVersionUID = 5162710183389028792L;
+
/**
* Constructs a NullPointerException
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/OutOfMemoryError.java b/jdk/src/share/classes/java/lang/OutOfMemoryError.java
index 3ab19d24048..842b5c60d3f 100644
--- a/jdk/src/share/classes/java/lang/OutOfMemoryError.java
+++ b/jdk/src/share/classes/java/lang/OutOfMemoryError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -35,6 +35,8 @@ package java.lang;
*/
public
class OutOfMemoryError extends VirtualMachineError {
+ private static final long serialVersionUID = 8228564086184010517L;
+
/**
* Constructs an OutOfMemoryError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/StackOverflowError.java b/jdk/src/share/classes/java/lang/StackOverflowError.java
index 00cd783b440..992a395f2d7 100644
--- a/jdk/src/share/classes/java/lang/StackOverflowError.java
+++ b/jdk/src/share/classes/java/lang/StackOverflowError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -34,6 +34,8 @@ package java.lang;
*/
public
class StackOverflowError extends VirtualMachineError {
+ private static final long serialVersionUID = 8609175038441759607L;
+
/**
* Constructs a StackOverflowError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/StringIndexOutOfBoundsException.java b/jdk/src/share/classes/java/lang/StringIndexOutOfBoundsException.java
index 35bf7b4c64b..a2386205686 100644
--- a/jdk/src/share/classes/java/lang/StringIndexOutOfBoundsException.java
+++ b/jdk/src/share/classes/java/lang/StringIndexOutOfBoundsException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-2000 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -37,6 +37,8 @@ package java.lang;
*/
public
class StringIndexOutOfBoundsException extends IndexOutOfBoundsException {
+ private static final long serialVersionUID = -6762910422159637258L;
+
/**
* Constructs a StringIndexOutOfBoundsException
with no
* detail message.
diff --git a/jdk/src/share/classes/java/lang/ThreadDeath.java b/jdk/src/share/classes/java/lang/ThreadDeath.java
index 1cab266993f..6a346023674 100644
--- a/jdk/src/share/classes/java/lang/ThreadDeath.java
+++ b/jdk/src/share/classes/java/lang/ThreadDeath.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -46,4 +46,6 @@ package java.lang;
* @since JDK1.0
*/
-public class ThreadDeath extends Error {}
+public class ThreadDeath extends Error {
+ private static final long serialVersionUID = -4417128565033088268L;
+}
diff --git a/jdk/src/share/classes/java/lang/TypeNotPresentException.java b/jdk/src/share/classes/java/lang/TypeNotPresentException.java
index 44570349082..d7fa0d6bdeb 100644
--- a/jdk/src/share/classes/java/lang/TypeNotPresentException.java
+++ b/jdk/src/share/classes/java/lang/TypeNotPresentException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. 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
@@ -40,6 +40,8 @@ package java.lang;
* @since 1.5
*/
public class TypeNotPresentException extends RuntimeException {
+ private static final long serialVersionUID = -5101214195716534496L;
+
private String typeName;
/**
diff --git a/jdk/src/share/classes/java/lang/UnknownError.java b/jdk/src/share/classes/java/lang/UnknownError.java
index 966b3344569..437441d46e0 100644
--- a/jdk/src/share/classes/java/lang/UnknownError.java
+++ b/jdk/src/share/classes/java/lang/UnknownError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -34,6 +34,8 @@ package java.lang;
*/
public
class UnknownError extends VirtualMachineError {
+ private static final long serialVersionUID = 2524784860676771849L;
+
/**
* Constructs an UnknownError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/UnsatisfiedLinkError.java b/jdk/src/share/classes/java/lang/UnsatisfiedLinkError.java
index 70426b4eb08..8ffe6cc7345 100644
--- a/jdk/src/share/classes/java/lang/UnsatisfiedLinkError.java
+++ b/jdk/src/share/classes/java/lang/UnsatisfiedLinkError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -35,6 +35,8 @@ package java.lang;
*/
public
class UnsatisfiedLinkError extends LinkageError {
+ private static final long serialVersionUID = -4019343241616879428L;
+
/**
* Constructs an UnsatisfiedLinkError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/UnsupportedClassVersionError.java b/jdk/src/share/classes/java/lang/UnsupportedClassVersionError.java
index a36bdb79bfc..ec846508f49 100644
--- a/jdk/src/share/classes/java/lang/UnsupportedClassVersionError.java
+++ b/jdk/src/share/classes/java/lang/UnsupportedClassVersionError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2008 Sun Microsystems, Inc. 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
@@ -34,6 +34,8 @@ package java.lang;
*/
public
class UnsupportedClassVersionError extends ClassFormatError {
+ private static final long serialVersionUID = -7123279212883497373L;
+
/**
* Constructs a UnsupportedClassVersionError
* with no detail message.
diff --git a/jdk/src/share/classes/java/lang/VerifyError.java b/jdk/src/share/classes/java/lang/VerifyError.java
index 46f2b10dcc4..a24d34bfcbc 100644
--- a/jdk/src/share/classes/java/lang/VerifyError.java
+++ b/jdk/src/share/classes/java/lang/VerifyError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -35,6 +35,8 @@ package java.lang;
*/
public
class VerifyError extends LinkageError {
+ private static final long serialVersionUID = 7001962396098498785L;
+
/**
* Constructs an VerifyError
with no detail message.
*/
diff --git a/jdk/src/share/classes/java/lang/annotation/AnnotationFormatError.java b/jdk/src/share/classes/java/lang/annotation/AnnotationFormatError.java
index 1ec3d457a72..0bc2fd15169 100644
--- a/jdk/src/share/classes/java/lang/annotation/AnnotationFormatError.java
+++ b/jdk/src/share/classes/java/lang/annotation/AnnotationFormatError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2004-2008 Sun Microsystems, Inc. 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
@@ -33,6 +33,8 @@ package java.lang.annotation;
* @since 1.5
*/
public class AnnotationFormatError extends Error {
+ private static final long serialVersionUID = -4256701562333669892L;
+
/**
* Constructs a new AnnotationFormatError with the specified
* detail message.
diff --git a/jdk/src/share/classes/java/lang/annotation/AnnotationTypeMismatchException.java b/jdk/src/share/classes/java/lang/annotation/AnnotationTypeMismatchException.java
index 3af297dca93..c4cb7534c31 100644
--- a/jdk/src/share/classes/java/lang/annotation/AnnotationTypeMismatchException.java
+++ b/jdk/src/share/classes/java/lang/annotation/AnnotationTypeMismatchException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. 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
@@ -35,6 +35,8 @@ import java.lang.reflect.Method;
* @since 1.5
*/
public class AnnotationTypeMismatchException extends RuntimeException {
+ private static final long serialVersionUID = 8125925355765570191L;
+
/**
* The Method object for the annotation element.
*/
diff --git a/jdk/src/share/classes/java/lang/annotation/IncompleteAnnotationException.java b/jdk/src/share/classes/java/lang/annotation/IncompleteAnnotationException.java
index abea0ac331b..04070a1bbd4 100644
--- a/jdk/src/share/classes/java/lang/annotation/IncompleteAnnotationException.java
+++ b/jdk/src/share/classes/java/lang/annotation/IncompleteAnnotationException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. 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
@@ -35,6 +35,8 @@ package java.lang.annotation;
* @since 1.5
*/
public class IncompleteAnnotationException extends RuntimeException {
+ private static final long serialVersionUID = 8445097402741811912L;
+
private Class annotationType;
private String elementName;
diff --git a/jdk/src/share/classes/java/lang/instrument/IllegalClassFormatException.java b/jdk/src/share/classes/java/lang/instrument/IllegalClassFormatException.java
index 94c4933e4c0..5594165fb3e 100644
--- a/jdk/src/share/classes/java/lang/instrument/IllegalClassFormatException.java
+++ b/jdk/src/share/classes/java/lang/instrument/IllegalClassFormatException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. 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
@@ -40,6 +40,8 @@ package java.lang.instrument;
* @since 1.5
*/
public class IllegalClassFormatException extends Exception {
+ private static final long serialVersionUID = -3841736710924794009L;
+
/**
* Constructs an IllegalClassFormatException
with no
* detail message.
diff --git a/jdk/src/share/classes/java/lang/instrument/UnmodifiableClassException.java b/jdk/src/share/classes/java/lang/instrument/UnmodifiableClassException.java
index 418ad7b3af8..d754fb2bbf0 100644
--- a/jdk/src/share/classes/java/lang/instrument/UnmodifiableClassException.java
+++ b/jdk/src/share/classes/java/lang/instrument/UnmodifiableClassException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2004-2008 Sun Microsystems, Inc. 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
@@ -34,6 +34,8 @@ package java.lang.instrument;
* @since 1.5
*/
public class UnmodifiableClassException extends Exception {
+ private static final long serialVersionUID = 1716652643585309178L;
+
/**
* Constructs an UnmodifiableClassException
with no
* detail message.
diff --git a/jdk/src/share/classes/java/lang/management/ManagementPermission.java b/jdk/src/share/classes/java/lang/management/ManagementPermission.java
index 5330e75399b..7eeadd5c5ec 100644
--- a/jdk/src/share/classes/java/lang/management/ManagementPermission.java
+++ b/jdk/src/share/classes/java/lang/management/ManagementPermission.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. 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
@@ -83,6 +83,7 @@ at the permission allows, and associated risks">
*/
public final class ManagementPermission extends java.security.BasicPermission {
+ private static final long serialVersionUID = 1897496590799378737L;
/**
* Constructs a ManagementPermission with the specified name.
diff --git a/jdk/src/share/classes/java/lang/reflect/GenericSignatureFormatError.java b/jdk/src/share/classes/java/lang/reflect/GenericSignatureFormatError.java
index 6ecdd3b24fd..717bc8bdeb0 100644
--- a/jdk/src/share/classes/java/lang/reflect/GenericSignatureFormatError.java
+++ b/jdk/src/share/classes/java/lang/reflect/GenericSignatureFormatError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. 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
@@ -33,4 +33,6 @@ package java.lang.reflect;
*
* @since 1.5
*/
-public class GenericSignatureFormatError extends ClassFormatError{}
+public class GenericSignatureFormatError extends ClassFormatError {
+ private static final long serialVersionUID = 6709919147137911034L;
+}
diff --git a/jdk/src/share/classes/java/lang/reflect/MalformedParameterizedTypeException.java b/jdk/src/share/classes/java/lang/reflect/MalformedParameterizedTypeException.java
index 6089687ec24..0ed0b399fba 100644
--- a/jdk/src/share/classes/java/lang/reflect/MalformedParameterizedTypeException.java
+++ b/jdk/src/share/classes/java/lang/reflect/MalformedParameterizedTypeException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. 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
@@ -34,4 +34,6 @@ package java.lang.reflect;
*
* @since 1.5
*/
-public class MalformedParameterizedTypeException extends RuntimeException{}
+public class MalformedParameterizedTypeException extends RuntimeException {
+ private static final long serialVersionUID = -5696557788586220964L;
+}
diff --git a/jdk/src/share/classes/java/util/ConcurrentModificationException.java b/jdk/src/share/classes/java/util/ConcurrentModificationException.java
index 19a30286538..fbe9282dc59 100644
--- a/jdk/src/share/classes/java/util/ConcurrentModificationException.java
+++ b/jdk/src/share/classes/java/util/ConcurrentModificationException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc. 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
@@ -67,6 +67,8 @@ package java.util;
* @since 1.2
*/
public class ConcurrentModificationException extends RuntimeException {
+ private static final long serialVersionUID = -3666751008965953603L;
+
/**
* Constructs a ConcurrentModificationException with no
* detail message.
diff --git a/jdk/src/share/classes/java/util/EmptyStackException.java b/jdk/src/share/classes/java/util/EmptyStackException.java
index 0bdaa2ee2e5..09ba39b0ec5 100644
--- a/jdk/src/share/classes/java/util/EmptyStackException.java
+++ b/jdk/src/share/classes/java/util/EmptyStackException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1998 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -35,6 +35,8 @@ package java.util;
*/
public
class EmptyStackException extends RuntimeException {
+ private static final long serialVersionUID = 5084686378493302095L;
+
/**
* Constructs a new EmptyStackException
with null
* as its error message string.
diff --git a/jdk/src/share/classes/java/util/InputMismatchException.java b/jdk/src/share/classes/java/util/InputMismatchException.java
index 87b0c60bfe1..ff1729c2133 100644
--- a/jdk/src/share/classes/java/util/InputMismatchException.java
+++ b/jdk/src/share/classes/java/util/InputMismatchException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. 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
@@ -36,6 +36,8 @@ package java.util;
*/
public
class InputMismatchException extends NoSuchElementException {
+ private static final long serialVersionUID = 8811230760997066428L;
+
/**
* Constructs an InputMismatchException
with null
* as its error message string.
diff --git a/jdk/src/share/classes/java/util/NoSuchElementException.java b/jdk/src/share/classes/java/util/NoSuchElementException.java
index 9750122cb4a..e4cbe8eef80 100644
--- a/jdk/src/share/classes/java/util/NoSuchElementException.java
+++ b/jdk/src/share/classes/java/util/NoSuchElementException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-1998 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2008 Sun Microsystems, Inc. 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
@@ -37,6 +37,8 @@ package java.util;
*/
public
class NoSuchElementException extends RuntimeException {
+ private static final long serialVersionUID = 6769829250639411880L;
+
/**
* Constructs a NoSuchElementException
with null
* as its error message string.
diff --git a/jdk/src/share/classes/java/util/TooManyListenersException.java b/jdk/src/share/classes/java/util/TooManyListenersException.java
index f7778a5edd1..c9feb957180 100644
--- a/jdk/src/share/classes/java/util/TooManyListenersException.java
+++ b/jdk/src/share/classes/java/util/TooManyListenersException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2008 Sun Microsystems, Inc. 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
@@ -48,6 +48,7 @@ package java.util;
*/
public class TooManyListenersException extends Exception {
+ private static final long serialVersionUID = 5074640544770687831L;
/**
* Constructs a TooManyListenersException with no detail message.
diff --git a/jdk/src/share/classes/java/util/jar/JarException.java b/jdk/src/share/classes/java/util/jar/JarException.java
index a8c66b692f1..a28bbcc5b74 100644
--- a/jdk/src/share/classes/java/util/jar/JarException.java
+++ b/jdk/src/share/classes/java/util/jar/JarException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc. 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
@@ -34,6 +34,8 @@ package java.util.jar;
*/
public
class JarException extends java.util.zip.ZipException {
+ private static final long serialVersionUID = 7159778400963954473L;
+
/**
* Constructs a JarException with no detail message.
*/
diff --git a/jdk/src/share/classes/java/util/regex/PatternSyntaxException.java b/jdk/src/share/classes/java/util/regex/PatternSyntaxException.java
index 093b6a39816..404756ed6d5 100644
--- a/jdk/src/share/classes/java/util/regex/PatternSyntaxException.java
+++ b/jdk/src/share/classes/java/util/regex/PatternSyntaxException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2008 Sun Microsystems, Inc. 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
@@ -40,6 +40,7 @@ import sun.security.action.GetPropertyAction;
public class PatternSyntaxException
extends IllegalArgumentException
{
+ private static final long serialVersionUID = -3864639126226059218L;
private final String desc;
private final String pattern;
diff --git a/jdk/src/share/classes/java/util/zip/DataFormatException.java b/jdk/src/share/classes/java/util/zip/DataFormatException.java
index db884f21e00..08730b87581 100644
--- a/jdk/src/share/classes/java/util/zip/DataFormatException.java
+++ b/jdk/src/share/classes/java/util/zip/DataFormatException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2008 Sun Microsystems, Inc. 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,6 +32,8 @@ package java.util.zip;
*/
public
class DataFormatException extends Exception {
+ private static final long serialVersionUID = 2219632870893641452L;
+
/**
* Constructs a DataFormatException with no detail message.
*/
diff --git a/jdk/src/share/classes/java/util/zip/ZipException.java b/jdk/src/share/classes/java/util/zip/ZipException.java
index 467a51c9baf..a5dbc12a153 100644
--- a/jdk/src/share/classes/java/util/zip/ZipException.java
+++ b/jdk/src/share/classes/java/util/zip/ZipException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2001 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc. 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
@@ -37,6 +37,8 @@ import java.io.IOException;
public
class ZipException extends IOException {
+ private static final long serialVersionUID = 8000196834066748623L;
+
/**
* Constructs an ZipException
with null
* as its error detail message.
diff --git a/jdk/src/share/classes/javax/management/openmbean/MXBeanMappingFactory.java b/jdk/src/share/classes/javax/management/openmbean/MXBeanMappingFactory.java
index d5808c3a1eb..f1dc6bcc080 100644
--- a/jdk/src/share/classes/javax/management/openmbean/MXBeanMappingFactory.java
+++ b/jdk/src/share/classes/javax/management/openmbean/MXBeanMappingFactory.java
@@ -48,7 +48,7 @@ import java.lang.reflect.Type;
* effect by defining {@code MyLinkedListMappingFactory} as follows:
- * public class MyLinkedListMappingFactory implements MXBeanMappingFactory { + * public class MyLinkedListMappingFactory extends MXBeanMappingFactory { * public MyLinkedListMappingFactory() {} * * public MXBeanMapping mappingForType(Type t, MXBeanMappingFactory f) diff --git a/jdk/src/share/classes/sun/launcher/LauncherHelp.java b/jdk/src/share/classes/sun/launcher/LauncherHelp.java deleted file mode 100644 index 61ced48550f..00000000000 --- a/jdk/src/share/classes/sun/launcher/LauncherHelp.java +++ /dev/null @@ -1,138 +0,0 @@ - -/* - * Copyright 2007 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. - * - * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package sun.launcher; - -/* - * - *This is NOT part of any API supported by Sun Microsystems. - * If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice. - * - */ - -/** - * A utility package for the java(1), javaw(1) launchers. - */ -import java.io.File; -import java.io.PrintStream; -import java.util.ResourceBundle; -import java.text.MessageFormat; - -public class LauncherHelp { - - private static final String defaultBundleName = "sun.launcher.resources.launcher"; - private static ResourceBundle javarb = ResourceBundle.getBundle(defaultBundleName); - - private static StringBuilder outBuf = new StringBuilder(); - - /** Creates a new instance of LauncherHelp, keep it a singleton */ - private LauncherHelp(){} - - - /** - * A private helper method to get a localized message and also - * apply any arguments that we might pass. - */ - private static String getLocalizedMessage(String key, Object... args) { - String msg = javarb.getString(key); - return (args != null) ? MessageFormat.format(msg, args) : msg; - } - - /** - * The java -help message is split into 3 parts, an invariant, followed - * by a set of platform dependent variant messages, finally an invariant - * set of lines. - * This method initializes the help message for the first time, and also - * assembles the invariant header part of the message. - */ - static void initHelpMessage(String progname) { - outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.header", (progname == null) ? "java" : progname )); - outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.datamodel", 32)); - outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.datamodel", 64)); - } - - /** - * Appends the vm selection messages to the header, already created. - * initHelpSystem must already be called. - */ - static void appendVmSelectMessage(String vm1, String vm2) { - outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.vmselect", vm1, vm2)); - } - - /** - * Appends the vm synoym message to the header, already created. - * initHelpSystem must be called before using this method. - */ - static void appendVmSynonymMessage(String vm1, String vm2) { - outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.hotspot", vm1, vm2)); - } - - /** - * Appends the vm Ergo message to the header, already created. - * initHelpSystem must be called before using this method. - */ - static void appendVmErgoMessage(boolean isServerClass, String vm) { - outBuf = outBuf.append(getLocalizedMessage("java.launcher.ergo.message1", vm)); - outBuf = (isServerClass) - ? outBuf.append(",\n" + getLocalizedMessage("java.launcher.ergo.message2") + "\n\n") - : outBuf.append(".\n\n"); - } - - /** - * Appends the last invariant part to the previously created messages, - * and finishes up the printing to the desired output stream. - * initHelpSystem must be called before using this method. - */ - static void printHelpMessage(boolean printToStderr) { - PrintStream ostream = (printToStderr) ? System.err : System.out; - outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.footer", File.pathSeparator)); - ostream.println(outBuf.toString()); - } - - /** - * Prints the Xusage text to the desired output stream. - */ - static void printXUsageMessage(boolean printToStderr) { - PrintStream ostream = (printToStderr) ? System.err : System.out; - ostream.println(getLocalizedMessage("java.launcher.X.usage", File.pathSeparator)); - } - - /* Test code */ - public static void main(String[] args) { - initHelpMessage("java"); - appendVmSelectMessage("-client", "client"); - appendVmSelectMessage("-server", "server"); - appendVmSynonymMessage("-hotspot", "client"); - appendVmErgoMessage(true, "server"); - printHelpMessage(true); - - System.err.println("------------------------------------"); - - printXUsageMessage(true); - } -} diff --git a/jdk/src/share/classes/sun/launcher/LauncherHelper.java b/jdk/src/share/classes/sun/launcher/LauncherHelper.java new file mode 100644 index 00000000000..96ad484468f --- /dev/null +++ b/jdk/src/share/classes/sun/launcher/LauncherHelper.java @@ -0,0 +1,238 @@ + +/* + * Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package sun.launcher; + +/* + * + *
This is NOT part of any API supported by Sun Microsystems. + * If you write code that depends on this, you do so at your own + * risk. This code and its internal interfaces are subject to change + * or deletion without notice. + * + */ + +/** + * A utility package for the java(1), javaw(1) launchers. + * The following are helper methods that the native launcher uses + * to perform checks etc. using JNI, see src/share/bin/java.c + */ +import java.io.File; +import java.io.IOException; +import java.io.PrintStream; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ResourceBundle; +import java.text.MessageFormat; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.Manifest; + +public enum LauncherHelper { + INSTANCE; + private static final String defaultBundleName = + "sun.launcher.resources.launcher"; + private static ResourceBundle javarb = + ResourceBundle.getBundle(defaultBundleName); + private static final String MAIN_CLASS = "Main-Class"; + + private static StringBuilder outBuf = new StringBuilder(); + + /** + * A private helper method to get a localized message and also + * apply any arguments that we might pass. + */ + private static String getLocalizedMessage(String key, Object... args) { + String msg = javarb.getString(key); + return (args != null) ? MessageFormat.format(msg, args) : msg; + } + + /** + * The java -help message is split into 3 parts, an invariant, followed + * by a set of platform dependent variant messages, finally an invariant + * set of lines. + * This method initializes the help message for the first time, and also + * assembles the invariant header part of the message. + */ + static void initHelpMessage(String progname) { + outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.header", + (progname == null) ? "java" : progname )); + outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.datamodel", + 32)); + outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.datamodel", + 64)); + } + + /** + * Appends the vm selection messages to the header, already created. + * initHelpSystem must already be called. + */ + static void appendVmSelectMessage(String vm1, String vm2) { + outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.vmselect", + vm1, vm2)); + } + + /** + * Appends the vm synoym message to the header, already created. + * initHelpSystem must be called before using this method. + */ + static void appendVmSynonymMessage(String vm1, String vm2) { + outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.hotspot", + vm1, vm2)); + } + + /** + * Appends the vm Ergo message to the header, already created. + * initHelpSystem must be called before using this method. + */ + static void appendVmErgoMessage(boolean isServerClass, String vm) { + outBuf = outBuf.append(getLocalizedMessage("java.launcher.ergo.message1", + vm)); + outBuf = (isServerClass) + ? outBuf.append(",\n" + + getLocalizedMessage("java.launcher.ergo.message2") + "\n\n") + : outBuf.append(".\n\n"); + } + + /** + * Appends the last invariant part to the previously created messages, + * and finishes up the printing to the desired output stream. + * initHelpSystem must be called before using this method. + */ + static void printHelpMessage(boolean printToStderr) { + PrintStream ostream = (printToStderr) ? System.err : System.out; + outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.footer", + File.pathSeparator)); + ostream.println(outBuf.toString()); + } + + /** + * Prints the Xusage text to the desired output stream. + */ + static void printXUsageMessage(boolean printToStderr) { + PrintStream ostream = (printToStderr) ? System.err : System.out; + ostream.println(getLocalizedMessage("java.launcher.X.usage", + File.pathSeparator)); + } + + static String getMainClassFromJar(String jarname) throws IOException { + JarFile jarFile = null; + try { + jarFile = new JarFile(jarname); + Manifest manifest = jarFile.getManifest(); + if (manifest == null) { + throw new IOException("manifest not found in " + jarname); + } + Attributes mainAttrs = manifest.getMainAttributes(); + if (mainAttrs == null) { + throw new IOException("no main mainifest attributes, in " + + jarname); + } + return mainAttrs.getValue(MAIN_CLASS); + } finally { + if (jarFile != null) { + jarFile.close(); + } + } + } + + /** + * This method does the following: + * 1. gets the classname from a Jar's manifest, if necessary + * 2. loads the class using the System ClassLoader + * 3. ensures the availability and accessibility of the main method, + * using signatureDiagnostic method. + * a. does the class exist + * b. is there a main + * c. is the main public + * d. is the main static + * c. does the main take a String array for args + * 4. and off we go...... + * + * @param printToStderr + * @param isJar + * @param name + * @return + * @throws java.lang.Exception + */ + public static Object checkAndLoadMain(boolean printToStderr, + boolean isJar, String name) throws Exception { + // get the class name + String classname = (isJar) ? getMainClassFromJar(name) : name; + classname = classname.replace('/', '.'); + ClassLoader loader = ClassLoader.getSystemClassLoader(); + Class> clazz = null; + PrintStream ostream = (printToStderr) ? System.err : System.out; + try { + clazz = loader.loadClass(classname); + } catch (ClassNotFoundException cnfe) { + ostream.println(getLocalizedMessage("java.launcher.cls.error1", classname)); + throw new RuntimeException("Could not find the main class " + classname); + } + signatureDiagnostic(ostream, clazz); + return clazz; + } + + static void signatureDiagnostic(PrintStream ostream, Class> clazz) { + String classname = clazz.getName(); + Method method = null; + try { + method = clazz.getMethod("main", String[].class); + } catch (Exception e) { + ostream.println(getLocalizedMessage("java.launcher.cls.error4", + classname)); + throw new RuntimeException("Main method not found in " + classname); + } + /* + * Usually the getMethod (above) will choose the correct method, based + * on its modifiers and parameter types, the only check required is the + * getReturnType check as getMethod does not check for this, all the + * other modifier tests are redundant, and are simply here for safety. + */ + int mod = method.getModifiers(); + if (!Modifier.isStatic(mod)) { + ostream.println(getLocalizedMessage("java.launcher.cls.error2", + "static", classname)); + throw new RuntimeException("Main method is not static in class " + + classname); + } + if (!Modifier.isPublic(mod)) { + ostream.println(getLocalizedMessage("java.launcher.cls.error2", + "public", classname)); + throw new RuntimeException("Main method is not public in class " + + classname); + } + Class> rType = method.getReturnType(); + if (!rType.isPrimitive() || !rType.getName().equals("void")) { + ostream.println(getLocalizedMessage("java.launcher.cls.error3", + classname)); + throw new RuntimeException("Main method must return a value" + + " of type void in class " + + classname); + } + return; + } +} diff --git a/jdk/src/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/share/classes/sun/launcher/resources/launcher.properties index 14ffdecfc92..5114bee180b 100644 --- a/jdk/src/share/classes/sun/launcher/resources/launcher.properties +++ b/jdk/src/share/classes/sun/launcher/resources/launcher.properties @@ -1,5 +1,5 @@ # -# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2007-2008 Sun Microsystems, Inc. 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 @@ -99,3 +99,18 @@ java.launcher.X.usage=\ \ -Xshare:auto use shared class data if possible (default)\n\ \ -Xshare:on require using shared class data, otherwise fail.\n\n\ The -X options are non-standard and subject to change without notice.\n + +java.launcher.cls.error1=\ + Error: Could not find main class {0} +java.launcher.cls.error2=\ + Error: Main method is not {0} in class {1}, please define the main method as:\n\ +\ public static void main(String[] args) +java.launcher.cls.error3=\ + Error: Main method must return a value of type void in class {0}, please \n\ + define the main method as:\n\ +\ public static void main(String[] args) +java.launcher.cls.error4=\ + Error: Main method not found in class {0}, please define the main method as:\n\ +\ public static void main(String[] args) + + diff --git a/jdk/src/solaris/bin/java_md.c b/jdk/src/solaris/bin/java_md.c index 6ecd9681c8f..c10c0b4367c 100644 --- a/jdk/src/solaris/bin/java_md.c +++ b/jdk/src/solaris/bin/java_md.c @@ -1312,3 +1312,24 @@ InitLauncher(jboolean javaw) { JLI_SetTraceLauncher(); } + +/* + * The implementation for finding classes from the bootstrap + * class loader, refer to java.h + */ +static FindClassFromBootLoader_t *findBootClass = NULL; + +jclass +FindBootStrapClass(JNIEnv *env, const char* classname) +{ + if (findBootClass == NULL) { + findBootClass = (FindClassFromBootLoader_t *)dlsym(RTLD_DEFAULT, + "JVM_FindClassFromBootLoader"); + if (findBootClass == NULL) { + JLI_ReportErrorMessage(DLL_ERROR4, + "JVM_FindClassFromBootLoader"); + return NULL; + } + } + return findBootClass(env, classname, JNI_FALSE); +} diff --git a/jdk/src/windows/bin/java_md.c b/jdk/src/windows/bin/java_md.c index 2db1f25e2c4..557b5667c9c 100644 --- a/jdk/src/windows/bin/java_md.c +++ b/jdk/src/windows/bin/java_md.c @@ -993,9 +993,34 @@ ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void return rslt; } -/* Linux only, empty on windows. */ +/* Unix only, empty on windows. */ void SetJavaLauncherPlatformProps() {} +/* + * The implementation for finding classes from the bootstrap + * class loader, refer to java.h + */ +static FindClassFromBootLoader_t *findBootClass = NULL; + +jclass FindBootStrapClass(JNIEnv *env, const char *classname) +{ + HMODULE hJvm; + + if (findBootClass == NULL) { + hJvm = GetModuleHandle(JVM_DLL); + if (hJvm == NULL) return NULL; + /* need to use the demangled entry point */ + findBootClass = (FindClassFromBootLoader_t *)GetProcAddress(hJvm, + "JVM_FindClassFromBootLoader"); + if (findBootClass == NULL) { + JLI_ReportErrorMessage(DLL_ERROR4, + "JVM_FindClassBootLoader"); + return NULL; + } + } + return findBootClass(env, classname, JNI_FALSE); +} + void InitLauncher(boolean javaw) { diff --git a/jdk/test/javax/management/mxbean/CustomTypeTest.java b/jdk/test/javax/management/mxbean/CustomTypeTest.java index ccf192ab531..6da91330c77 100644 --- a/jdk/test/javax/management/mxbean/CustomTypeTest.java +++ b/jdk/test/javax/management/mxbean/CustomTypeTest.java @@ -22,7 +22,7 @@ */ /* @test %M% %I% - * @bug 6562936 + * @bug 6562936 6750935 * @run compile customtypes/package-info.java * @run main CustomTypeTest */ @@ -342,6 +342,38 @@ public class CustomTypeTest { } } + public static class BadConstructorMXBeanMappingFactory1 extends + MXBeanMappingFactory { + private BadConstructorMXBeanMappingFactory1() {} + + @Override + public MXBeanMapping mappingForType(Type arg0, MXBeanMappingFactory arg1) + throws OpenDataException { + throw new UnsupportedOperationException("Should not be called"); + } + } + + public static class BadConstructorMXBeanMappingFactory2 extends + MXBeanMappingFactory { + public BadConstructorMXBeanMappingFactory2(boolean oops) {} + + @Override + public MXBeanMapping mappingForType(Type arg0, MXBeanMappingFactory arg1) + throws OpenDataException { + throw new UnsupportedOperationException("Should not be called"); + } + } + + @MXBeanMappingFactoryClass(BadConstructorMXBeanMappingFactory1.class) + public static interface BadConstructor1MXBean {} + + public static class BadConstructor1 implements BadConstructor1MXBean {} + + @MXBeanMappingFactoryClass(BadConstructorMXBeanMappingFactory2.class) + public static interface BadConstructor2MXBean {} + + public static class BadConstructor2 implements BadConstructor2MXBean {} + public static void main(String[] args) throws Exception { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); @@ -407,8 +439,10 @@ public class CustomTypeTest { try { mbs.registerMBean(new ReallyBrokenImpl(), new ObjectName("d:type=Broken")); fail("Register did not throw exception"); - } catch (IllegalArgumentException e) { + } catch (NotCompliantMBeanException e) { System.out.println("...OK: threw: " + e); + } catch (Exception e) { + fail("Register threw wrong exception: " + e); } System.out.println("Test MXBeanMappingFactory exception with StandardMBean"); @@ -433,6 +467,24 @@ public class CustomTypeTest { System.out.println("...OK: threw: " + e); } + System.out.println("Test MXBeanMappingFactoryClass constructor exception"); + for (Object mbean : new Object[] { + new BadConstructor1(), new BadConstructor2(), + }) { + String testName = mbean.getClass().getSimpleName(); + try { + ObjectName name = new ObjectName("d:type=" + testName); + mbs.registerMBean(mbean, name); + fail("Broken MXBeanMappingFactoryClass did not throw exception" + + " (" + testName + ")"); + } catch (NotCompliantMBeanException e) { + System.out.println("...OK: " + testName + " threw: " + e); + } catch (Exception e) { + fail("Broken MXBeanMappingFactoryClass " + testName + " threw " + + "wrong exception: " + e); + } + } + if (failure == null) System.out.println("TEST PASSED"); else diff --git a/jdk/test/tools/launcher/Arrrghs.java b/jdk/test/tools/launcher/Arrrghs.java index 34bfcee369b..6b14abe5090 100644 --- a/jdk/test/tools/launcher/Arrrghs.java +++ b/jdk/test/tools/launcher/Arrrghs.java @@ -21,57 +21,47 @@ * have any questions. */ +/** + * @test + * @compile -XDignore.symbol.file Arrrghs.java TestHelper.java + * @bug 5030233 6214916 6356475 6571029 6684582 + * @run main Arrrghs + * @summary Argument parsing validation. + */ + import java.io.BufferedReader; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; import java.util.Map; -import java.util.StringTokenizer; public class Arrrghs { - + private Arrrghs(){} /** + * This class provides various tests for arguments processing. * A group of tests to ensure that arguments are passed correctly to * a child java process upon a re-exec, this typically happens when * a version other than the one being executed is requested by the user. * * History: these set of tests were part of Arrrghs.sh. The MKS shell - * implementations are notoriously buggy. Implementing these tests purely + * implementations were notoriously buggy. Implementing these tests purely * in Java is not only portable but also robust. * */ - /* Do not instantiate */ - private Arrrghs() {} - - static String javaCmd; - // The version string to force a re-exec final static String VersionStr = "-version:1.1+"; // The Cookie or the pattern we match in the debug output. final static String Cookie = "ReExec Args: "; - private static boolean _debug = Boolean.getBoolean("Arrrghs.Debug"); - private static boolean isWindows = System.getProperty("os.name", "unknown").startsWith("Windows"); - private static int exitValue = 0; - - private static void doUsage(String message) { - if (message != null) System.out.println("Error: " + message); - System.out.println("Usage: Arrrghs path_to_java"); - System.exit(1); - } - /* * SIGH, On Windows all strings are quoted, we need to unwrap it */ private static String removeExtraQuotes(String in) { - if (isWindows) { + if (TestHelper.isWindows) { // Trim the string and remove the enclosed quotes if any. in = in.trim(); if (in.startsWith("\"") && in.endsWith("\"")) { @@ -81,27 +71,29 @@ public class Arrrghs { return in; } - /* * This method detects the cookie in the output stream of the process. */ - private static boolean detectCookie(InputStream istream, String expectedArguments) throws IOException { + private static boolean detectCookie(InputStream istream, + String expectedArguments) throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(istream)); boolean retval = false; String in = rd.readLine(); while (in != null) { - if (_debug) System.out.println(in); + if (TestHelper.debug) System.out.println(in); if (in.startsWith(Cookie)) { String detectedArgument = removeExtraQuotes(in.substring(Cookie.length())); if (expectedArguments.equals(detectedArgument)) { retval = true; } else { - System.out.println("Error: Expected Arguments\t:'" + expectedArguments + "'"); - System.out.println(" Detected Arguments\t:'" + detectedArgument + "'"); + System.out.println("Error: Expected Arguments\t:'" + + expectedArguments + "'"); + System.out.println(" Detected Arguments\t:'" + + detectedArgument + "'"); } // Return the value asap if not in debug mode. - if (!_debug) { + if (!TestHelper.debug) { rd.close(); istream.close(); return retval; @@ -112,7 +104,7 @@ public class Arrrghs { return retval; } - private static boolean doExec0(ProcessBuilder pb, String expectedArguments) { + private static boolean doTest0(ProcessBuilder pb, String expectedArguments) { boolean retval = false; try { pb.redirectErrorStream(true); @@ -131,72 +123,199 @@ public class Arrrghs { * This method return true if the expected and detected arguments are the same. * Quoting could cause dissimilar testArguments and expected arguments. */ - static boolean doExec(String testArguments, String expectedPattern) { - ProcessBuilder pb = new ProcessBuilder(javaCmd, VersionStr, testArguments); + static int doTest(String testArguments, String expectedPattern) { + ProcessBuilder pb = new ProcessBuilder(TestHelper.javaCmd, + VersionStr, testArguments); Map
env = pb.environment(); env.put("_JAVA_LAUNCHER_DEBUG", "true"); - return doExec0(pb, testArguments); + return doTest0(pb, testArguments) ? 0 : 1; } /** * A convenience method for identical test pattern and expected arguments */ - static boolean doExec(String testPattern) { - return doExec(testPattern, testPattern); + static int doTest(String testPattern) { + return doTest(testPattern, testPattern); + } + + static void quoteParsingTests() { + /* + * Tests for 6214916 + * These tests require that a JVM (any JVM) be installed in the system registry. + * If none is installed, skip this test. + */ + TestHelper.TestResult tr = + TestHelper.doExec(TestHelper.javaCmd, VersionStr, "-version"); + if (!tr.isOK()) { + System.err.println("Warning:Argument Passing Tests were skipped, " + + "no java found in system registry."); + return; + } + + // Basic test + TestHelper.testExitValue += doTest("-a -b -c -d"); + + // Basic test with many spaces + TestHelper.testExitValue += doTest("-a -b -c -d"); + + // Quoted whitespace does matter ? + TestHelper.testExitValue += doTest("-a \"\"-b -c\"\" -d"); + + + // Escaped quotes outside of quotes as literals + TestHelper.testExitValue += doTest("-a \\\"-b -c\\\" -d"); + + // Check for escaped quotes inside of quotes as literal + TestHelper.testExitValue += doTest("-a \"-b \\\"stuff\\\"\" -c -d"); + + // A quote preceeded by an odd number of slashes is a literal quote + TestHelper.testExitValue += doTest("-a -b\\\\\\\" -c -d"); + + // A quote preceeded by an even number of slashes is a literal quote + // see 6214916. + TestHelper.testExitValue += doTest("-a -b\\\\\\\\\" -c -d"); + + // Make sure that whitespace doesn't interfere with the removal of the + // appropriate tokens. (space-tab-space preceeds -jre-restict-search). + TestHelper.testExitValue += doTest("-a -b \t -jre-restrict-search -c -d","-a -b -c -d"); + + // Make sure that the mJRE tokens being stripped, aren't stripped if + // they happen to appear as arguments to the main class. + TestHelper.testExitValue += doTest("foo -version:1.1+"); + + System.out.println("Completed arguments quoting tests with " + + TestHelper.testExitValue + " errors"); + } + + /* + * These tests are usually run on non-existent targets to check error results + */ + static void runBasicErrorMessageTests() { + // Tests for 5030233 + TestHelper.TestResult tr = TestHelper.doExec(TestHelper.javaCmd, "-cp"); + tr.checkNegative(); + tr.isNotZeroOutput(); + System.out.println(tr); + + tr = TestHelper.doExec(TestHelper.javaCmd, "-classpath"); + tr.checkNegative(); + tr.isNotZeroOutput(); + System.out.println(tr); + + tr = TestHelper.doExec(TestHelper.javaCmd, "-jar"); + tr.checkNegative(); + tr.isNotZeroOutput(); + System.out.println(tr); + + tr = TestHelper.doExec(TestHelper.javacCmd, "-cp"); + tr.checkNegative(); + tr.isNotZeroOutput(); + System.out.println(tr); + + // Test for 6356475 "REGRESSION:"java -X" from cmdline fails" + tr = TestHelper.doExec(TestHelper.javaCmd, "-X"); + tr.checkPositive(); + tr.isNotZeroOutput(); + System.out.println(tr); + + tr = TestHelper.doExec(TestHelper.javaCmd, "-help"); + tr.checkPositive(); + tr.isNotZeroOutput(); + System.out.println(tr); + } + + /* + * A set of tests which tests various dispositions of the main method. + */ + static void runMainMethodTests() throws FileNotFoundException { + TestHelper.TestResult tr = null; + + // a missing class + TestHelper.createJar(new File("some.jar"), new File("Foo"), (String[])null); + tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar"); + tr.contains("MIA"); + System.out.println(tr); + // use classpath to check + tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "MIA"); + tr.contains("Error: Could not find main class MIA"); + System.out.println(tr); + + // incorrect method access + TestHelper.createJar(new File("some.jar"), new File("Foo"), + "private static void main(String[] args){}"); + tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar"); + tr.contains("Error: Main method not found in class Foo"); + System.out.println(tr); + // use classpath to check + tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "Foo"); + tr.contains("Error: Main method not found in class Foo"); + System.out.println(tr); + + // incorrect return type + TestHelper.createJar(new File("some.jar"), new File("Foo"), + "public static int main(String[] args){return 1;}"); + tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar"); + tr.contains("Error: Main method must return a value of type void in class Foo"); + System.out.println(tr); + // use classpath to check + tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "Foo"); + tr.contains("Error: Main method must return a value of type void in class Foo"); + System.out.println(tr); + + // incorrect parameter type + TestHelper.createJar(new File("some.jar"), new File("Foo"), + "public static void main(Object[] args){}"); + tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar"); + tr.contains("Error: Main method not found in class Foo"); + System.out.println(tr); + // use classpath to check + tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "Foo"); + tr.contains("Error: Main method not found in class Foo"); + System.out.println(tr); + + // incorrect method type - non-static + TestHelper.createJar(new File("some.jar"), new File("Foo"), + "public void main(Object[] args){}"); + tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar"); + tr.contains("Error: Main method not found in class Foo"); + System.out.println(tr); + // use classpath to check + tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "Foo"); + tr.contains("Error: Main method not found in class Foo"); + System.out.println(tr); + + // amongst a potpourri of kindred main methods, is the right one chosen ? + TestHelper.createJar(new File("some.jar"), new File("Foo"), + "void main(Object[] args){}", + "int main(Float[] args){return 1;}", + "private void main() {}", + "private static void main(int x) {}", + "public int main(int argc, String[] argv) {return 1;}", + "public static void main(String[] args) {System.out.println(\"THE_CHOSEN_ONE\");}"); + tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar"); + tr.contains("THE_CHOSEN_ONE"); + System.out.println(tr); + // use classpath to check + tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "Foo"); + tr.contains("THE_CHOSEN_ONE"); + System.out.println(tr); } /** * @param args the command line arguments + * @throws java.io.FileNotFoundException */ - public static void main(String[] args) { - if (args.length < 1 && args[0] == null) { - doUsage("Invalid number of arguments"); + public static void main(String[] args) throws FileNotFoundException { + if (TestHelper.debug) System.out.println("Starting Arrrghs tests"); + quoteParsingTests(); + runBasicErrorMessageTests(); + runMainMethodTests(); + if (TestHelper.testExitValue > 0) { + System.out.println("Total of " + TestHelper.testExitValue + " failed"); + System.exit(1); + } else { + System.out.println("All tests pass"); } - - javaCmd = args[0]; - - if (!new File(javaCmd).canExecute()) { - if (isWindows && new File(javaCmd + ".exe").canExecute()) { - javaCmd = javaCmd + ".exe"; - } else { - doUsage("The java executable must exist"); - } - } - - if (_debug) System.out.println("Starting Arrrghs tests"); - // Basic test - if (!doExec("-a -b -c -d")) exitValue++; - - // Basic test with many spaces - if (!doExec("-a -b -c -d")) exitValue++; - - // Quoted whitespace does matter ? - if (!doExec("-a \"\"-b -c\"\" -d")) exitValue++; - - // Escaped quotes outside of quotes as literals - if (!doExec("-a \\\"-b -c\\\" -d")) exitValue++; - - // Check for escaped quotes inside of quotes as literal - if (!doExec("-a \"-b \\\"stuff\\\"\" -c -d")) exitValue++; - - // A quote preceeded by an odd number of slashes is a literal quote - if (!doExec("-a -b\\\\\\\" -c -d")) exitValue++; - - // A quote preceeded by an even number of slashes is a literal quote - // see 6214916. - if (!doExec("-a -b\\\\\\\\\" -c -d")) exitValue++; - - // Make sure that whitespace doesn't interfere with the removal of the - // appropriate tokens. (space-tab-space preceeds -jre-restict-search). - if (!doExec("-a -b \t -jre-restrict-search -c -d","-a -b -c -d")) exitValue++; - - // Make sure that the mJRE tokens being stripped, aren't stripped if - // they happen to appear as arguments to the main class. - if (!doExec("foo -version:1.1+")) exitValue++; - - System.out.println("Completed Arrrghs arguments quoting/matching tests with " + exitValue + " errors"); - System.exit(exitValue); } - } diff --git a/jdk/test/tools/launcher/Arrrghs.sh b/jdk/test/tools/launcher/Arrrghs.sh deleted file mode 100644 index f5ee6b0a75b..00000000000 --- a/jdk/test/tools/launcher/Arrrghs.sh +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/sh -# @test Arrrghs.sh -# @bug 5030233 6214916 6356475 6571029 6684582 -# @build Arrrghs -# @run shell Arrrghs.sh -# @summary Argument parsing validation. -# @author Joseph E. Kowalski - -# -# Copyright 2004-2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - -# -# This test is intended to validate generic argument parsing and -# handling. -# -# Oh yes, since the response to argument parsing errors is often -# a visceral one, the name Arrrghs (pronounced "args") seems rather -# appropriate. -# - -# Verify directory context variables are set -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi - -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi - -# -# Shell routine to test for the proper handling of the cp/classpath -# option is correct (see 5030233). This option is unique in that it -# is the only option to the java command (and friends) which is -# separated from its option argument by a space, rather than an -# equals sign. -# -# Parameters: -# $1 cmd utility name to be tested (java, javac, ...) -# $2 option either the -cp or -classpath option to be -# tested. -# -TestCP() { - mess="`$TESTJAVA/bin/$1 $2 2>&1 1>/dev/null`" - if [ $? -eq 0 ]; then - echo "Invalid $1 $2 syntax accepted" - exit 1 - fi - if [ -z "$mess" ]; then - echo "No Usage message from invalid $1 $2 syntax" - exit 1 - fi -} - -# -# Test for 6356475 "REGRESSION:"java -X" from cmdline fails" -# -TestXUsage() { - $TESTJAVA/bin/java -X > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "-X option failed" - exit 1 - fi -} - -# -# Test if java -help works -# -TestHelp() { - $TESTJAVA/bin/java -help > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "-help option failed" - exit 1 - fi -} - -# -# Test to ensure that a missing main class is indicated in the error message -# -TestMissingMainClass() { - # First create a small jar file with no main - printf "public class Foo {}\n" > Foo.java - $TESTJAVA/bin/javac Foo.java - if [ $? -ne 0 ]; then - printf "Error: compilation of Foo.java failed\n" - exit 1 - fi - printf "Main-Class: Bar\n" > manifest - $TESTJAVA/bin/jar -cvfm some.jar manifest Foo.class - if [ ! -f some.jar ]; then - printf "Error: did not find some.jar\n" - exit 1 - fi - - # test a non-existence main-class using -jar - mess="`$TESTJAVA/bin/java -jar some.jar 2>&1 1>/dev/null`" - echo $mess | grep 'Bar' 2>&1 > /dev/null - if [ $? -ne 0 ]; then - printf "Error: did not find main class missing message\n" - exit 1 - fi - - # test a non-existent main-class using classpath - mess="`$TESTJAVA/bin/java -cp some.jar Bar 2>&1 1>/dev/null`" - echo $mess | grep 'Bar' 2>&1 > /dev/null - if [ $? -ne 0 ]; then - printf "Error: did not find main class missing message\n" - exit 1 - fi - - # cleanup - rm -f some.jar Foo.* manifest -} - -# -# Main processing: -# - -# -# Tests for 5030233 -# -TestCP java -cp -TestCP java -classpath -TestCP java -jar -TestCP javac -cp -TestCP javac -classpath -TestXUsage -TestHelp -TestMissingMainClass - -# -# Tests for 6214916 -# -# -# These tests require that a JVM (any JVM) be installed in the system registry. -# If none is installed, skip this test. -$TESTJAVA/bin/java -version:1.1+ -version >/dev/null 2>&1 -if [ $? -eq 0 ]; then - $TESTJAVA/bin/java -classpath $TESTCLASSES Arrrghs $TESTJAVA/bin/java - if [ $? -ne 0 ]; then - echo "Argument Passing Tests failed" - exit 1 - fi -else - printf "Warning:Argument Passing Tests were skipped, no java found in system registry." -fi -exit 0 diff --git a/jdk/test/tools/launcher/TestHelper.java b/jdk/test/tools/launcher/TestHelper.java new file mode 100644 index 00000000000..bd9009dc598 --- /dev/null +++ b/jdk/test/tools/launcher/TestHelper.java @@ -0,0 +1,228 @@ + +/* + * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import javax.tools.ToolProvider; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.tools.JavaCompiler; + +/** + * This class provides some common utilites for the launcher tests. + */ +public enum TestHelper { + INSTANCE; + static final String JAVAHOME = System.getProperty("java.home", "."); + static final boolean isSDK = JAVAHOME.endsWith("jre"); + static final String javaCmd; + static final String javacCmd; + static final JavaCompiler compiler; + + static final boolean debug = Boolean.getBoolean("Arrrghs.Debug"); + static final boolean isWindows = + System.getProperty("os.name", "unknown").startsWith("Windows"); + static int testExitValue = 0; + + static { + compiler = ToolProvider.getSystemJavaCompiler(); + File binDir = (isSDK) ? new File((new File(JAVAHOME)).getParentFile(), "bin") + : new File(JAVAHOME, "bin"); + File javaCmdFile = (isWindows) + ? new File(binDir, "java.exe") + : new File(binDir, "java"); + javaCmd = javaCmdFile.getAbsolutePath(); + if (!javaCmdFile.canExecute()) { + throw new RuntimeException("java <" + TestHelper.javaCmd + "> must exist"); + } + + File javacCmdFile = (isWindows) + ? new File(binDir, "javac.exe") + : new File(binDir, "javac"); + javacCmd = javacCmdFile.getAbsolutePath(); + if (!javacCmdFile.canExecute()) { + throw new RuntimeException("java <" + javacCmd + "> must exist"); + } + } + + /* + * A generic jar file creator which creates the java file, compiles it + * and jar's it up for use. + */ + static void createJar(File jarName, File mainClass, String... mainDefs) + throws FileNotFoundException { + createJar(null, jarName, mainClass, mainDefs); + } + + /* + * A method which takes manifest entry to specify a specific manifest + * Main-Class name. + */ + static void createJar(String mEntry, File jarName, File mainClass, String... mainDefs) + throws FileNotFoundException { + if (jarName.exists()) { + jarName.delete(); + } + PrintStream ps = new PrintStream(new FileOutputStream(mainClass + ".java")); + ps.println("public class Foo {"); + if (mainDefs != null) { + for (String x : mainDefs) { + ps.println(x); + } + } + ps.println("}"); + ps.close(); + + String compileArgs[] = { + mainClass + ".java" + }; + if (compiler.run(null, null, null, compileArgs) != 0) { + throw new RuntimeException("compilation failed " + mainClass + ".java"); + } + + if (mEntry == null && mainDefs == null) { + mEntry = "MIA"; + } else { + mEntry = mainClass.getName(); + } + String jarArgs[] = { + (debug) ? "cvfe" : "cfe", + jarName.getAbsolutePath(), + mEntry, + mainClass.getName() + ".class" + }; + sun.tools.jar.Main jarTool = + new sun.tools.jar.Main(System.out, System.err, "JarCreator"); + if (!jarTool.run(jarArgs)) { + throw new RuntimeException("jar creation failed " + jarName); + } + } + + /* + * A method which executes a java cmd and returs the results in a container + */ + static TestResult doExec(String...cmds) { + String cmdStr = ""; + for (String x : cmds) { + cmdStr = cmdStr.concat(x + " "); + } + ProcessBuilder pb = new ProcessBuilder(cmds); + Map env = pb.environment(); + BufferedReader rdr = null; + try { + List outputList = new ArrayList (); + pb.redirectErrorStream(true); + Process p = pb.start(); + rdr = new BufferedReader(new InputStreamReader(p.getInputStream())); + String in = rdr.readLine(); + while (in != null) { + outputList.add(in); + in = rdr.readLine(); + } + p.waitFor(); + p.destroy(); + return new TestHelper.TestResult(cmdStr, p.exitValue(), outputList); + } catch (Exception ex) { + ex.printStackTrace(); + throw new RuntimeException(ex.getMessage()); + } + } + + /* + * A class to encapsulate the test results and stuff, with some ease + * of use methods to check the test results. + */ + static class TestResult { + StringBuilder status; + int exitValue; + List testOutput; + + public TestResult(String str, int rv, List oList) { + status = new StringBuilder(str); + exitValue = rv; + testOutput = oList; + } + + void checkNegative() { + if (exitValue == 0) { + status = status.append(" Error: test must not return 0 exit value"); + testExitValue++; + } + } + + void checkPositive() { + if (exitValue != 0) { + status = status.append(" Error: test did not return 0 exit value"); + testExitValue++; + } + } + + boolean isOK() { + return exitValue == 0; + } + + boolean isZeroOutput() { + if (!testOutput.isEmpty()) { + status = status.append(" Error: No message from cmd please"); + testExitValue++; + return false; + } + return true; + } + + boolean isNotZeroOutput() { + if (testOutput.isEmpty()) { + status = status.append(" Error: Missing message"); + testExitValue++; + return false; + } + return true; + } + + public String toString() { + if (debug) { + for (String x : testOutput) { + status = status.append(x + "\n"); + } + } + return status.toString(); + } + + boolean contains(String str) { + for (String x : testOutput) { + if (x.contains(str)) { + return true; + } + } + status = status.append(" Error: string <" + str + "> not found "); + testExitValue++; + return false; + } + } +}