--- a/jdk/src/share/classes/java/lang/instrument/Instrumentation.java Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/src/share/classes/java/lang/instrument/Instrumentation.java Thu Mar 27 14:15:59 2008 -0700
@@ -636,7 +636,11 @@
* @param transformer
* The ClassFileTransformer which wraps using this prefix.
* @param prefix
- * The prefix which has been applied to wrapped native methods.
+ * The prefix to apply to wrapped native methods when
+ * retrying a failed native method resolution. If prefix
+ * is either <code>null</code> or the empty string, then
+ * failed native method resolutions are not retried for
+ * this transformer.
* @throws java.lang.NullPointerException if passed a <code>null</code> transformer.
* @throws java.lang.UnsupportedOperationException if the current configuration of
* the JVM does not allow setting a native method prefix
--- a/jdk/src/share/classes/sun/instrument/InstrumentationImpl.java Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/src/share/classes/sun/instrument/InstrumentationImpl.java Thu Mar 27 14:15:59 2008 -0700
@@ -303,39 +303,78 @@
NoSuchMethodException firstExc = null;
boolean twoArgAgent = false;
- // The agent class has a premain or agentmain method that has 1 or 2
- // arguments. We first check for a signature of (String, Instrumentation),
- // and if not found we check for (String). If neither is found then we
- // throw the NoSuchMethodException from the first attempt so that the
- // exception text indicates the lookup failed for the 2-arg method
- // (same as JDK5.0).
+ // The agent class must have a premain or agentmain method that
+ // has 1 or 2 arguments. We check in the following order:
+ //
+ // 1) declared with a signature of (String, Instrumentation)
+ // 2) declared with a signature of (String)
+ // 3) inherited with a signature of (String, Instrumentation)
+ // 4) inherited with a signature of (String)
+ //
+ // So the declared version of either 1-arg or 2-arg always takes
+ // primary precedence over an inherited version. After that, the
+ // 2-arg version takes precedence over the 1-arg version.
+ //
+ // If no method is found then we throw the NoSuchMethodException
+ // from the first attempt so that the exception text indicates
+ // the lookup failed for the 2-arg method (same as JDK5.0).
try {
- m = javaAgentClass.getMethod( methodname,
- new Class[] {
- String.class,
- java.lang.instrument.Instrumentation.class
- }
- );
+ m = javaAgentClass.getDeclaredMethod( methodname,
+ new Class[] {
+ String.class,
+ java.lang.instrument.Instrumentation.class
+ }
+ );
twoArgAgent = true;
} catch (NoSuchMethodException x) {
// remember the NoSuchMethodException
firstExc = x;
}
- // check for the 1-arg method
if (m == null) {
+ // now try the declared 1-arg method
+ try {
+ m = javaAgentClass.getDeclaredMethod(methodname,
+ new Class[] { String.class });
+ } catch (NoSuchMethodException x) {
+ // ignore this exception because we'll try
+ // two arg inheritance next
+ }
+ }
+
+ if (m == null) {
+ // now try the inherited 2-arg method
try {
- m = javaAgentClass.getMethod(methodname, new Class[] { String.class });
+ m = javaAgentClass.getMethod( methodname,
+ new Class[] {
+ String.class,
+ java.lang.instrument.Instrumentation.class
+ }
+ );
+ twoArgAgent = true;
} catch (NoSuchMethodException x) {
- // Neither method exists so we throw the first NoSuchMethodException
- // as per 5.0
+ // ignore this exception because we'll try
+ // one arg inheritance next
+ }
+ }
+
+ if (m == null) {
+ // finally try the inherited 1-arg method
+ try {
+ m = javaAgentClass.getMethod(methodname,
+ new Class[] { String.class });
+ } catch (NoSuchMethodException x) {
+ // none of the methods exists so we throw the
+ // first NoSuchMethodException as per 5.0
throw firstExc;
}
}
// the premain method should not be required to be public,
// make it accessible so we can call it
+ // Note: The spec says the following:
+ // The agent class must implement a public static premain method...
setAccessible(m, true);
// invoke the 1 or 2-arg method
--- a/jdk/src/share/instrument/InvocationAdapter.c Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/src/share/instrument/InvocationAdapter.c Thu Mar 27 14:15:59 2008 -0700
@@ -626,6 +626,7 @@
jvmtiError jvmtierr;
jvmtierr = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, jarfile);
+ check_phase_ret_1(jvmtierr);
if (jvmtierr == JVMTI_ERROR_NONE) {
return 0;
@@ -634,6 +635,7 @@
jvmtiError err;
err = (*jvmtienv)->GetPhase(jvmtienv, &phase);
+ /* can be called from any phase */
jplis_assert(err == JVMTI_ERROR_NONE);
if (phase == JVMTI_PHASE_LIVE) {
@@ -805,6 +807,8 @@
/* print warning if boot class path not updated */
if (jvmtierr != JVMTI_ERROR_NONE) {
+ check_phase_blob_ret(jvmtierr, free(path));
+
fprintf(stderr, "WARNING: %s not added to bootstrap class loader search: ", path);
switch (jvmtierr) {
case JVMTI_ERROR_ILLEGAL_ARGUMENT :
--- a/jdk/src/share/instrument/JPLISAgent.c Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/src/share/instrument/JPLISAgent.c Thu Mar 27 14:15:59 2008 -0700
@@ -179,6 +179,7 @@
jvmtierror = (*jvmtienv)->GetEnvironmentLocalStorage(
jvmtienv,
(void**)&environment);
+ /* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
if (jvmtierror == JVMTI_ERROR_NONE) {
@@ -230,6 +231,7 @@
/* don't leak envs */
if ( initerror != JPLIS_INIT_ERROR_NONE ) {
jvmtiError jvmtierror = (*jvmtienv)->DisposeEnvironment(jvmtienv);
+ /* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
}
}
@@ -259,7 +261,7 @@
agent->mNormalEnvironment.mIsRetransformer = JNI_FALSE;
agent->mRetransformEnvironment.mJVMTIEnv = NULL; /* NULL until needed */
agent->mRetransformEnvironment.mAgent = agent;
- agent->mRetransformEnvironment.mIsRetransformer = JNI_TRUE;
+ agent->mRetransformEnvironment.mIsRetransformer = JNI_FALSE; /* JNI_FALSE until mJVMTIEnv is set */
agent->mAgentmainCaller = NULL;
agent->mInstrumentationImpl = NULL;
agent->mPremainCaller = NULL;
@@ -277,18 +279,25 @@
jvmtierror = (*jvmtienv)->SetEnvironmentLocalStorage(
jvmtienv,
&(agent->mNormalEnvironment));
+ /* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
/* check what capabilities are available */
checkCapabilities(agent);
/* check phase - if live phase then we don't need the VMInit event */
- jvmtierror == (*jvmtienv)->GetPhase(jvmtienv, &phase);
+ jvmtierror = (*jvmtienv)->GetPhase(jvmtienv, &phase);
+ /* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
if (phase == JVMTI_PHASE_LIVE) {
return JPLIS_INIT_ERROR_NONE;
}
+ if (phase != JVMTI_PHASE_ONLOAD) {
+ /* called too early or called too late; either way bail out */
+ return JPLIS_INIT_ERROR_FAILURE;
+ }
+
/* now turn on the VMInit event */
if ( jvmtierror == JVMTI_ERROR_NONE ) {
jvmtiEventCallbacks callbacks;
@@ -298,6 +307,7 @@
jvmtierror = (*jvmtienv)->SetEventCallbacks( jvmtienv,
&callbacks,
sizeof(callbacks));
+ check_phase_ret_blob(jvmtierror, JPLIS_INIT_ERROR_FAILURE);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
}
@@ -307,6 +317,7 @@
JVMTI_ENABLE,
JVMTI_EVENT_VM_INIT,
NULL /* all threads */);
+ check_phase_ret_blob(jvmtierror, JPLIS_INIT_ERROR_FAILURE);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
}
@@ -622,6 +633,7 @@
jvmtierror = (*jvmtienv)->SetEventCallbacks( jvmtienv,
&callbacks,
sizeof(callbacks));
+ check_phase_ret_false(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
@@ -632,6 +644,7 @@
JVMTI_DISABLE,
JVMTI_EVENT_VM_INIT,
NULL /* all threads */);
+ check_phase_ret_false(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
}
@@ -642,6 +655,7 @@
JVMTI_ENABLE,
JVMTI_EVENT_CLASS_FILE_LOAD_HOOK,
NULL /* all threads */);
+ check_phase_ret_false(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
}
@@ -660,6 +674,7 @@
memset(&potentialCapabilities, 0, sizeof(potentialCapabilities));
jvmtierror = (*jvmtienv)->GetPotentialCapabilities(jvmtienv, &potentialCapabilities);
+ check_phase_ret(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
if ( jvmtierror == JVMTI_ERROR_NONE ) {
@@ -681,9 +696,11 @@
jvmtiError jvmtierror;
jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities);
+ /* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
desiredCapabilities.can_set_native_method_prefix = 1;
jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities);
+ check_phase_ret(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
}
@@ -715,9 +732,11 @@
jvmtiError jvmtierror;
jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities);
+ /* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
desiredCapabilities.can_maintain_original_method_order = 1;
jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities);
+ check_phase_ret(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
}
@@ -732,9 +751,11 @@
if (agent->mRedefineAvailable && !agent->mRedefineAdded) {
jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities);
+ /* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
desiredCapabilities.can_redefine_classes = 1;
jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities);
+ check_phase_ret(jvmtierror);
/*
* With mixed premain/agentmain agents then it's possible that the
@@ -998,6 +1019,7 @@
if (jvmtierror == JVMTI_ERROR_NONE) {
// install the retransforming environment
agent->mRetransformEnvironment.mJVMTIEnv = retransformerEnv;
+ agent->mRetransformEnvironment.mIsRetransformer = JNI_TRUE;
// Make it for ClassFileLoadHook handling
jvmtierror = (*retransformerEnv)->SetEnvironmentLocalStorage(
@@ -1025,6 +1047,7 @@
jvmtierror = (*jvmtienv)->IsModifiableClass( jvmtienv,
clazz,
&is_modifiable);
+ check_phase_ret_false(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
return is_modifiable;
@@ -1032,7 +1055,7 @@
jboolean
isRetransformClassesSupported(JNIEnv * jnienv, JPLISAgent * agent) {
- return retransformableEnvironment(agent) != NULL;
+ return agent->mRetransformEnvironment.mIsRetransformer;
}
void
@@ -1075,6 +1098,12 @@
numClasses = (*jnienv)->GetArrayLength(jnienv, classes);
errorOccurred = checkForThrowable(jnienv);
jplis_assert(!errorOccurred);
+
+ if (!errorOccurred && numClasses == 0) {
+ jplis_assert(numClasses != 0);
+ errorOccurred = JNI_TRUE;
+ errorCode = JVMTI_ERROR_NULL_POINTER;
+ }
}
if (!errorOccurred) {
@@ -1096,6 +1125,13 @@
if (errorOccurred) {
break;
}
+
+ if (classArray[index] == NULL) {
+ jplis_assert(classArray[index] != NULL);
+ errorOccurred = JNI_TRUE;
+ errorCode = JVMTI_ERROR_NULL_POINTER;
+ break;
+ }
}
}
@@ -1217,6 +1253,7 @@
if (!errorOccurred) {
jvmtiError errorCode = JVMTI_ERROR_NONE;
errorCode = (*jvmtienv)->RedefineClasses(jvmtienv, numDefs, classDefs);
+ check_phase_blob_ret(errorCode, deallocate(jvmtienv, (void*)classDefs));
errorOccurred = (errorCode != JVMTI_ERROR_NONE);
if ( errorOccurred ) {
createAndThrowThrowableFromJVMTIErrorCode(jnienv, errorCode);
@@ -1250,6 +1287,7 @@
classLoader,
&classCount,
&classes);
+ check_phase_ret_blob(jvmtierror, localArray);
errorOccurred = (jvmtierror != JVMTI_ERROR_NONE);
jplis_assert(!errorOccurred);
@@ -1311,6 +1349,7 @@
jvmtiError jvmtierror = JVMTI_ERROR_NONE;
jvmtierror = (*jvmtienv)->GetObjectSize(jvmtienv, objectToSize, &objectSize);
+ check_phase_ret_0(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
if ( jvmtierror != JVMTI_ERROR_NONE ) {
createAndThrowThrowableFromJVMTIErrorCode(jnienv, jvmtierror);
@@ -1360,6 +1399,7 @@
} else {
jvmtierror = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, platformChars);
}
+ check_phase_ret(jvmtierror);
if ( jvmtierror != JVMTI_ERROR_NONE ) {
createAndThrowThrowableFromJVMTIErrorCode(jnienv, jvmtierror);
@@ -1450,6 +1490,7 @@
}
err = (*jvmtienv)->SetNativeMethodPrefixes(jvmtienv, inx, (char**)prefixes);
+ /* can be called from any phase */
jplis_assert(err == JVMTI_ERROR_NONE);
for (i = 0; i < inx; i++) {
--- a/jdk/src/share/instrument/JPLISAgent.h Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/src/share/instrument/JPLISAgent.h Thu Mar 27 14:15:59 2008 -0700
@@ -266,6 +266,48 @@
#define jvmti(a) a->mNormalEnvironment.mJVMTIEnv
+/*
+ * A set of macros for insulating the JLI method callers from
+ * JVMTI_ERROR_WRONG_PHASE return codes.
+ */
+
+/* for a JLI method where "blob" is executed before simply returning */
+#define check_phase_blob_ret(ret, blob) \
+ if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
+ blob; \
+ return; \
+ }
+
+/* for a JLI method where simply returning is benign */
+#define check_phase_ret(ret) \
+ if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
+ return; \
+ }
+
+/* for a JLI method where returning zero (0) is benign */
+#define check_phase_ret_0(ret) \
+ if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
+ return 0; \
+ }
+
+/* for a JLI method where returning one (1) is benign */
+#define check_phase_ret_1(ret) \
+ if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
+ return 1; \
+ }
+
+/* for a case where a specific "blob" must be returned */
+#define check_phase_ret_blob(ret, blob) \
+ if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
+ return (blob); \
+ }
+
+/* for a JLI method where returning false is benign */
+#define check_phase_ret_false(ret) \
+ if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
+ return (jboolean) 0; \
+ }
+
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
--- a/jdk/src/share/instrument/JarFacade.c Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/src/share/instrument/JarFacade.c Thu Mar 27 14:15:59 2008 -0700
@@ -23,6 +23,14 @@
* have any questions.
*/
+#ifdef _WIN32
+/*
+ * Win* needs this include. However, Linux and Solaris do not.
+ * Having this include on Solaris SPARC breaks having non US-ASCII
+ * characters in the value of the Premain-Class attribute.
+ */
+#include <ctype.h>
+#endif /* _WIN32 */
#include <string.h>
#include <stdlib.h>
@@ -45,11 +53,37 @@
if (attribute->name == NULL) {
free(attribute);
} else {
- attribute->value = strdup(value);
+ char *begin = (char *)value;
+ char *end;
+ size_t value_len;
+
+ /* skip any leading white space */
+ while (isspace(*begin)) {
+ begin++;
+ }
+
+ /* skip any trailing white space */
+ end = &begin[strlen(begin)];
+ while (end > begin && isspace(end[-1])) {
+ end--;
+ }
+
+ if (begin == end) {
+ /* no value so skip this attribute */
+ free(attribute->name);
+ free(attribute);
+ return;
+ }
+
+ value_len = (size_t)(end - begin);
+ attribute->value = malloc(value_len + 1);
if (attribute->value == NULL) {
free(attribute->name);
free(attribute);
} else {
+ /* save the value without leading or trailing whitespace */
+ strncpy(attribute->value, begin, value_len);
+ attribute->value[value_len] = '\0';
attribute->next = NULL;
if (context->head == NULL) {
context->head = attribute;
--- a/jdk/src/share/instrument/Reentrancy.c Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/src/share/instrument/Reentrancy.c Thu Mar 27 14:15:59 2008 -0700
@@ -74,6 +74,7 @@
jvmtienv,
thread,
newValue);
+ check_phase_ret_blob(error, error);
#if JPLISASSERT_ENABLEASSERTIONS
assertTLSValue( jvmtienv,
@@ -96,6 +97,7 @@
jvmtienv,
thread,
&test);
+ check_phase_ret(error);
jplis_assert(error == JVMTI_ERROR_NONE);
jplis_assert(test == expected);
}
@@ -111,6 +113,7 @@
jvmtienv,
thread,
&storedValue);
+ check_phase_ret_false(error);
jplis_assert(error == JVMTI_ERROR_NONE);
if ( error == JVMTI_ERROR_NONE ) {
/* if this thread is already inside, just return false and short-circuit */
--- a/jdk/src/share/instrument/Utilities.c Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/src/share/instrument/Utilities.c Thu Mar 27 14:15:59 2008 -0700
@@ -46,6 +46,7 @@
error = (*jvmtienv)->Allocate(jvmtienv,
bytecount,
(unsigned char**) &resultBuffer);
+ /* may be called from any phase */
jplis_assert(error == JVMTI_ERROR_NONE);
if ( error != JVMTI_ERROR_NONE ) {
resultBuffer = NULL;
@@ -66,6 +67,7 @@
error = (*jvmtienv)->Deallocate(jvmtienv,
(unsigned char*)buffer);
+ /* may be called from any phase */
jplis_assert_msg(error == JVMTI_ERROR_NONE, "Can't deallocate memory");
return;
}
--- a/jdk/test/java/lang/instrument/BootClassPath/BootClassPathTest.sh Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/BootClassPath/BootClassPathTest.sh Thu Mar 27 14:15:59 2008 -0700
@@ -23,8 +23,10 @@
# @test
# @bug 5055293
-# @summary Test non US-ASCII characters in the value of the Boot-Class-Path
+# @summary Test non US-ASCII characters in the value of the Boot-Class-Path
# attribute.
+#
+# @run shell/timeout=240 BootClassPathTest.sh
if [ "${TESTJAVA}" = "" ]
then
@@ -72,7 +74,7 @@
echo "Running test..."
-"${JAVA}" -javaagent:"${TESTCLASSES}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain
+"${JAVA}" ${TESTVMOPTS} -javaagent:"${TESTCLASSES}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain
result=$?
echo "Cleanup..."
--- a/jdk/test/java/lang/instrument/MakeJAR2.sh Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/MakeJAR2.sh Thu Mar 27 14:15:59 2008 -0700
@@ -70,9 +70,11 @@
cp ${TESTSRC}/${AGENT}.java .
cp ${TESTSRC}/${APP}.java .
rm -rf ilib
-cp -r ${TESTSRC}/ilib .
-mkdir bootpath
-cp -r ${TESTSRC}/bootreporter bootpath
+mkdir ilib
+cp ${TESTSRC}/ilib/*.java ilib
+rm -rf bootpath
+mkdir -p bootpath/bootreporter
+cp ${TESTSRC}/bootreporter/*.java bootpath/bootreporter
cd bootpath
${JAVAC} bootreporter/*.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ManifestTest.sh Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,483 @@
+#
+# 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.
+#
+
+# @test
+# @bug 6274276
+# @summary JLI JAR manifest processing should ignore leading and trailing white space.
+# @author Daniel D. Daugherty
+#
+# @run build ManifestTestApp
+# @run shell/timeout=900 ManifestTest.sh
+#
+
+make_a_JAR() {
+ # version_line and premain_line are required
+ version_line="Manifest-Version: 1.0"
+ premain_line="Premain-Class: ${AGENT}"
+ boot_cp_line=""
+ expect_boot_cp_line="ExampleForBootClassPath was not loaded."
+ can_redef_line=""
+ expect_redef_line="isRedefineClassesSupported()=false"
+ can_retrans_line=""
+ expect_retrans_line="isRetransformClassesSupported()=false"
+ can_set_nmp_line=""
+ expect_set_nmp_line="isNativeMethodPrefixSupported()=false"
+
+ while [ $# != 0 ] ; do
+ case "$1" in
+ defaults)
+ # just use the defaults for the test
+ ;;
+
+ boot_cp_line1)
+ boot_cp_line="Boot-Class-Path: no_white_space"
+ expect_boot_cp_line="ExampleForBootClassPath was loaded."
+ mkdir -p no_white_space
+ cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class no_white_space
+ ;;
+
+ boot_cp_line2)
+ boot_cp_line="Boot-Class-Path: has_leading_blank"
+ expect_boot_cp_line="ExampleForBootClassPath was loaded."
+ mkdir -p has_leading_blank " has_leading_blank"
+ # the good class is in the directory without the blank
+ cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class \
+ has_leading_blank
+ # the bad class is in the directory with the blank
+ cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class.bad \
+ " has_leading_blank"/ExampleForBootClassPath.class
+ ;;
+
+ boot_cp_line3)
+ boot_cp_line="Boot-Class-Path: has_trailing_blank "
+ expect_boot_cp_line="ExampleForBootClassPath was loaded."
+ mkdir -p has_trailing_blank "has_trailing_blank "
+ # the good class is in the directory without the blank
+ cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class \
+ has_trailing_blank
+ # the bad class is in the directory with the blank
+ cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class.bad \
+ "has_trailing_blank "/ExampleForBootClassPath.class
+ ;;
+
+ boot_cp_line4)
+ boot_cp_line="Boot-Class-Path: has_leading_and_trailing_blank "
+ expect_boot_cp_line="ExampleForBootClassPath was loaded."
+ mkdir -p has_leading_and_trailing_blank \
+ " has_leading_and_trailing_blank "
+ # the good class is in the directory without the blanks
+ cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class \
+ has_leading_and_trailing_blank
+ # the bad class is in the directory with the blanks
+ cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class.bad \
+ " has_leading_and_trailing_blank "/ExampleForBootClassPath.class
+ ;;
+
+ boot_cp_line5)
+ boot_cp_line="Boot-Class-Path: has_embedded blank"
+ expect_boot_cp_line="ExampleForBootClassPath was loaded."
+ mkdir -p has_embedded "has_embedded blank"
+ # the good class is in the first blank separated word
+ cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class has_embedded
+ # the bad class is in the directory with the blank
+ cp -p $OUT_OF_THE_WAY/ExampleForBootClassPath.class.bad \
+ "has_embedded blank"/ExampleForBootClassPath.class
+ ;;
+
+ can_redef_line1)
+ can_redef_line="Can-Redefine-Classes: true"
+ expect_redef_line="isRedefineClassesSupported()=true"
+ ;;
+
+ can_redef_line2)
+ can_redef_line="Can-Redefine-Classes: true"
+ expect_redef_line="isRedefineClassesSupported()=true"
+ ;;
+
+ can_redef_line3)
+ can_redef_line="Can-Redefine-Classes: true "
+ expect_redef_line="isRedefineClassesSupported()=true"
+ ;;
+
+ can_redef_line4)
+ can_redef_line="Can-Redefine-Classes: true "
+ expect_redef_line="isRedefineClassesSupported()=true"
+ ;;
+
+ can_redef_line5)
+ can_redef_line="Can-Redefine-Classes: false"
+ ;;
+
+ can_redef_line6)
+ can_redef_line="Can-Redefine-Classes: false"
+ ;;
+
+ can_redef_line7)
+ can_redef_line="Can-Redefine-Classes: false "
+ ;;
+
+ can_redef_line8)
+ can_redef_line="Can-Redefine-Classes: false "
+ ;;
+
+ can_redef_line9)
+ # this line makes the jar command unhappy and that's
+ # not what we're testing so skip this case
+ can_redef_line="Can-Redefine-Classes:"
+ ;;
+
+ can_redef_line10)
+ can_redef_line="Can-Redefine-Classes: "
+ ;;
+
+ can_redef_line11)
+ can_redef_line="Can-Redefine-Classes: "
+ ;;
+
+ can_retrans_line1)
+ can_retrans_line="Can-Retransform-Classes: true"
+ expect_retrans_line="isRetransformClassesSupported()=true"
+ ;;
+
+ can_retrans_line2)
+ can_retrans_line="Can-Retransform-Classes: true"
+ expect_retrans_line="isRetransformClassesSupported()=true"
+ ;;
+
+ can_retrans_line3)
+ can_retrans_line="Can-Retransform-Classes: true "
+ expect_retrans_line="isRetransformClassesSupported()=true"
+ ;;
+
+ can_retrans_line4)
+ can_retrans_line="Can-Retransform-Classes: true "
+ expect_retrans_line="isRetransformClassesSupported()=true"
+ ;;
+
+ can_retrans_line5)
+ can_retrans_line="Can-Retransform-Classes: false"
+ ;;
+
+ can_retrans_line6)
+ can_retrans_line="Can-Retransform-Classes: false"
+ ;;
+
+ can_retrans_line7)
+ can_retrans_line="Can-Retransform-Classes: false "
+ ;;
+
+ can_retrans_line8)
+ can_retrans_line="Can-Retransform-Classes: false "
+ ;;
+
+ can_retrans_line9)
+ # this line makes the jar command unhappy and that's
+ # not what we're testing so skip this case
+ can_retrans_line="Can-Retransform-Classes:"
+ ;;
+
+ can_retrans_line10)
+ can_retrans_line="Can-Retransform-Classes: "
+ ;;
+
+ can_retrans_line11)
+ can_retrans_line="Can-Retransform-Classes: "
+ ;;
+
+ can_set_nmp_line1)
+ can_set_nmp_line="Can-Set-Native-Method-Prefix: true"
+ expect_set_nmp_line="isNativeMethodPrefixSupported()=true"
+ ;;
+
+ can_set_nmp_line2)
+ can_set_nmp_line="Can-Set-Native-Method-Prefix: true"
+ expect_set_nmp_line="isNativeMethodPrefixSupported()=true"
+ ;;
+
+ can_set_nmp_line3)
+ can_set_nmp_line="Can-Set-Native-Method-Prefix: true "
+ expect_set_nmp_line="isNativeMethodPrefixSupported()=true"
+ ;;
+
+ can_set_nmp_line4)
+ can_set_nmp_line="Can-Set-Native-Method-Prefix: true "
+ expect_set_nmp_line="isNativeMethodPrefixSupported()=true"
+ ;;
+
+ can_set_nmp_line5)
+ can_set_nmp_line="Can-Set-Native-Method-Prefix: false"
+ ;;
+
+ can_set_nmp_line6)
+ can_set_nmp_line="Can-Set-Native-Method-Prefix: false"
+ ;;
+
+ can_set_nmp_line7)
+ can_set_nmp_line="Can-Set-Native-Method-Prefix: false "
+ ;;
+
+ can_set_nmp_line8)
+ can_set_nmp_line="Can-Set-Native-Method-Prefix: false "
+ ;;
+
+ can_set_nmp_line9)
+ # this line makes the jar command unhappy and that's
+ # not what we're testing so skip this case
+ can_set_nmp_line="Can-Set-Native-Method-Prefix:"
+ ;;
+
+ can_set_nmp_line10)
+ can_set_nmp_line="Can-Set-Native-Method-Prefix: "
+ ;;
+
+ can_set_nmp_line11)
+ can_set_nmp_line="Can-Set-Native-Method-Prefix: "
+ ;;
+
+ premain_line1)
+ premain_line="Premain-Class: ${AGENT}"
+ ;;
+
+ premain_line2)
+ premain_line="Premain-Class: ${AGENT} "
+ ;;
+
+ premain_line3)
+ premain_line="Premain-Class: ${AGENT} "
+ ;;
+
+ version_line1)
+ version_line="Manifest-Version: 1.0"
+ ;;
+
+ version_line2)
+ version_line="Manifest-Version: 1.0 "
+ ;;
+
+ version_line3)
+ version_line="Manifest-Version: 1.0 "
+ ;;
+
+ *)
+ echo "ERROR: invalid test token"
+ exit 1
+ esac
+ shift
+ done
+
+ echo "${version_line}" > ${AGENT}.mf
+ echo "${premain_line}" >> ${AGENT}.mf
+
+ if [ -n "$boot_cp_line" ]; then
+ echo "${boot_cp_line}" >> ${AGENT}.mf
+ fi
+
+ if [ -n "$can_redef_line" ]; then
+ echo "${can_redef_line}" >> ${AGENT}.mf
+ fi
+
+ if [ -n "$can_retrans_line" ]; then
+ echo "${can_retrans_line}" >> ${AGENT}.mf
+ fi
+
+ if [ -n "$can_set_nmp_line" ]; then
+ echo "${can_set_nmp_line}" >> ${AGENT}.mf
+ fi
+
+ rm -f ${AGENT}.jar
+ ${JAR} cvfm ${AGENT}.jar ${AGENT}.mf ${AGENT}.class
+
+ echo "$expect_boot_cp_line" > expect_boot_cp_line
+ echo "$expect_redef_line" > expect_redef_line
+ echo "$expect_retrans_line" > expect_retrans_line
+ echo "$expect_set_nmp_line" > expect_set_nmp_line
+}
+
+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
+
+JAR="${TESTJAVA}/bin/jar"
+JAVAC="${TESTJAVA}"/bin/javac
+JAVA="${TESTJAVA}"/bin/java
+
+# Now that ManifestTestApp.class is built, we move
+# ExampleForBootClassPath.class so that it cannot be found
+# by default
+OUT_OF_THE_WAY=out_of_the_way
+mkdir $OUT_OF_THE_WAY
+mv "${TESTCLASSES}/ExampleForBootClassPath.class" $OUT_OF_THE_WAY
+
+# create a bad version of ExampleForBootClassPath.class
+# so we can tell when the wrong version is run
+sed 's/return 15/return 42/' "${TESTSRC}"/ExampleForBootClassPath.java \
+ > ExampleForBootClassPath.java
+"$JAVAC" ExampleForBootClassPath.java
+mv ExampleForBootClassPath.class \
+ $OUT_OF_THE_WAY/ExampleForBootClassPath.class.bad
+mv ExampleForBootClassPath.java \
+ $OUT_OF_THE_WAY/ExampleForBootClassPath.java.bad
+
+AGENT=ManifestTestAgent
+# We compile the agent in the working directory instead of with
+# a build task because we construct a different agent JAR file
+# for each test case.
+${JAVAC} -d . ${TESTSRC}/${AGENT}.java
+
+FAIL_MARKER=fail_marker
+rm -f $FAIL_MARKER
+
+while read token; do
+ echo
+ echo "===== begin test case: $token ====="
+ make_a_JAR "$token"
+
+ "${JAVA}" ${TESTVMOPTS} -javaagent:${AGENT}.jar \
+ -classpath "${TESTCLASSES}" ManifestTestApp > output.log 2>&1
+ result=$?
+
+ cat output.log
+
+ if [ "$result" = 0 ]; then
+ echo "PASS: ManifestTestApp exited with status of 0."
+ else
+ echo "FAIL: ManifestTestApp exited with status of $result"
+ touch $FAIL_MARKER
+ fi
+
+ MESG="Hello from ${AGENT}!"
+ grep -s "$MESG" output.log > /dev/null
+ result=$?
+ if [ "$result" = 0 ]; then
+ echo "PASS: found '$MESG' in the test output"
+ else
+ echo "FAIL: did NOT find '$MESG' in the test output"
+ touch $FAIL_MARKER
+ fi
+
+ MESG=`cat expect_boot_cp_line`
+ grep -s "$MESG" output.log > /dev/null
+ result=$?
+ if [ "$result" = 0 ]; then
+ echo "PASS: found '$MESG' in the test output"
+ else
+ echo "FAIL: did NOT find '$MESG' in the test output"
+ touch $FAIL_MARKER
+ fi
+
+ MESG=`cat expect_redef_line`
+ grep -s "$MESG" output.log > /dev/null
+ result=$?
+ if [ "$result" = 0 ]; then
+ echo "PASS: found '$MESG' in the test output"
+ else
+ echo "FAIL: did NOT find '$MESG' in the test output"
+ touch $FAIL_MARKER
+ fi
+
+ MESG=`cat expect_retrans_line`
+ grep -s "$MESG" output.log > /dev/null
+ result=$?
+ if [ "$result" = 0 ]; then
+ echo "PASS: found '$MESG' in the test output"
+ else
+ echo "FAIL: did NOT find '$MESG' in the test output"
+ touch $FAIL_MARKER
+ fi
+
+ MESG=`cat expect_set_nmp_line`
+ grep -s "$MESG" output.log > /dev/null
+ result=$?
+ if [ "$result" = 0 ]; then
+ echo "PASS: found '$MESG' in the test output"
+ else
+ echo "FAIL: did NOT find '$MESG' in the test output"
+ touch $FAIL_MARKER
+ fi
+
+ echo "===== end test case: $token ====="
+ echo
+done << EOF
+defaults
+version_line1
+version_line2
+version_line3
+premain_line1
+premain_line2
+premain_line3
+boot_cp_line1
+boot_cp_line2
+boot_cp_line3
+boot_cp_line4
+boot_cp_line5
+can_redef_line1
+can_redef_line2
+can_redef_line3
+can_redef_line4
+can_redef_line5
+can_redef_line6
+can_redef_line7
+can_redef_line8
+can_redef_line10
+can_redef_line11
+can_retrans_line1
+can_retrans_line2
+can_retrans_line3
+can_retrans_line4
+can_retrans_line5
+can_retrans_line6
+can_retrans_line7
+can_retrans_line8
+can_retrans_line10
+can_retrans_line11
+can_set_nmp_line1
+can_set_nmp_line2
+can_set_nmp_line3
+can_set_nmp_line4
+can_set_nmp_line5
+can_set_nmp_line6
+can_set_nmp_line7
+can_set_nmp_line8
+can_set_nmp_line10
+can_set_nmp_line11
+EOF
+
+if [ -f $FAIL_MARKER ]; then
+ exit 1
+else
+ exit 0
+fi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ManifestTestAgent.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,41 @@
+/*
+ * 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 java.lang.instrument.Instrumentation;
+
+public class ManifestTestAgent {
+ private static Instrumentation instrumentation;
+
+ private ManifestTestAgent() {
+ }
+
+ public static void premain(String agentArgs, Instrumentation inst) {
+ System.out.println("Hello from ManifestTestAgent!");
+ System.out.println("isNativeMethodPrefixSupported()=" +
+ inst.isNativeMethodPrefixSupported());
+ System.out.println("isRedefineClassesSupported()=" +
+ inst.isRedefineClassesSupported());
+ System.out.println("isRetransformClassesSupported()=" +
+ inst.isRetransformClassesSupported());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ManifestTestApp.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+public class ManifestTestApp {
+ public static void main(String args[]) {
+ System.out.println("Hello from ManifestTestApp!");
+
+ new ManifestTestApp().doTest();
+ System.exit(0);
+ }
+
+ private void doTest() {
+ try {
+ // load the class only found via the Boot-Class-Path attribute
+ Object instance = loadExampleClass();
+ if (instance.getClass().getClassLoader() == null) {
+ System.out.println("PASS: ExampleForBootClassPath was loaded" +
+ " by the boot class path loader.");
+ } else {
+ System.out.println("FAIL: ExampleForBootClassPath was loaded" +
+ " by a non-boot class path loader.");
+ System.exit(1);
+ }
+ } catch (NoClassDefFoundError ncdfe) {
+ // This message just lets ManifestTest.sh know whether or
+ // not ExampleForBootClassPath was loaded. Depending on
+ // the current test case, that will be either a PASSing
+ // condition or a FAILing condition as determined by
+ // ManifestTest.sh.
+ System.out.println("ExampleForBootClassPath was not loaded.");
+ }
+ }
+
+ Object loadExampleClass() {
+ ExampleForBootClassPath instance = new ExampleForBootClassPath();
+ System.out.println("ExampleForBootClassPath was loaded.");
+ if (instance.fifteen() == 15) {
+ System.out.println("PASS: the correct" +
+ " ExampleForBootClassPath was loaded.");
+ } else {
+ System.out.println("FAIL: the wrong ExampleForBootClassPath" +
+ " was loaded.");
+ System.out.println("FAIL: instance.fifteen()=" +
+ instance.fifteen());
+ System.exit(1);
+ }
+ return instance;
+ }
+}
--- a/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/NativeMethodPrefixAgent.java Thu Mar 27 14:15:59 2008 -0700
@@ -27,7 +27,7 @@
* @summary test setNativeMethodPrefix
* @author Robert Field, Sun Microsystems
*
- * @run shell MakeJAR2.sh NativeMethodPrefixAgent NativeMethodPrefixApp 'Can-Retransform-Classes: true' 'Can-Set-Native-Method-Prefix: true'
+ * @run shell/timeout=240 MakeJAR2.sh NativeMethodPrefixAgent NativeMethodPrefixApp 'Can-Retransform-Classes: true' 'Can-Set-Native-Method-Prefix: true'
* @run main/othervm -javaagent:NativeMethodPrefixAgent.jar NativeMethodPrefixApp
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ParallelTransformerLoader.sh Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,72 @@
+#
+# 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.
+#
+
+# @test
+# @bug 5088398
+# @summary Test parallel class loading by parallel transformers.
+# @author Daniel D. Daugherty as modified from the code of Daryl Puryear @ Wily
+#
+# @run shell MakeJAR3.sh ParallelTransformerLoaderAgent
+# @run build ParallelTransformerLoaderApp
+# @run shell/timeout=240 ParallelTransformerLoader.sh
+#
+
+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
+
+JAR="${TESTJAVA}"/bin/jar
+JAVAC="${TESTJAVA}"/bin/javac
+JAVA="${TESTJAVA}"/bin/java
+
+"${JAVAC}" -d . \
+ "${TESTSRC}"/TestClass1.java \
+ "${TESTSRC}"/TestClass2.java \
+ "${TESTSRC}"/TestClass3.java
+
+"${JAR}" cvf Test.jar Test*.class
+# Removing the test class files is important. If these
+# .class files are available on the classpath other
+# than via Test.jar, then the deadlock will not reproduce.
+rm -f Test*.class
+
+"${JAVA}" ${TESTVMOPTS} -javaagent:ParallelTransformerLoaderAgent.jar=Test.jar \
+ -classpath "${TESTCLASSES}" ParallelTransformerLoaderApp
+result=$?
+echo "result=$result"
+
+exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ParallelTransformerLoaderAgent.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,120 @@
+/*
+ * 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 java.lang.instrument.*;
+import java.net.*;
+import java.io.*;
+import java.security.*;
+
+/**
+ * Test Java Agent
+ *
+ * @author Daryl Puryear
+ * @copyright 1999-2004 Wily Technology, Inc. All rights reserved.
+ */
+public class ParallelTransformerLoaderAgent
+{
+ private static URL sURL;
+ private static ClassLoader sClassLoader;
+
+ public static synchronized ClassLoader
+ getClassLoader()
+ {
+ return sClassLoader;
+ }
+
+ public static synchronized void
+ generateNewClassLoader()
+ {
+ sClassLoader = new URLClassLoader(new URL[] {sURL});
+ }
+
+ public static void
+ premain( String agentArgs,
+ Instrumentation instrumentation)
+ throws Exception
+ {
+ if (agentArgs == null || agentArgs == "")
+ {
+ System.err.println("Error: No jar file name provided, test will not run.");
+ return;
+ }
+
+ sURL = (new File(agentArgs)).toURL();
+ System.out.println("Using jar file: " + sURL);
+ generateNewClassLoader();
+
+ instrumentation.addTransformer(new TestTransformer());
+ }
+
+ private static class TestTransformer
+ implements ClassFileTransformer
+ {
+ public byte[]
+ transform( ClassLoader loader,
+ String className,
+ Class classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer)
+ throws IllegalClassFormatException
+ {
+ String tName = Thread.currentThread().getName();
+ // In 160_03 and older, transform() is called
+ // with the "system_loader_lock" held and that
+ // prevents the bootstrap class loaded from
+ // running in parallel. If we add a slight sleep
+ // delay here when the transform() call is not
+ // main or TestThread, then the deadlock in
+ // 160_03 and older is much more reproducible.
+ if (!tName.equals("main") && !tName.equals("TestThread")) {
+ System.out.println("Thread '" + tName +
+ "' has called transform()");
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ie) {
+ }
+ }
+
+ // load additional classes when called from other threads
+ if (!tName.equals("main"))
+ {
+ loadClasses(3);
+ }
+ return null;
+ }
+
+ public static void
+ loadClasses( int index)
+ {
+ ClassLoader loader = ParallelTransformerLoaderAgent.getClassLoader();
+ try
+ {
+ Class.forName("TestClass" + index, true, loader);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/ParallelTransformerLoaderApp.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+/**
+ * Test Java Program
+ *
+ * @author Daryl Puryear
+ * @copyright 1999-2004 Wily Technology, Inc. All rights reserved.
+ */
+public class ParallelTransformerLoaderApp
+{
+ private static final int kNumIterations = 1000;
+
+ public static void
+ main( String[] args)
+ throws Exception
+ {
+ System.out.println();
+ System.out.print("Starting test with " + kNumIterations + " iterations");
+ for (int i = 0; i < kNumIterations; i++)
+ {
+ // load some classes from multiple threads (this thread and one other)
+ Thread testThread = new TestThread(2);
+ testThread.start();
+ loadClasses(1);
+
+ // log that it completed and reset for the next iteration
+ testThread.join();
+ System.out.print(".");
+ ParallelTransformerLoaderAgent.generateNewClassLoader();
+ }
+
+ System.out.println();
+ System.out.println("Test completed successfully");
+ }
+
+ private static class TestThread
+ extends Thread
+ {
+ private final int fIndex;
+
+ public
+ TestThread( int index)
+ {
+ super("TestThread");
+
+ fIndex = index;
+ }
+
+ public void
+ run()
+ {
+ loadClasses(fIndex);
+ }
+ }
+
+ public static void
+ loadClasses( int index)
+ {
+ ClassLoader loader = ParallelTransformerLoaderAgent.getClassLoader();
+ try
+ {
+ Class.forName("TestClass" + index, true, loader);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
--- a/jdk/test/java/lang/instrument/PremainClass/DummyMain.java Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/PremainClass/DummyMain.java Thu Mar 27 14:15:59 2008 -0700
@@ -22,11 +22,10 @@
*/
/*
- *
- *
- * Used by PremainClassTest.sh - dummy "main application" which doesn't do anything
+ * dummy "Hello World"ish application for "premain" tests
*/
public class DummyMain {
public static void main(String[] args) {
+ System.out.println("Hello from DummyMain!");
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0001.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (0,0,0,1): declared 1-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent0001
+ * @run main/othervm -javaagent:InheritAgent0001.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent0001 extends InheritAgent0001Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent0001!");
+ }
+
+ // This agent does NOT have a double argument premain() method.
+}
+
+class InheritAgent0001Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ // This agent does NOT have a double argument premain() method.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0010.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (0,0,1,0): declared 2-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent0010
+ * @run main/othervm -javaagent:InheritAgent0010.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent0010 extends InheritAgent0010Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ //
+ // This agent has a double argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent0010!");
+ }
+}
+
+class InheritAgent0010Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ // This agent does NOT have a double argument premain() method.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0011.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (0,0,1,1): declared 2-arg and declared 1-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent0011
+ * @run main/othervm -javaagent:InheritAgent0011.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent0011 extends InheritAgent0011Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent0011!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ //
+ // This agent has a double argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent0011!");
+ }
+}
+
+class InheritAgent0011Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ // This agent does NOT have a double argument premain() method.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0100.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (0,1,0,0): inherited 1-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent0100
+ * @run main/othervm -javaagent:InheritAgent0100.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent0100 extends InheritAgent0100Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ // This agent does NOT have a double argument premain() method.
+}
+
+class InheritAgent0100Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent0100Super!");
+ }
+
+ // This agent does NOT have a double argument premain() method.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0101.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (0,1,0,1): inherited 1-arg and declared 1-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent0101
+ * @run main/othervm -javaagent:InheritAgent0101.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent0101 extends InheritAgent0101Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent0101!");
+ }
+
+ // This agent does NOT have a double argument premain() method.
+}
+
+class InheritAgent0101Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent0101Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ // This agent does NOT have a double argument premain() method.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0110.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (0,1,1,0): inherited 1-arg and declared 2-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent0110
+ * @run main/othervm -javaagent:InheritAgent0110.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent0110 extends InheritAgent0110Super {
+
+ // This agent does NOT have a one argument premain() method.
+
+ //
+ // This agent has a double argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent0110!");
+ }
+}
+
+class InheritAgent0110Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent0110Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ // This agent does NOT have a double argument premain() method.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent0111.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (0,1,1,1): inherited 1-arg, declared 2-arg and declared 1-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent0111
+ * @run main/othervm -javaagent:InheritAgent0111.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent0111 extends InheritAgent0111Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent0111!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ //
+ // This agent has a double argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent0111!");
+ }
+
+}
+
+class InheritAgent0111Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent0111Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ // This agent does NOT have a double argument premain() method.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1000.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (1,0,0,0): inherited 2-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent1000
+ * @run main/othervm -javaagent:InheritAgent1000.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent1000 extends InheritAgent1000Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ // This agent does NOT have a double argument premain() method.
+}
+
+class InheritAgent1000Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ //
+ // This agent has a double argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1000Super!");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1001.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (1,0,0,1): inherited 2-arg, and declared 1-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent1001
+ * @run main/othervm -javaagent:InheritAgent1001.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent1001 extends InheritAgent1001Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent1001!");
+ }
+
+ // This agent does NOT have a double argument premain() method.
+}
+
+class InheritAgent1001Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ //
+ // This agent has a double argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1001Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1010.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (1,0,1,0): inherited 2-arg, and declared 2-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent1010
+ * @run main/othervm -javaagent:InheritAgent1010.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent1010 extends InheritAgent1010Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ //
+ // This agent has a double argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1010!");
+ }
+}
+
+class InheritAgent1010Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ //
+ // This agent has a double argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1010Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1011.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (1,0,1,1): inherited 2-arg, declared 2-arg and declared 1-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent1011
+ * @run main/othervm -javaagent:InheritAgent1011.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent1011 extends InheritAgent1011Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent1011!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ //
+ // This agent has a double argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1011!");
+ }
+}
+
+class InheritAgent1011Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ //
+ // This agent has a double argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1011Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1100.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (1,1,0,0): inherited 2-arg and inherited 1-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent1100
+ * @run main/othervm -javaagent:InheritAgent1100.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent1100 extends InheritAgent1100Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ // This agent does NOT have a double argument premain() method.
+}
+
+class InheritAgent1100Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent1100Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ //
+ // This agent has a double argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1100Super!");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1101.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (1,1,0,1): inherited 2-arg, inherited 1-arg, and declared 1-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent1101
+ * @run main/othervm -javaagent:InheritAgent1101.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent1101 extends InheritAgent1101Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent1101!");
+ }
+
+ // This agent does NOT have a double argument premain() method.
+}
+
+class InheritAgent1101Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent1101Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ //
+ // This agent has a double argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1101Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1110.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (1,1,1,0): inherited 2-arg, inherited 1-arg, and declared 2-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent1110
+ * @run main/othervm -javaagent:InheritAgent1110.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent1110 extends InheritAgent1110Super {
+
+ // This agent does NOT have a single argument premain() method.
+
+ //
+ // This agent has a double argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1110!");
+ }
+}
+
+class InheritAgent1110Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent1110Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ //
+ // This agent has a double argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1110Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/InheritAgent1111.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 6289149
+ * @summary test config (1,1,1,1): inherited 2-arg, inherited 1-arg, declared 2-arg and declared 1-arg in agent class
+ * @author Daniel D. Daugherty, Sun Microsystems
+ *
+ * @run shell ../MakeJAR3.sh InheritAgent1111
+ * @run main/othervm -javaagent:InheritAgent1111.jar DummyMain
+ */
+
+import java.lang.instrument.*;
+
+class InheritAgent1111 extends InheritAgent1111Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent1111!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ //
+ // This agent has a double argument premain() method which
+ // is the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1111!");
+ }
+}
+
+class InheritAgent1111Super {
+
+ //
+ // This agent has a single argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs) {
+ System.out.println("Hello from Single-Arg InheritAgent1111Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+
+ //
+ // This agent has a double argument premain() method which
+ // is NOT the one that should be called.
+ //
+ public static void premain (String agentArgs, Instrumentation instArg) {
+ System.out.println("Hello from Double-Arg InheritAgent1111Super!");
+ throw new Error("ERROR: THIS AGENT SHOULD NOT HAVE BEEN CALLED.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/NoPremainAgent.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,29 @@
+/*
+ * 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 java.lang.instrument.*;
+
+class NoPremainAgent {
+
+ // This agent is missing the premain() function.
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/NoPremainAgent.sh Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,68 @@
+#
+# 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.
+#
+
+# @test
+# @bug 6289149
+# @summary test when the agent's class is missing the premain() function.
+# @author Daniel D. Daugherty, Sun Microsystems
+#
+# @run build DummyMain
+# @run shell ../MakeJAR3.sh NoPremainAgent
+# @run shell NoPremainAgent.sh
+#
+
+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
+
+JAVAC="${TESTJAVA}"/bin/javac
+JAVA="${TESTJAVA}"/bin/java
+
+"${JAVA}" ${TESTVMOPTS} -javaagent:NoPremainAgent.jar \
+ -classpath "${TESTCLASSES}" DummyMain > output.log 2>&1
+cat output.log
+
+MESG="java.lang.NoSuchMethodException"
+grep "$MESG" output.log
+result=$?
+if [ "$result" = 0 ]; then
+ echo "PASS: found '$MESG' in the test output"
+else
+ echo "FAIL: did NOT find '$MESG' in the test output"
+fi
+
+exit $result
--- a/jdk/test/java/lang/instrument/PremainClass/PremainClassTest.sh Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/PremainClass/PremainClassTest.sh Thu Mar 27 14:15:59 2008 -0700
@@ -49,7 +49,7 @@
"$JAVAC" -d "${TESTCLASSES}" "${TESTSRC}"/DummyMain.java
-"${JAVA}" -javaagent:"${TESTSRC}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain
+"${JAVA}" ${TESTVMOPTS} -javaagent:"${TESTSRC}"/Agent.jar -classpath "${TESTCLASSES}" DummyMain
result=$?
exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgent.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,32 @@
+/*
+ * 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 java.lang.instrument.*;
+
+class ZeroArgPremainAgent {
+
+ // This agent has a zero arg premain() function.
+ public static void premain () {
+ System.out.println("Hello from ZeroArgInheritAgent!");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgent.sh Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,68 @@
+#
+# 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.
+#
+
+# @test
+# @bug 6289149
+# @summary test when the agent's class has a zero arg premain() function.
+# @author Daniel D. Daugherty, Sun Microsystems
+#
+# @run build DummyMain
+# @run shell ../MakeJAR3.sh ZeroArgPremainAgent
+# @run shell ZeroArgPremainAgent.sh
+#
+
+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
+
+JAVAC="${TESTJAVA}"/bin/javac
+JAVA="${TESTJAVA}"/bin/java
+
+"${JAVA}" ${TESTVMOPTS} -javaagent:ZeroArgPremainAgent.jar \
+ -classpath "${TESTCLASSES}" DummyMain > output.log 2>&1
+cat output.log
+
+MESG="java.lang.NoSuchMethodException"
+grep "$MESG" output.log
+result=$?
+if [ "$result" = 0 ]; then
+ echo "PASS: found '$MESG' in the test output"
+else
+ echo "FAIL: did NOT find '$MESG' in the test output"
+fi
+
+exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineClassWithNativeMethod.sh Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,81 @@
+#
+# 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.
+#
+
+# @test
+# @bug 5003341 4917140 6545149
+# @summary Redefine a class with a native method.
+# @author Daniel D. Daugherty as modified from the test submitted by clovis@par.univie.ac.at
+#
+# @run shell MakeJAR3.sh RedefineClassWithNativeMethodAgent 'Can-Redefine-Classes: true'
+# @run build RedefineClassWithNativeMethodApp
+# @run shell RedefineClassWithNativeMethod.sh
+#
+
+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
+
+JAVAC="${TESTJAVA}"/bin/javac
+JAVA="${TESTJAVA}"/bin/java
+
+"${JAVA}" ${TESTVMOPTS} \
+ -javaagent:RedefineClassWithNativeMethodAgent.jar=java/lang/Thread.class \
+ -classpath "${TESTCLASSES}" RedefineClassWithNativeMethodApp \
+ > output.log 2>&1
+result=$?
+
+cat output.log
+
+if [ "$result" = 0 ]; then
+ echo "PASS: RedefineClassWithNativeMethodApp exited with status of 0."
+else
+ echo "FAIL: RedefineClassWithNativeMethodApp exited with status of $result"
+ exit "$result"
+fi
+
+MESG="Exception"
+grep "$MESG" output.log
+result=$?
+if [ "$result" = 0 ]; then
+ echo "FAIL: found '$MESG' in the test output"
+ result=1
+else
+ echo "PASS: did NOT find '$MESG' in the test output"
+ result=0
+fi
+
+exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineClassWithNativeMethodAgent.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,70 @@
+/*
+ * 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 java.lang.instrument.*;
+import java.net.*;
+import java.util.*;
+import java.io.*;
+
+public class RedefineClassWithNativeMethodAgent {
+ static Class clz;
+
+ // just read the original class and redefine it via a Timer
+ public static void premain(String agentArgs, final Instrumentation inst) throws Exception {
+ String s = agentArgs.substring(0, agentArgs.indexOf(".class"));
+ clz = Class.forName(s.replace('/', '.'));
+ ClassLoader loader =
+ RedefineClassWithNativeMethodAgent.class.getClassLoader();
+ URL classURL = loader.getResource(agentArgs);
+ if (classURL == null) {
+ throw new Exception("Cannot find class: " + agentArgs);
+ }
+
+ int redefineLength;
+ InputStream redefineStream;
+
+ System.out.println("Reading test class from " + classURL);
+ if (classURL.getProtocol().equals("file")) {
+ File f = new File(classURL.getFile());
+ redefineStream = new FileInputStream(f);
+ redefineLength = (int) f.length();
+ } else {
+ URLConnection conn = classURL.openConnection();
+ redefineStream = conn.getInputStream();
+ redefineLength = conn.getContentLength();
+ }
+
+ final byte[] buffer = new byte[redefineLength];
+ new BufferedInputStream(redefineStream).read(buffer);
+ new Timer(true).schedule(new TimerTask() {
+ public void run() {
+ try {
+ System.out.println("Instrumenting");
+ ClassDefinition cld = new ClassDefinition(clz, buffer);
+ inst.redefineClasses(new ClassDefinition[] { cld });
+ }
+ catch (Exception e) { e.printStackTrace(); }
+ }
+ }, 500);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineClassWithNativeMethodApp.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+public class RedefineClassWithNativeMethodApp {
+ public static void main(String[] args) throws Exception {
+ try {
+ // give the agent a chance to redefine the target class
+ Thread.sleep(2000);
+ } catch (InterruptedException ie) {
+ }
+
+ System.out.println("Creating instance of " +
+ RedefineClassWithNativeMethodAgent.clz);
+ RedefineClassWithNativeMethodAgent.clz.newInstance();
+
+ System.exit(0);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvoke.sh Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,82 @@
+#
+# 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.
+#
+
+# @test
+# @bug 6667089
+# @summary Reflexive invocation of newly added methods broken.
+# @author Daniel D. Daugherty
+#
+# @run shell MakeJAR3.sh RedefineMethodAddInvokeAgent 'Can-Redefine-Classes: true'
+# @run build RedefineMethodAddInvokeApp
+# @run shell RedefineMethodAddInvoke.sh
+#
+
+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
+
+JAVAC="${TESTJAVA}"/bin/javac
+JAVA="${TESTJAVA}"/bin/java
+
+cp "${TESTSRC}"/RedefineMethodAddInvokeTarget_1.java \
+ RedefineMethodAddInvokeTarget.java
+"${JAVAC}" -d . RedefineMethodAddInvokeTarget.java
+mv RedefineMethodAddInvokeTarget.java RedefineMethodAddInvokeTarget_1.java
+mv RedefineMethodAddInvokeTarget.class RedefineMethodAddInvokeTarget_1.class
+
+cp "${TESTSRC}"/RedefineMethodAddInvokeTarget_2.java \
+ RedefineMethodAddInvokeTarget.java
+"${JAVAC}" -d . RedefineMethodAddInvokeTarget.java
+mv RedefineMethodAddInvokeTarget.java RedefineMethodAddInvokeTarget_2.java
+mv RedefineMethodAddInvokeTarget.class RedefineMethodAddInvokeTarget_2.class
+
+"${JAVA}" ${TESTVMOPTS} -javaagent:RedefineMethodAddInvokeAgent.jar \
+ -classpath "${TESTCLASSES}" RedefineMethodAddInvokeApp > output.log 2>&1
+cat output.log
+
+MESG="Exception"
+grep "$MESG" output.log
+result=$?
+if [ "$result" = 0 ]; then
+ echo "FAIL: found '$MESG' in the test output"
+ result=1
+else
+ echo "PASS: did NOT find '$MESG' in the test output"
+ result=0
+fi
+
+exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvokeAgent.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,43 @@
+/*
+ * 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 java.lang.instrument.Instrumentation;
+
+public class RedefineMethodAddInvokeAgent {
+ private static Instrumentation instrumentation;
+
+ private RedefineMethodAddInvokeAgent() {
+ }
+
+ public static void premain(String agentArgs, Instrumentation inst) {
+ System.out.println("Hello from RedefineMethodAddInvokeAgent!");
+ System.out.println("isRedefineClassesSupported()=" +
+ inst.isRedefineClassesSupported());
+
+ instrumentation = inst;
+ }
+
+ public static Instrumentation getInstrumentation() {
+ return instrumentation;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvokeApp.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,70 @@
+/*
+ * 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 java.io.*;
+import java.lang.instrument.*;
+
+public class RedefineMethodAddInvokeApp {
+ public static void main(String args[]) throws Exception {
+ System.out.println("Hello from RedefineMethodAddInvokeApp!");
+
+ new RedefineMethodAddInvokeApp().doTest();
+
+ System.exit(0);
+ }
+
+ private void doTest() throws Exception {
+ RedefineMethodAddInvokeTarget target =
+ new RedefineMethodAddInvokeTarget();
+
+ System.out.println("RedefineMethodAddInvokeApp: invoking myMethod()");
+ target.test(0); // invoke the original myMethod()
+
+ // add myMethod1()
+ do_redefine(1);
+
+ System.out.println("RedefineMethodAddInvokeApp: invoking myMethod1()");
+ target.test(1); // invoke myMethod1()
+
+ // add myMethod2()
+ do_redefine(2);
+
+ System.out.println("RedefineMethodAddInvokeApp: invoking myMethod2()");
+ target.test(2); // invoke myMethod2()
+ }
+
+ private static void do_redefine(int counter) throws Exception {
+ File f = new File("RedefineMethodAddInvokeTarget_" + counter +
+ ".class");
+ System.out.println("Reading test class from " + f);
+ InputStream redefineStream = new FileInputStream(f);
+
+ byte[] redefineBuffer = NamedBuffer.loadBufferFromStream(redefineStream);
+
+ ClassDefinition redefineParamBlock = new ClassDefinition(
+ RedefineMethodAddInvokeTarget.class, redefineBuffer);
+
+ RedefineMethodAddInvokeAgent.getInstrumentation().redefineClasses(
+ new ClassDefinition[] {redefineParamBlock});
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvokeTarget.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,37 @@
+/*
+ * 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 java.lang.reflect.Method;
+
+public class RedefineMethodAddInvokeTarget {
+ public void test(int counter) throws Exception {
+ Method method = getClass().getDeclaredMethod("myMethod" +
+ (counter == 0 ? "" : counter));
+ method.setAccessible(true);
+ method.invoke(this);
+ }
+
+ public void myMethod() {
+ System.out.println("Hello from the original myMethod()!");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvokeTarget_1.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,43 @@
+/*
+ * 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 java.lang.reflect.Method;
+
+public class RedefineMethodAddInvokeTarget {
+ public void test(int counter) throws Exception {
+ Method method = getClass().getDeclaredMethod("myMethod" +
+ (counter == 0 ? "" : counter));
+ method.setAccessible(true);
+ method.invoke(this);
+ }
+
+ public void myMethod() {
+ System.out.println("Hello from the non-EMCP myMethod()!");
+ }
+
+ private final void myMethod1() {
+ System.out.println("Hello from myMethod1()!");
+ System.out.println("Calling myMethod() from myMethod1():");
+ myMethod();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/RedefineMethodAddInvokeTarget_2.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,49 @@
+/*
+ * 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 java.lang.reflect.Method;
+
+public class RedefineMethodAddInvokeTarget {
+ public void test(int counter) throws Exception {
+ Method method = getClass().getDeclaredMethod("myMethod" +
+ (counter == 0 ? "" : counter));
+ method.setAccessible(true);
+ method.invoke(this);
+ }
+
+ public void myMethod() {
+ System.out.println("Hello from the non-EMCP again myMethod()!");
+ }
+
+ private final void myMethod1() {
+ System.out.println("Hello from myMethod1()!");
+ System.out.println("Calling myMethod() from myMethod1():");
+ myMethod();
+ }
+
+ private final void myMethod2() {
+ System.out.println("Hello from myMethod2()!");
+ System.out.println("Calling myMethod1() from myMethod2():");
+ myMethod1();
+ }
+}
--- a/jdk/test/java/lang/instrument/RetransformAgent.java Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/RetransformAgent.java Thu Mar 27 14:15:59 2008 -0700
@@ -27,7 +27,7 @@
* @summary test retransformClasses
* @author Robert Field, Sun Microsystems
*
- * @run shell MakeJAR2.sh RetransformAgent RetransformApp 'Can-Retransform-Classes: true'
+ * @run shell/timeout=240 MakeJAR2.sh RetransformAgent RetransformApp 'Can-Retransform-Classes: true'
* @run main/othervm -javaagent:RetransformAgent.jar RetransformApp
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/StressGetObjectSizeApp.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,86 @@
+/*
+ * 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 java.lang.instrument.Instrumentation;
+
+public class StressGetObjectSizeApp
+ extends ASimpleInstrumentationTestCase
+{
+
+ /**
+ * Constructor for StressGetObjectSizeApp.
+ * @param name
+ */
+ public StressGetObjectSizeApp(String name)
+ {
+ super(name);
+ }
+
+ public static void
+ main (String[] args)
+ throws Throwable {
+ ATestCaseScaffold test = new StressGetObjectSizeApp(args[0]);
+ test.runTest();
+ }
+
+ protected final void
+ doRunTest()
+ throws Throwable {
+ stressGetObjectSize();
+ }
+
+ public void stressGetObjectSize() {
+ System.out.println("main: an object size=" +
+ fInst.getObjectSize(new Object()));
+
+ RoundAndRound[] threads = new RoundAndRound[10];
+ for (int i = 0; i < threads.length; ++i) {
+ threads[i] = new RoundAndRound(fInst);
+ threads[i].start();
+ }
+ try {
+ Thread.sleep(500); // let all threads get going in their loops
+ } catch (InterruptedException ie) {
+ }
+ System.out.println("stressGetObjectSize: returning");
+ return;
+ }
+
+ private static class RoundAndRound extends Thread {
+ private final Instrumentation inst;
+ private final Object anObject;
+
+ public RoundAndRound(Instrumentation inst) {
+ this.inst = inst;
+ this.anObject = new Object();
+ setDaemon(true);
+ }
+
+ public void run() {
+ long sum = 0;
+ while (true) {
+ sum += inst.getObjectSize(anObject);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/StressGetObjectSizeTest.sh Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,70 @@
+#
+# 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.
+#
+
+# @test
+# @bug 6572160
+# @summary stress getObjectSize() API
+# @author Daniel D. Daugherty as modified from the code of fischman@google.com
+#
+# @run build StressGetObjectSizeApp
+# @run shell MakeJAR.sh basicAgent
+# @run shell StressGetObjectSizeTest.sh
+#
+
+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
+
+JAVA="${TESTJAVA}"/bin/java
+
+"${JAVA}" ${TESTVMOPTS} -javaagent:basicAgent.jar \
+ -classpath "${TESTCLASSES}" StressGetObjectSizeApp StressGetObjectSizeApp \
+ > output.log 2>&1
+cat output.log
+
+MESG="ASSERTION FAILED"
+grep "$MESG" output.log
+result=$?
+if [ "$result" = 0 ]; then
+ echo "FAIL: found '$MESG' in the test output"
+ result=1
+else
+ echo "PASS: did NOT find '$MESG' in the test output"
+ result=0
+fi
+
+exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/TestClass1.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+/**
+ * Test Java Program
+ *
+ * @author Daryl Puryear
+ * @copyright 1999-2004 Wily Technology, Inc. All rights reserved.
+ */
+public class TestClass1
+{
+ public
+ TestClass1()
+ {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/TestClass2.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+/**
+ * Test Java Program
+ *
+ * @author Daryl Puryear
+ * @copyright 1999-2004 Wily Technology, Inc. All rights reserved.
+ */
+public class TestClass2
+{
+ public
+ TestClass2()
+ {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/TestClass3.java Thu Mar 27 14:15:59 2008 -0700
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+/**
+ * Test Java Program
+ *
+ * @author Daryl Puryear
+ * @copyright 1999-2004 Wily Technology, Inc. All rights reserved.
+ */
+public class TestClass3
+{
+ public
+ TestClass3()
+ {
+ }
+}
--- a/jdk/test/java/lang/instrument/TransformerManagementThreadAddTests.java Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/TransformerManagementThreadAddTests.java Thu Mar 27 14:15:59 2008 -0700
@@ -79,6 +79,12 @@
protected static final int TOTAL_THREADS = MAX_TRANS - MIN_TRANS + 1;
private byte[] fDummyClassBytes;
+ // fCheckedTransformers is a Vector that is used to verify
+ // that the transform() function is called in the same
+ // order in which the transformers were added to the
+ // TransformerManager. The test currently verifies that all
+ // transformers for a specific worker thread are in
+ // increasing order by index value.
private Vector fCheckedTransformers;
private Instrumentation fInstrumentation;
private int fFinished;
@@ -131,9 +137,16 @@
threads[i].start();
}
- while (!exec.fDone)
+ // Effective Java - Item 48: Synchronize access to shared mutable data
+ // Don't use a direct field getter.
+ while (!exec.isDone())
{
- Thread.currentThread().yield();
+ // Effective Java - Item 51: Don't depend on the thread scheduler
+ // Use sleep() instead of yield().
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ie) {
+ }
}
assertTrue(finalCheck());
@@ -169,13 +182,17 @@
this.fExec = exec;
}
+ // Effective Java - Item 48: Synchronize access to shared mutable data
+ // Document a synchronized setter.
protected synchronized void
threadFinished(Thread t)
{
fFinished++;
}
- protected boolean
+ // Effective Java - Item 48: Synchronize access to shared mutable data
+ // Provide synchronized getter.
+ protected synchronized boolean
threadsDone()
{
return fFinished == TOTAL_THREADS;
@@ -188,7 +205,9 @@
protected boolean
testCompleted()
{
- return getExecThread().fDone;
+ // Effective Java - Item 48: Synchronize access to shared mutable data
+ // Don't use direct field getter.
+ return getExecThread().isDone();
}
/**
@@ -264,11 +283,19 @@
private void
executeTransform()
{
- fCheckedTransformers.clear();
-
try
{
ClassDefinition cd = new ClassDefinition(DummyClass.class, fDummyClassBytes);
+
+ // When the ClassDefinition above is created for the first
+ // time and every time redefineClasses() below is called,
+ // the transform() function is called for each registered
+ // transformer. We only want one complete set of calls to
+ // be logged in the fCheckedTransformers Vector so we clear
+ // any calls logged for ClassDefinition above and just use
+ // the ones logged for redefineClasses() below.
+ fCheckedTransformers.clear();
+
getInstrumentation().redefineClasses(new ClassDefinition[]{ cd });
}
catch (ClassNotFoundException e)
@@ -325,6 +352,18 @@
{
private boolean fDone = false;
+ // Effective Java - Item 48: Synchronize access to shared mutable data
+ // Provide a synchronized getter.
+ private synchronized boolean isDone() {
+ return fDone;
+ }
+
+ // Effective Java - Item 48: Synchronize access to shared mutable data
+ // Provide a synchronized setter.
+ private synchronized void setIsDone() {
+ fDone = true;
+ }
+
public void
run()
{
@@ -335,7 +374,9 @@
// Do a final check for good measure
executeTransform();
- fDone = true;
+ // Effective Java - Item 48: Synchronize access to shared mutable data
+ // Don't use direct field setter.
+ setIsDone();
}
}
--- a/jdk/test/java/lang/instrument/TransformerManagementThreadRemoveTests.java Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/TransformerManagementThreadRemoveTests.java Thu Mar 27 14:15:59 2008 -0700
@@ -27,10 +27,9 @@
* @summary multi-thread test to exercise sync and contention for removes to transformer registry
* @author Gabriel Adauto, Wily Technology
*
- * @ignore Disabled until race condition which hangs test can be fixed.
* @run build TransformerManagementThreadRemoveTests
- * @run shell MakeJAR.sh basicAgent
- * @run main/othervm -javaagent:basicAgent.jar TransformerManagementThreadRemoveTests TransformerManagementThreadRemoveTests
+ * @run shell MakeJAR.sh redefineAgent
+ * @run main/othervm -javaagent:redefineAgent.jar TransformerManagementThreadRemoveTests TransformerManagementThreadRemoveTests
*/
import java.util.*;
@@ -87,7 +86,12 @@
while (!testCompleted())
{
- Thread.currentThread().yield();
+ // Effective Java - Item 51: Don't depend on the thread scheduler
+ // Use sleep() instead of yield().
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ie) {
+ }
}
assertTrue(finalCheck());
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CircularityErrorTest.sh Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CircularityErrorTest.sh Thu Mar 27 14:15:59 2008 -0700
@@ -26,14 +26,14 @@
# @summary Unit tests for appendToBootstrapClassLoaderSearch and
# appendToSystemClasLoaderSearch methods.
#
-# @run shell CircularityErrorTest.sh
+# @run shell/timeout=240 CircularityErrorTest.sh
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
-
+
. ${TESTSRC}/CommonSetup.sh
# Setup to create circularity condition
@@ -71,5 +71,5 @@
-C "${TESTCLASSES}" CircularityErrorTest.class
# Finally we run the test
-(cd "${TESTCLASSES}";
- $JAVA -javaagent:CircularityErrorTest.jar CircularityErrorTest)
+(cd "${TESTCLASSES}";
+ $JAVA ${TESTVMOPTS} -javaagent:CircularityErrorTest.jar CircularityErrorTest)
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh Thu Mar 27 14:15:59 2008 -0700
@@ -34,11 +34,11 @@
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
-
+
. ${TESTSRC}/CommonSetup.sh
# Create Foo and Bar
-# Foo has a reference to Bar but we deleted Bar so that
+# Foo has a reference to Bar but we deleted Bar so that
# a NoClassDefFoundError will be thrown when Foo tries to
# resolve the reference to Bar
@@ -53,11 +53,11 @@
public class Foo {
public static boolean doSomething() {
try {
- Bar b = new Bar();
- return true;
- } catch (NoClassDefFoundError x) {
- return false;
- }
+ Bar b = new Bar();
+ return true;
+ } catch (NoClassDefFoundError x) {
+ return false;
+ }
}
}
EOF
@@ -79,5 +79,5 @@
# Finally we run the test
(cd "${TESTCLASSES}"; \
- $JAVA -Xverify:none -XX:+TraceClassUnloading -javaagent:ClassUnloadTest.jar \
- ClassUnloadTest "${OTHERDIR}" Bar.jar)
+ $JAVA ${TESTVMOPTS} -Xverify:none -XX:+TraceClassUnloading \
+ -javaagent:ClassUnloadTest.jar ClassUnloadTest "${OTHERDIR}" Bar.jar)
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh Thu Mar 27 14:15:59 2008 -0700
@@ -24,7 +24,6 @@
#
-#%E
#
# Common setup for unit tests. Setups up the following variables:
#
@@ -66,7 +65,7 @@
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
-
+
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/run_tests.sh Thu Mar 27 10:42:36 2008 -0700
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/run_tests.sh Thu Mar 27 14:15:59 2008 -0700
@@ -23,24 +23,24 @@
# have any questions.
#
-
+
# @test
# @bug 6173575 6388987
-# @summary Unit tests for appendToBootstrapClassLoaderSearch and
+# @summary Unit tests for appendToBootstrapClassLoaderSearch and
# appendToSystemClasLoaderSearch methods.
#
# @build Agent AgentSupport BootSupport BasicTest PrematureLoadTest DynamicTest
-# @run shell run_tests.sh
+# @run shell/timeout=240 run_tests.sh
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
-
+
. ${TESTSRC}/CommonSetup.sh
-
+
# Simple tests
echo "Creating jar files for simple tests..."
@@ -50,13 +50,13 @@
"$JAR" -cfm Agent.jar "${TESTSRC}"/manifest.mf Agent.class
"$JAR" -cf AgentSupport.jar AgentSupport.class
"$JAR" -cf BootSupport.jar BootSupport.class
-"$JAR" -cf SimpleTests.jar BasicTest.class PrematureLoadTest.class
+"$JAR" -cf SimpleTests.jar BasicTest.class PrematureLoadTest.class
failures=0
go() {
echo ''
- sh -xc "$JAVA -javaagent:Agent.jar -classpath SimpleTests.jar $1 $2 $3" 2>&1
+ sh -xc "$JAVA ${TESTVMOPTS} -javaagent:Agent.jar -classpath SimpleTests.jar $1 $2 $3" 2>&1
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
}
@@ -75,7 +75,7 @@
"${JAVAC}" -d tmp "${TESTSRC}"/Tracer.java
(cd tmp; "${JAR}" cf ../Tracer.jar org/tools/Tracer.class)
-# InstrumentedApplication is Application+instrmentation - don't copy as
+# InstrumentedApplication is Application+instrmentation - don't copy as
# we don't want the original file permission
cat "${TESTSRC}"/InstrumentedApplication.java > ./Application.java
@@ -85,11 +85,11 @@
cp "${TESTSRC}"/Application.java .
"${JAVAC}" -d . Application.java
-sh -xc "$JAVA -classpath . -javaagent:Agent.jar DynamicTest" 2>&1
+sh -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar DynamicTest" 2>&1
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
# Repeat test with security manager
-sh -xc "$JAVA -classpath . -javaagent:Agent.jar -Djava.security.manager DynamicTest" 2>&1
+sh -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar -Djava.security.manager DynamicTest" 2>&1
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
#