Merge
This commit is contained in:
commit
66dc9c8301
@ -165,25 +165,35 @@ bool InstanceKlass::has_nest_member(InstanceKlass* k, TRAPS) const {
|
||||
k->external_name(), this->external_name());
|
||||
}
|
||||
|
||||
// Check names first and if they match then check actual klass. This avoids
|
||||
// resolving anything unnecessarily.
|
||||
// Check for a resolved cp entry , else fall back to a name check.
|
||||
// We don't want to resolve any class other than the one being checked.
|
||||
for (int i = 0; i < _nest_members->length(); i++) {
|
||||
int cp_index = _nest_members->at(i);
|
||||
Symbol* name = _constants->klass_name_at(cp_index);
|
||||
if (name == k->name()) {
|
||||
log_trace(class, nestmates)("- Found it at nest_members[%d] => cp[%d]", i, cp_index);
|
||||
|
||||
// names match so check actual klass - this may trigger class loading if
|
||||
// it doesn't match (but that should be impossible)
|
||||
if (_constants->tag_at(cp_index).is_klass()) {
|
||||
Klass* k2 = _constants->klass_at(cp_index, CHECK_false);
|
||||
if (k2 == k) {
|
||||
log_trace(class, nestmates)("- class is listed as a nest member");
|
||||
log_trace(class, nestmates)("- class is listed at nest_members[%d] => cp[%d]", i, cp_index);
|
||||
return true;
|
||||
} else {
|
||||
// same name but different klass!
|
||||
log_trace(class, nestmates)(" - klass comparison failed!");
|
||||
// can't have different classes for the same name, so we're done
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Symbol* name = _constants->klass_name_at(cp_index);
|
||||
if (name == k->name()) {
|
||||
log_trace(class, nestmates)("- Found it at nest_members[%d] => cp[%d]", i, cp_index);
|
||||
|
||||
// names match so check actual klass - this may trigger class loading if
|
||||
// it doesn't match (but that should be impossible)
|
||||
Klass* k2 = _constants->klass_at(cp_index, CHECK_false);
|
||||
if (k2 == k) {
|
||||
log_trace(class, nestmates)("- class is listed as a nest member");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// same name but different klass!
|
||||
log_trace(class, nestmates)(" - klass comparison failed!");
|
||||
// can't have two names the same, so we're done
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ class GlobalCounter : public AllStatic {
|
||||
// Since do not know what we will end up next to in BSS, we make sure the
|
||||
// counter is on a seperate cacheline.
|
||||
struct PaddedCounter {
|
||||
DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE/2, 0);
|
||||
DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0);
|
||||
volatile uintx _counter;
|
||||
DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE/2, sizeof(volatile uintx));
|
||||
DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile uintx));
|
||||
};
|
||||
|
||||
// The global counter
|
||||
|
@ -725,7 +725,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
|
||||
return config().invalidVtableIndex;
|
||||
}
|
||||
if (holder.isInterface()) {
|
||||
if (resolved.isInterface()) {
|
||||
if (resolved.isInterface() || !resolved.isLinked()) {
|
||||
return config().invalidVtableIndex;
|
||||
}
|
||||
return getVtableIndexForInterfaceMethod(resolved);
|
||||
|
@ -100,6 +100,17 @@ public class TTY implements EventNotifier {
|
||||
public void breakpointEvent(BreakpointEvent be) {
|
||||
Thread.yield(); // fetch output
|
||||
MessageOutput.lnprint("Breakpoint hit:");
|
||||
// Print breakpoint location and prompt if suspend policy is
|
||||
// SUSPEND_NONE or SUSPEND_EVENT_THREAD. In case of SUSPEND_ALL
|
||||
// policy this is handled by vmInterrupted() method.
|
||||
int suspendPolicy = be.request().suspendPolicy();
|
||||
switch (suspendPolicy) {
|
||||
case EventRequest.SUSPEND_EVENT_THREAD:
|
||||
case EventRequest.SUSPEND_NONE:
|
||||
printBreakpointLocation(be);
|
||||
MessageOutput.printPrompt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -227,6 +238,10 @@ public class TTY implements EventNotifier {
|
||||
Commands.locationString(loc)});
|
||||
}
|
||||
|
||||
private void printBreakpointLocation(BreakpointEvent be) {
|
||||
printLocationWithSourceLine(be.thread().name(), be.location());
|
||||
}
|
||||
|
||||
private void printCurrentLocation() {
|
||||
ThreadInfo threadInfo = ThreadInfo.getCurrentThreadInfo();
|
||||
StackFrame frame;
|
||||
@ -239,26 +254,29 @@ public class TTY implements EventNotifier {
|
||||
if (frame == null) {
|
||||
MessageOutput.println("No frames on the current call stack");
|
||||
} else {
|
||||
Location loc = frame.location();
|
||||
printBaseLocation(threadInfo.getThread().name(), loc);
|
||||
// Output the current source line, if possible
|
||||
if (loc.lineNumber() != -1) {
|
||||
String line;
|
||||
try {
|
||||
line = Env.sourceLine(loc, loc.lineNumber());
|
||||
} catch (java.io.IOException e) {
|
||||
line = null;
|
||||
}
|
||||
if (line != null) {
|
||||
MessageOutput.println("source line number and line",
|
||||
new Object [] {loc.lineNumber(),
|
||||
line});
|
||||
}
|
||||
}
|
||||
printLocationWithSourceLine(threadInfo.getThread().name(), frame.location());
|
||||
}
|
||||
MessageOutput.println();
|
||||
}
|
||||
|
||||
private void printLocationWithSourceLine(String threadName, Location loc) {
|
||||
printBaseLocation(threadName, loc);
|
||||
// Output the current source line, if possible
|
||||
if (loc.lineNumber() != -1) {
|
||||
String line;
|
||||
try {
|
||||
line = Env.sourceLine(loc, loc.lineNumber());
|
||||
} catch (java.io.IOException e) {
|
||||
line = null;
|
||||
}
|
||||
if (line != null) {
|
||||
MessageOutput.println("source line number and line",
|
||||
new Object [] {loc.lineNumber(),
|
||||
line});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void printLocationOfEvent(LocatableEvent theEvent) {
|
||||
printBaseLocation(theEvent.thread().name(), theEvent.location());
|
||||
}
|
||||
|
@ -429,11 +429,24 @@ public class TestResolvedJavaMethod extends MethodUniverse {
|
||||
}
|
||||
}
|
||||
|
||||
static class UnlinkedType {
|
||||
}
|
||||
|
||||
/**
|
||||
* All public non-final methods should be available in the vtable.
|
||||
*/
|
||||
@Test
|
||||
public void testVirtualMethodTableAccess() {
|
||||
ResolvedJavaType unlinkedType = metaAccess.lookupJavaType(UnlinkedType.class);
|
||||
assertTrue(!unlinkedType.isLinked());
|
||||
for (Class<?> c : classes) {
|
||||
if (c.isInterface()) {
|
||||
for (Method m : c.getDeclaredMethods()) {
|
||||
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
|
||||
method.isInVirtualMethodTable(unlinkedType);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Class<?> c : classes) {
|
||||
if (c.isPrimitive() || c.isInterface()) {
|
||||
continue;
|
||||
|
@ -29,12 +29,12 @@
|
||||
extern "C" {
|
||||
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define THREADS_LIMIT 2000
|
||||
|
||||
|
@ -32,12 +32,12 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define THREADS_LIMIT 2000
|
||||
|
||||
|
@ -130,7 +130,7 @@ Java_nsk_jvmti_unit_clsldrclss00x_check(JNIEnv *env, jclass appCls, jclass objCl
|
||||
found = JNI_FALSE;
|
||||
for (i = 0; i < classCount; ++i) {
|
||||
jclass k = classes[i];
|
||||
if ( env->IsSameObject(k, appCls) ) {
|
||||
if (env->IsSameObject(k, appCls)) {
|
||||
if (printdump) {
|
||||
printf(">>> found app class in app class loader\n");
|
||||
}
|
||||
@ -154,7 +154,7 @@ Java_nsk_jvmti_unit_clsldrclss00x_check(JNIEnv *env, jclass appCls, jclass objCl
|
||||
found = JNI_FALSE;
|
||||
for (i = 0; i < classCount; ++i) {
|
||||
jclass k = classes[i];
|
||||
if ( env->IsSameObject(k, objCls) ) {
|
||||
if (env->IsSameObject(k, objCls)) {
|
||||
if (printdump) {
|
||||
printf(">>> found Object class in bootstrap class loader\n");
|
||||
}
|
||||
|
@ -29,12 +29,12 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
static jvmtiEnv *jvmti;
|
||||
static jint iGlobalStatus = 0;
|
||||
|
@ -29,12 +29,12 @@
|
||||
extern "C" {
|
||||
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf(" %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf(" %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf(" %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf(" %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if ( res != err) { printf(str); printf(" unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if (res != err) { printf(str); printf(" unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
|
||||
|
||||
|
@ -29,8 +29,8 @@
|
||||
extern "C" {
|
||||
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define THREADS_LIMIT 8
|
||||
|
||||
|
@ -29,12 +29,12 @@
|
||||
extern "C" {
|
||||
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
|
||||
|
||||
|
@ -29,12 +29,12 @@
|
||||
extern "C" {
|
||||
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define THREADS_LIMIT 2000
|
||||
|
||||
|
@ -28,12 +28,12 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define THREADS_LIMIT 2000
|
||||
|
||||
|
@ -51,12 +51,12 @@
|
||||
extern "C" {
|
||||
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf(" %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if ( res != err) { printf(str); printf(" unexpected error %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf(" %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if (res != err) { printf(str); printf(" unexpected error %d\n",res); return res;}
|
||||
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf(" %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf(" %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if ( res != err) { printf(str); printf(" unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if (res != err) { printf(str); printf(" unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define THREADS_LIMIT 8
|
||||
|
||||
|
@ -38,12 +38,12 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
|
||||
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_VOID(str,res) if (res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR_VOID(str,res,err) if (res != err) { printf(str); printf("unexpected error %d\n",res); iGlobalStatus = 2; }
|
||||
|
||||
jvmtiEnv *jvmti;
|
||||
jint iGlobalStatus = 0;
|
||||
|
@ -41,11 +41,11 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
#define JVMTI_ERROR_CHECK_DURING_ONLOAD(str,res) if ( res != JVMTI_ERROR_NONE) { printf("Fatal error: %s - %d\n", str, res); return JNI_ERR; }
|
||||
#define JVMTI_ERROR_CHECK_DURING_ONLOAD(str,res) if (res != JVMTI_ERROR_NONE) { printf("Fatal error: %s - %d\n", str, res); return JNI_ERR; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK_RETURN(str,res) if ( res != JVMTI_ERROR_NONE) { printf("Error: %s - %d\n", str, res); return; }
|
||||
#define JVMTI_ERROR_CHECK_RETURN(str,res) if (res != JVMTI_ERROR_NONE) { printf("Error: %s - %d\n", str, res); return; }
|
||||
|
||||
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf("Error: %s - %d\n", str, res); }
|
||||
#define JVMTI_ERROR_CHECK(str,res) if (res != JVMTI_ERROR_NONE) { printf("Error: %s - %d\n", str, res); }
|
||||
|
||||
#define THREADS_LIMIT 200
|
||||
|
||||
|
@ -161,18 +161,18 @@ jthread nsk_jvmti_aod_createThread(JNIEnv *jni) {
|
||||
jmethodID threadConstructor;
|
||||
jthread thread;
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != NULL )) {
|
||||
if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != NULL)) {
|
||||
NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!NSK_JNI_VERIFY(jni,
|
||||
(threadConstructor = jni->GetMethodID(klass, "<init>", "()V") ) != NULL )) {
|
||||
(threadConstructor = jni->GetMethodID(klass, "<init>", "()V")) != NULL)) {
|
||||
NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!NSK_JNI_VERIFY (jni,
|
||||
(thread = jni->NewObject(klass, threadConstructor, NULL)) != NULL ) ) {
|
||||
(thread = jni->NewObject(klass, threadConstructor, NULL)) != NULL)) {
|
||||
NSK_COMPLAIN0("Failed to create Thread object\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -194,18 +194,18 @@ jthread nsk_jvmti_aod_createThreadWithName(JNIEnv *jni, const char* threadName)
|
||||
if (!NSK_JNI_VERIFY(jni, (threadNameString = jni->NewStringUTF(threadName)) != NULL))
|
||||
return NULL;
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != NULL )) {
|
||||
if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != NULL)) {
|
||||
NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!NSK_JNI_VERIFY(jni,
|
||||
(threadConstructor = jni->GetMethodID(klass, "<init>", "(Ljava/lang/String;)V") ) != NULL )) {
|
||||
(threadConstructor = jni->GetMethodID(klass, "<init>", "(Ljava/lang/String;)V")) != NULL)) {
|
||||
NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!NSK_JNI_VERIFY(jni,
|
||||
(thread = jni->NewObject(klass, threadConstructor, threadNameString)) != NULL ) ) {
|
||||
(thread = jni->NewObject(klass, threadConstructor, threadNameString)) != NULL)) {
|
||||
NSK_COMPLAIN0("Failed to create Thread object\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -250,7 +250,7 @@ int nsk_jvmti_aod_redefineClass(
|
||||
|
||||
bytecode = fopen(file, "rb");
|
||||
error= JVMTI_ERROR_NONE;
|
||||
if ( bytecode == NULL ) {
|
||||
if (bytecode == NULL) {
|
||||
NSK_COMPLAIN1("Error opening file '%s'\n", file);
|
||||
return NSK_FALSE;
|
||||
}
|
||||
@ -261,12 +261,12 @@ int nsk_jvmti_aod_redefineClass(
|
||||
NSK_DISPLAY1("File size= %ld\n", ftell(bytecode));
|
||||
rewind(bytecode);
|
||||
error = jvmti->Allocate(size, &classBytes);
|
||||
if ( error != JVMTI_ERROR_NONE) {
|
||||
if (error != JVMTI_ERROR_NONE) {
|
||||
NSK_DISPLAY1("Failed to create memory %s\n", TranslateError(error));
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
if ( ((jint) fread( classBytes, 1, size, bytecode )) != size ) {
|
||||
if (((jint) fread(classBytes, 1, size, bytecode)) != size) {
|
||||
NSK_COMPLAIN0("Failed to read all the bytes, could be less or more\n");
|
||||
fclose(bytecode);
|
||||
return NSK_FALSE;
|
||||
@ -281,9 +281,9 @@ int nsk_jvmti_aod_redefineClass(
|
||||
classDef.class_bytes = classBytes;
|
||||
NSK_DISPLAY0("Redefining\n");
|
||||
error = jvmti->RedefineClasses(1, &classDef);
|
||||
if ( error != JVMTI_ERROR_NONE ) {
|
||||
if (error != JVMTI_ERROR_NONE) {
|
||||
NSK_DISPLAY1("# error occured while redefining %s ",
|
||||
TranslateError(error) );
|
||||
TranslateError(error));
|
||||
return NSK_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -69,13 +69,13 @@ int g_tagVisitCount[MAX_TAG];
|
||||
|
||||
void markTagSet(jlong tag_val)
|
||||
{
|
||||
if ( tag_val > 0 && tag_val < MAX_TAG )
|
||||
if (tag_val > 0 && tag_val < MAX_TAG)
|
||||
g_tagFlags[tag_val] |= FLAG_TAG_SET;
|
||||
}
|
||||
|
||||
void markTagVisited(jlong tag_val)
|
||||
{
|
||||
if ( tag_val > 0 && tag_val < MAX_TAG ) {
|
||||
if (tag_val > 0 && tag_val < MAX_TAG) {
|
||||
g_tagVisitCount[tag_val]++;
|
||||
}
|
||||
}
|
||||
@ -87,11 +87,11 @@ jboolean checkThatAllTagsVisited()
|
||||
|
||||
NSK_DISPLAY0("Checking that all set tags have been visited\n");
|
||||
|
||||
for ( i = 1; i < MAX_TAG; i++ ) {
|
||||
for (i = 1; i < MAX_TAG; i++) {
|
||||
char flags = g_tagFlags[i];
|
||||
|
||||
if ( (g_tagFlags[i] & FLAG_TAG_SET) ) {
|
||||
if ( g_tagVisitCount[i] == 0 ) {
|
||||
if ((g_tagFlags[i] & FLAG_TAG_SET)) {
|
||||
if (g_tagVisitCount[i] == 0) {
|
||||
NSK_COMPLAIN1("Tag %" LL "d has not been visited: %x\n", i);
|
||||
ok = JNI_FALSE;
|
||||
}
|
||||
@ -115,28 +115,28 @@ JNIEXPORT jboolean JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects
|
||||
jvmtiEnv * jvmti = nsk_jvmti_getAgentJVMTIEnv();
|
||||
jint hashCode;
|
||||
|
||||
if ( ! NSK_VERIFY(jvmti->SetTag(o, tag) == JVMTI_ERROR_NONE) ) {
|
||||
if (!NSK_VERIFY(jvmti->SetTag(o, tag) == JVMTI_ERROR_NONE)) {
|
||||
NSK_COMPLAIN2("Can't set tag %li for object %lx\n", tag, o);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
if ( ! NSK_VERIFY(jvmti->GetObjectHashCode(o, &hashCode) == JVMTI_ERROR_NONE) ) {
|
||||
if (!NSK_VERIFY(jvmti->GetObjectHashCode(o, &hashCode) == JVMTI_ERROR_NONE)) {
|
||||
NSK_COMPLAIN1("Can't get hash object %lx\n", o);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
NSK_DISPLAY2("setTag: %08x <- % 3li", hashCode, tag);
|
||||
|
||||
if ( tag > 0 && tag < MAX_TAG ) {
|
||||
if (tag > 0 && tag < MAX_TAG) {
|
||||
jboolean fCopy;
|
||||
const char * s;
|
||||
|
||||
if ( ! NSK_VERIFY((s = jni->GetStringUTFChars(sInfo, &fCopy)) != NULL) ) {
|
||||
if (!NSK_VERIFY((s = jni->GetStringUTFChars(sInfo, &fCopy)) != NULL)) {
|
||||
NSK_COMPLAIN1("Can't get string at %#p\n", sInfo);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
if ( ! s ) {
|
||||
if (!s) {
|
||||
NSK_COMPLAIN1("Can't get string at %#p: NULL\n", sInfo);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
@ -160,7 +160,7 @@ JNIEXPORT jlong JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects_ge
|
||||
|
||||
jlong tag;
|
||||
jvmtiError r;
|
||||
if ( ! NSK_VERIFY((r = jvmti->GetTag(o, &tag)) == JVMTI_ERROR_NONE) ) {
|
||||
if (!NSK_VERIFY((r = jvmti->GetTag(o, &tag)) == JVMTI_ERROR_NONE)) {
|
||||
NSK_COMPLAIN2("Can't GetTag for object %lx. Return code: %i\n", o, r);
|
||||
return -1;
|
||||
}
|
||||
@ -186,9 +186,9 @@ static RefToVerify * findRefToVerify(jlong tagFrom, jlong tagTo, jint refKind)
|
||||
int i;
|
||||
RefToVerify * pRefRec = g_refsToVerify;
|
||||
|
||||
for ( i = g_refsToVerifyCnt; i > 0; i--, pRefRec++ ) {
|
||||
for (i = g_refsToVerifyCnt; i > 0; i--, pRefRec++) {
|
||||
pRefRec = &g_refsToVerify[i];
|
||||
if ( pRefRec->_tagFrom == tagFrom && pRefRec->_tagTo == tagTo && pRefRec->_refKind == refKind ) {
|
||||
if (pRefRec->_tagFrom == tagFrom && pRefRec->_tagTo == tagTo && pRefRec->_refKind == refKind) {
|
||||
return pRefRec;
|
||||
}
|
||||
}
|
||||
@ -200,7 +200,7 @@ static jboolean addRefToVerify(jlong tagFrom, jlong tagTo, jint refKind, int exp
|
||||
{
|
||||
RefToVerify * pRefRec;
|
||||
|
||||
if ( g_refsToVerifyCnt >= MAX_REFS ) {
|
||||
if (g_refsToVerifyCnt >= MAX_REFS) {
|
||||
NSK_COMPLAIN0("TEST_BUG: Max. number of refs reached!");
|
||||
nsk_jvmti_setFailStatus();
|
||||
return JNI_FALSE;
|
||||
@ -224,20 +224,20 @@ JNIEXPORT jboolean JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects
|
||||
jlong tagFrom, tagTo;
|
||||
RefToVerify * pRefRec;
|
||||
|
||||
if ( ! NSK_VERIFY((r = jvmti->GetTag(from, &tagFrom)) == JVMTI_ERROR_NONE) ) {
|
||||
if (!NSK_VERIFY((r = jvmti->GetTag(from, &tagFrom)) == JVMTI_ERROR_NONE)) {
|
||||
NSK_COMPLAIN2("TEST_BUG: Can't GetTag for object %lx. Return code: %i\n", from, r);
|
||||
nsk_jvmti_setFailStatus();
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if ( ! NSK_VERIFY((r = jvmti->GetTag(to, &tagTo)) == JVMTI_ERROR_NONE) ) {
|
||||
if (!NSK_VERIFY((r = jvmti->GetTag(to, &tagTo)) == JVMTI_ERROR_NONE)) {
|
||||
NSK_COMPLAIN2("TEST_BUG: Can't GetTag for object %lx. Return code: %i\n", to, r);
|
||||
nsk_jvmti_setFailStatus();
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
if ( (pRefRec = findRefToVerify(tagFrom, tagTo, refKind)) != NULL ) {
|
||||
if ((pRefRec = findRefToVerify(tagFrom, tagTo, refKind)) != NULL) {
|
||||
pRefRec->_expectedCount += count;
|
||||
return JNI_TRUE;
|
||||
}
|
||||
@ -249,7 +249,7 @@ jboolean markRefToVerify(jlong tagFrom, jlong tagTo, int refKind)
|
||||
{
|
||||
RefToVerify * pRefRec;
|
||||
|
||||
if ( (pRefRec = findRefToVerify(tagFrom, tagTo, refKind)) != NULL ) {
|
||||
if ((pRefRec = findRefToVerify(tagFrom, tagTo, refKind)) != NULL) {
|
||||
pRefRec->_actualCount++;
|
||||
return JNI_TRUE;
|
||||
}
|
||||
@ -299,8 +299,8 @@ void printHeapRefCallbackInfo(
|
||||
NSK_DISPLAY2(" tag: %" LL "d, referrer_tag: %" LL "d\n",
|
||||
tag_val, DEREF(referrer_tag_ptr));
|
||||
|
||||
szInfo = ( tag_val > 0 && tag_val < MAX_TAG ) ? g_szTagInfo[tag_val] : "<none>";
|
||||
szRefInfo = ( referrer_tag_ptr && *referrer_tag_ptr > 0 && *referrer_tag_ptr < MAX_TAG ) ? g_szTagInfo[*referrer_tag_ptr] : "<none>";
|
||||
szInfo = (tag_val > 0 && tag_val < MAX_TAG) ? g_szTagInfo[tag_val] : "<none>";
|
||||
szRefInfo = (referrer_tag_ptr && *referrer_tag_ptr > 0 && *referrer_tag_ptr < MAX_TAG) ? g_szTagInfo[*referrer_tag_ptr] : "<none>";
|
||||
|
||||
NSK_DISPLAY3(" summary: %s: %s <- %s\n",
|
||||
g_refKindStr[reference_kind], szInfo, szRefInfo);
|
||||
|
@ -232,12 +232,12 @@ int nsk_jvmti_parseOptions(const char options[]) {
|
||||
context.options.string[len] = '\0';
|
||||
context.options.string[len+1] = '\0';
|
||||
|
||||
for (opt = context.options.string; ; ) {
|
||||
for (opt = context.options.string; ;) {
|
||||
const char* opt_end;
|
||||
const char* val_sep;
|
||||
int opt_len=0;
|
||||
int val_len=0;
|
||||
int exit=1;
|
||||
int exit=1;
|
||||
|
||||
while (*opt != '\0' && isOptSep(*opt)) opt++;
|
||||
if (*opt == '\0') break;
|
||||
@ -489,15 +489,13 @@ int nsk_jvmti_redefineClass(jvmtiEnv * jvmti,
|
||||
jclass classToRedefine,
|
||||
const char * fileName) {
|
||||
redefineAttempted = NSK_TRUE;
|
||||
if ( nsk_jvmti_findOptionValue(NSK_JVMTI_OPT_PATH_TO_NEW_BYTE_CODE)
|
||||
== NULL ) {
|
||||
nsk_printf("# error expected: %s \n",
|
||||
NSK_JVMTI_OPT_PATH_TO_NEW_BYTE_CODE );
|
||||
if (nsk_jvmti_findOptionValue(NSK_JVMTI_OPT_PATH_TO_NEW_BYTE_CODE) == NULL) {
|
||||
nsk_printf("# error expected: %s \n", NSK_JVMTI_OPT_PATH_TO_NEW_BYTE_CODE);
|
||||
nsk_printf("Hint :: missing java -agentlib:agentlib=%s=DirName, ($TESTBASE/bin) \n",
|
||||
NSK_JVMTI_OPT_PATH_TO_NEW_BYTE_CODE );
|
||||
NSK_JVMTI_OPT_PATH_TO_NEW_BYTE_CODE);
|
||||
return NSK_FALSE;
|
||||
}
|
||||
if ( fileName == NULL) {
|
||||
if (fileName == NULL) {
|
||||
nsk_printf("# error file name expected did not found \n");
|
||||
return NSK_FALSE;
|
||||
}
|
||||
@ -517,7 +515,7 @@ int nsk_jvmti_redefineClass(jvmtiEnv * jvmti,
|
||||
|
||||
bytecode = fopen(file, "rb");
|
||||
error= JVMTI_ERROR_NONE;
|
||||
if ( bytecode == NULL ) {
|
||||
if (bytecode == NULL) {
|
||||
nsk_printf("# error **Agent::error opening file %s \n",file);
|
||||
return NSK_FALSE;
|
||||
}
|
||||
@ -528,12 +526,12 @@ int nsk_jvmti_redefineClass(jvmtiEnv * jvmti,
|
||||
nsk_printf("# info file size= %ld\n",ftell(bytecode));
|
||||
rewind(bytecode);
|
||||
error = jvmti->Allocate(size,&classBytes);
|
||||
if ( error != JVMTI_ERROR_NONE) {
|
||||
if (error != JVMTI_ERROR_NONE) {
|
||||
nsk_printf(" Failed to create memory %s \n",TranslateError(error));
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
if ( ((jint) fread( classBytes, 1,size,bytecode )) != size ) {
|
||||
if (((jint) fread(classBytes, 1,size,bytecode)) != size) {
|
||||
nsk_printf(" # error failed to read all the bytes , could be less or more \n");
|
||||
return NSK_FALSE;
|
||||
} else {
|
||||
@ -546,9 +544,9 @@ int nsk_jvmti_redefineClass(jvmtiEnv * jvmti,
|
||||
classDef.class_byte_count= size;
|
||||
classDef.class_bytes = classBytes;
|
||||
error = jvmti->RedefineClasses(1,&classDef);
|
||||
if ( error != JVMTI_ERROR_NONE ) {
|
||||
if (error != JVMTI_ERROR_NONE) {
|
||||
nsk_printf("# error occured while redefining %s ",
|
||||
TranslateError(error) );
|
||||
TranslateError(error));
|
||||
return NSK_FALSE;
|
||||
}
|
||||
}
|
||||
@ -570,7 +568,7 @@ Java_nsk_share_jvmti_RedefineAgent_redefineAttempted(JNIEnv *jni, jobject obj)
|
||||
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_nsk_share_jvmti_RedefineAgent_isRedefined(JNIEnv * jni, jobject obj ) {
|
||||
Java_nsk_share_jvmti_RedefineAgent_isRedefined(JNIEnv * jni, jobject obj) {
|
||||
|
||||
if (redefineSucceed == NSK_TRUE) {
|
||||
return JNI_TRUE;
|
||||
@ -582,8 +580,8 @@ Java_nsk_share_jvmti_RedefineAgent_isRedefined(JNIEnv * jni, jobject obj ) {
|
||||
* This jni method is a Java wrapper for agent status.
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_nsk_share_jvmti_RedefineAgent_agentStatus(JNIEnv * jni, jobject obj ) {
|
||||
if ( agentFailed == NSK_TRUE) {
|
||||
Java_nsk_share_jvmti_RedefineAgent_agentStatus(JNIEnv * jni, jobject obj) {
|
||||
if (agentFailed == NSK_TRUE) {
|
||||
return JNI_FALSE;
|
||||
} else {
|
||||
return JNI_TRUE;
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#if (defined(WIN32) || defined (_WIN32) )
|
||||
#if (defined(WIN32) || defined (_WIN32))
|
||||
#include <process.h>
|
||||
#define getpid _getpid
|
||||
#define pidType int
|
||||
|
@ -133,11 +133,11 @@ void nsk_lvcomplain(const char file[], int line,
|
||||
char msg_buf[1024];
|
||||
nsk_context.nComplains++;
|
||||
if (!nsk_context.verbose) {
|
||||
if ( nsk_context.nComplains > NSK_MAX_COMPLAINS_NON_VERBOSE ) {
|
||||
if (nsk_context.nComplains > NSK_MAX_COMPLAINS_NON_VERBOSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( nsk_context.nComplains == NSK_MAX_COMPLAINS_NON_VERBOSE ) {
|
||||
if (nsk_context.nComplains == NSK_MAX_COMPLAINS_NON_VERBOSE) {
|
||||
nsk_printf("# ...\n"
|
||||
"# ERROR: too many complains, giving up to save disk space (CR 6341460)\n"
|
||||
"# Please rerun the test with -verbose option to listen to the entire song\n");
|
||||
|
@ -35,14 +35,14 @@ Java_nsk_stress_jni_JNIter007_incCount (JNIEnv *env, jobject jobj, jstring name)
|
||||
const char *str = env->GetStringUTFChars(name, 0); CE
|
||||
|
||||
if (env->MonitorEnter(jobj))
|
||||
printf("Error in monitor lock\n");
|
||||
printf("Error in monitor lock\n");
|
||||
clazz = env->GetObjectClass(jobj); CE
|
||||
fld = env->GetStaticFieldID(clazz, "nativeCount", "I"); CE
|
||||
value = env->GetStaticIntField(clazz, fld); CE
|
||||
env->SetStaticIntField(clazz, fld, (jint)(++value)); CE
|
||||
env->MonitorExit(jobj); CE
|
||||
if (value%1000 == 0 )
|
||||
printf("in %s Count after %u\n", str, value);
|
||||
if (value % 1000 == 0)
|
||||
printf("in %s Count after %u\n", str, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ Java_nsk_stress_strace_strace011Thread_recursiveMethod(JNIEnv *env, jobject obj)
|
||||
alltime = 0;
|
||||
GET_STATIC_BOOL_FIELD(isLocked, testClass, "isLocked");
|
||||
|
||||
while ( isLocked != JNI_TRUE )
|
||||
while (isLocked != JNI_TRUE)
|
||||
{
|
||||
MONITOR_ENTER(testField);
|
||||
CALL_VOID(testField, threadClass, "wait", Slongparam, 1LL);
|
||||
|
@ -75,35 +75,35 @@ Java_vm_mlvm_indy_func_jvmti_share_IndyRedefineClass_checkStatus(JNIEnv * pEnv,
|
||||
NSK_DISPLAY1("Single step event fired? %i\n", gIsSingleStepWorking);
|
||||
NSK_DISPLAY0("The following value should be zero for test to pass:\n");
|
||||
NSK_DISPLAY1("Any other error occured? %i\n", gIsErrorOccured);
|
||||
return gIsMethodEntryWorking && gIsSingleStepWorking && ! gIsErrorOccured;
|
||||
return gIsMethodEntryWorking && gIsSingleStepWorking && !gIsErrorOccured;
|
||||
}
|
||||
|
||||
static void popFrameLogic(jvmtiEnv * jvmti_env, jthread thread) {
|
||||
|
||||
TLSStruct * tls = (TLSStruct *) getTLS(jvmti_env, thread, sizeof(TLSStruct));
|
||||
|
||||
if ( ! tls )
|
||||
if (!tls)
|
||||
return;
|
||||
|
||||
if ( tls->countOfFramesToPop <= 0 ) {
|
||||
if (tls->countOfFramesToPop <= 0) {
|
||||
|
||||
NSK_DISPLAY0("Disabling single step\n");
|
||||
if ( ! NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)) )
|
||||
if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)))
|
||||
gIsErrorOccured = JNI_TRUE;
|
||||
|
||||
} else {
|
||||
|
||||
NSK_DISPLAY0("Enabling single step\n");
|
||||
if ( ! NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)) )
|
||||
if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)))
|
||||
gIsErrorOccured = JNI_TRUE;
|
||||
|
||||
if ( tls->countOfFramesToPop == 1 ) {
|
||||
if (tls->countOfFramesToPop == 1) {
|
||||
NSK_DISPLAY0("Popping a frame\n");
|
||||
if ( ! NSK_JVMTI_VERIFY(jvmti_env->PopFrame(thread)) )
|
||||
if (!NSK_JVMTI_VERIFY(jvmti_env->PopFrame(thread)))
|
||||
gIsErrorOccured = JNI_TRUE;
|
||||
} else {
|
||||
NSK_DISPLAY0("Forcing early return\n");
|
||||
if ( ! NSK_JVMTI_VERIFY(jvmti_env->ForceEarlyReturnVoid(thread)) )
|
||||
if (!NSK_JVMTI_VERIFY(jvmti_env->ForceEarlyReturnVoid(thread)))
|
||||
gIsErrorOccured = JNI_TRUE;
|
||||
}
|
||||
|
||||
@ -123,10 +123,10 @@ MethodEntry(jvmtiEnv *jvmti_env,
|
||||
|
||||
gIsMethodEntryWorking = JNI_TRUE;
|
||||
mn = getMethodName(jvmti_env, method);
|
||||
if ( ! mn )
|
||||
if (!mn)
|
||||
return;
|
||||
|
||||
if ( strcmp(mn->methodName, gszRedefineTriggerMethodName) != 0 ) {
|
||||
if (strcmp(mn->methodName, gszRedefineTriggerMethodName) != 0) {
|
||||
free(mn);
|
||||
return;
|
||||
}
|
||||
@ -134,17 +134,17 @@ MethodEntry(jvmtiEnv *jvmti_env,
|
||||
NSK_DISPLAY2("Entering redefine tigger method: %s.%s\n", mn->classSig, mn->methodName);
|
||||
free(mn); mn = NULL;
|
||||
|
||||
if ( gIsClassRedefined ) {
|
||||
if (gIsClassRedefined) {
|
||||
NSK_DISPLAY0("Class is already redefined.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY1("Redefining class %s\n", gszRedefinedClassFileName);
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &clazz)) )
|
||||
if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &clazz)))
|
||||
return;
|
||||
|
||||
if ( ! NSK_VERIFY(nsk_jvmti_redefineClass(jvmti_env, clazz, gszRedefinedClassFileName)) ) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_redefineClass(jvmti_env, clazz, gszRedefinedClassFileName))) {
|
||||
gIsErrorOccured = JNI_TRUE;
|
||||
return;
|
||||
}
|
||||
@ -183,13 +183,13 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) {
|
||||
jvmtiEventCallbacks callbacks;
|
||||
jvmtiCapabilities caps;
|
||||
|
||||
if ( ! NSK_VERIFY(nsk_jvmti_parseOptions(options)) )
|
||||
if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
|
||||
return JNI_ERR;
|
||||
|
||||
if ( ! NSK_VERIFY((gJvmtiEnv = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL) )
|
||||
if (!NSK_VERIFY((gJvmtiEnv = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
if ( nsk_jvmti_findOptionValue("debuggerCompatible") ) {
|
||||
if (nsk_jvmti_findOptionValue("debuggerCompatible")) {
|
||||
gIsDebuggerCompatible = JNI_TRUE;
|
||||
}
|
||||
|
||||
@ -200,20 +200,20 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) {
|
||||
caps.can_force_early_return = 1;
|
||||
caps.can_redefine_classes = 1;
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->AddCapabilities(&caps)) )
|
||||
if (!NSK_JVMTI_VERIFY(gJvmtiEnv->AddCapabilities(&caps)))
|
||||
return JNI_ERR;
|
||||
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
callbacks.MethodEntry = &MethodEntry;
|
||||
callbacks.SingleStep = &SingleStep;
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventCallbacks(&callbacks, sizeof(callbacks))) )
|
||||
if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventCallbacks(&callbacks, sizeof(callbacks))))
|
||||
return JNI_ERR;
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL) ) )
|
||||
if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL)))
|
||||
return JNI_ERR;
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL) ) )
|
||||
if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)))
|
||||
return JNI_ERR;
|
||||
|
||||
return JNI_OK;
|
||||
|
@ -63,7 +63,7 @@ Java_vm_mlvm_indy_func_jvmti_stepBreakPopReturn_INDIFY_1Test_checkStatus(JNIEnv
|
||||
NSK_DISPLAY0("The following values should be non-zero for test to pass:\n");
|
||||
NSK_DISPLAY1("Method entry event fired? %i\n", gIsMethodEntryWorking);
|
||||
NSK_DISPLAY1("Single step event fired? %i\n", gIsSingleStepWorking);
|
||||
if ( ! gIsDebuggerCompatible )
|
||||
if (!gIsDebuggerCompatible)
|
||||
NSK_DISPLAY1("Breakpoint event fired? %i\n", gIsBreakpointWorking);
|
||||
|
||||
return gIsMethodEntryWorking && !gErrorHappened && gIsSingleStepWorking
|
||||
@ -79,16 +79,16 @@ MethodEntry(jvmtiEnv *jvmti_env,
|
||||
struct MethodName * mn;
|
||||
|
||||
mn = getMethodName(jvmti_env, method);
|
||||
if ( ! mn )
|
||||
if (!mn)
|
||||
return;
|
||||
|
||||
if ( strcmp(mn->classSig, gszDebuggeeClassName) == 0 ) {
|
||||
if (strcmp(mn->classSig, gszDebuggeeClassName) == 0) {
|
||||
NSK_DISPLAY2("Entering method: %s.%s\n", mn->classSig, mn->methodName);
|
||||
|
||||
if ( strcmp(mn->methodName, gszDebuggeeMethodName) == 0 ) {
|
||||
if (strcmp(mn->methodName, gszDebuggeeMethodName) == 0) {
|
||||
gIsMethodEntryWorking = JNI_TRUE;
|
||||
|
||||
if ( ! gIsBreakpointSet )
|
||||
if (!gIsBreakpointSet)
|
||||
NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL));
|
||||
}
|
||||
}
|
||||
@ -118,8 +118,8 @@ SingleStep(jvmtiEnv *jvmti_env,
|
||||
|
||||
NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL));
|
||||
|
||||
if ( ! gIsDebuggerCompatible ) {
|
||||
if ( ! NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(method, location)) )
|
||||
if (!gIsDebuggerCompatible) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(method, location)))
|
||||
return;
|
||||
|
||||
NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL));
|
||||
@ -128,7 +128,7 @@ SingleStep(jvmtiEnv *jvmti_env,
|
||||
NSK_DISPLAY0("Pop a frame\n");
|
||||
NSK_JVMTI_VERIFY(gJvmtiEnv->PopFrame(thread));
|
||||
} else {
|
||||
if ( gIsFirstCall ) {
|
||||
if (gIsFirstCall) {
|
||||
NSK_DISPLAY0("Pop a frame\n");
|
||||
NSK_JVMTI_VERIFY(gJvmtiEnv->PopFrame(thread));
|
||||
gIsFirstCall = JNI_FALSE;
|
||||
@ -170,24 +170,24 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) {
|
||||
jvmtiEventCallbacks callbacks;
|
||||
jvmtiCapabilities caps;
|
||||
|
||||
if ( ! NSK_VERIFY(nsk_jvmti_parseOptions(options)) )
|
||||
if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
|
||||
return JNI_ERR;
|
||||
|
||||
if ( ! NSK_VERIFY((gJvmtiEnv = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL) )
|
||||
if (!NSK_VERIFY((gJvmtiEnv = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
|
||||
return JNI_ERR;
|
||||
|
||||
if ( nsk_jvmti_findOptionValue("debuggerCompatible") ) {
|
||||
if (nsk_jvmti_findOptionValue("debuggerCompatible")) {
|
||||
gIsDebuggerCompatible = JNI_TRUE;
|
||||
}
|
||||
|
||||
memset(&caps, 0, sizeof(caps));
|
||||
caps.can_generate_method_entry_events = 1;
|
||||
caps.can_generate_single_step_events = 1;
|
||||
caps.can_generate_breakpoint_events = ! gIsDebuggerCompatible;
|
||||
caps.can_generate_breakpoint_events = !gIsDebuggerCompatible;
|
||||
caps.can_pop_frame = 1;
|
||||
caps.can_force_early_return = 1;
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->AddCapabilities(&caps)) )
|
||||
if (!NSK_JVMTI_VERIFY(gJvmtiEnv->AddCapabilities(&caps)))
|
||||
return JNI_ERR;
|
||||
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
@ -195,10 +195,10 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) {
|
||||
callbacks.SingleStep = &SingleStep;
|
||||
callbacks.Breakpoint = &Breakpoint;
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventCallbacks(&callbacks, sizeof(callbacks))) )
|
||||
if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventCallbacks(&callbacks, sizeof(callbacks))))
|
||||
return JNI_ERR;
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL) ) )
|
||||
if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL)))
|
||||
return JNI_ERR;
|
||||
|
||||
return JNI_OK;
|
||||
|
@ -48,10 +48,10 @@ Java_vm_mlvm_meth_stress_jni_nativeAndMH_Test_native01(
|
||||
jobjectArray arguments;
|
||||
jobject result;
|
||||
|
||||
if ( ! NSK_JNI_VERIFY(pEnv, (mhClass = pEnv->GetObjectClass(mhToCall)) != NULL) )
|
||||
if (!NSK_JNI_VERIFY(pEnv, (mhClass = pEnv->GetObjectClass(mhToCall)) != NULL))
|
||||
return NULL;
|
||||
|
||||
if ( ! NSK_JNI_VERIFY(pEnv, NULL != (mid = pEnv->GetMethodID(mhClass, "invokeWithArguments", "([Ljava/lang/Object;)Ljava/lang/Object;"))) )
|
||||
if (!NSK_JNI_VERIFY(pEnv, NULL != (mid = pEnv->GetMethodID(mhClass, "invokeWithArguments", "([Ljava/lang/Object;)Ljava/lang/Object;"))))
|
||||
return NULL;
|
||||
|
||||
NSK_JNI_VERIFY(pEnv, NULL != (objectClass = pEnv->FindClass("java/lang/Object")));
|
||||
|
@ -36,7 +36,7 @@ void copyFromJString(JNIEnv * pEnv, jstring src, char ** dst) {
|
||||
const char * pStr;
|
||||
jsize len;
|
||||
|
||||
if ( ! NSK_VERIFY((pStr = pEnv->GetStringUTFChars(src, NULL)) != NULL) ) {
|
||||
if (!NSK_VERIFY((pStr = pEnv->GetStringUTFChars(src, NULL)) != NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -53,16 +53,16 @@ struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) {
|
||||
jclass clazz;
|
||||
struct MethodName * mn;
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodName(method, &szName, NULL, NULL)) ) {
|
||||
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodName(method, &szName, NULL, NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodDeclaringClass(method, &clazz)) ) {
|
||||
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodDeclaringClass(method, &clazz))) {
|
||||
NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szName));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(pJvmtiEnv->GetClassSignature(clazz, &szSignature, NULL)) ) {
|
||||
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetClassSignature(clazz, &szSignature, NULL))) {
|
||||
NSK_JVMTI_VERIFY(pJvmtiEnv->Deallocate((unsigned char*) szName));
|
||||
return NULL;
|
||||
}
|
||||
@ -83,7 +83,7 @@ char * locationToString(jvmtiEnv * pJvmtiEnv, jmethodID method, jlocation locati
|
||||
const char * const format = "%s .%s :" JLONG_FORMAT;
|
||||
|
||||
pMN = getMethodName(pJvmtiEnv, method);
|
||||
if ( ! pMN )
|
||||
if (!pMN)
|
||||
return strdup("NONE");
|
||||
|
||||
len = snprintf(NULL, 0, format, pMN->classSig, pMN->methodName, location) + 1;
|
||||
@ -107,16 +107,16 @@ char * locationToString(jvmtiEnv * pJvmtiEnv, jmethodID method, jlocation locati
|
||||
|
||||
void * getTLS(jvmtiEnv * pJvmtiEnv, jthread thread, jsize sizeToAllocate) {
|
||||
void * tls;
|
||||
if ( ! NSK_JVMTI_VERIFY(pJvmtiEnv->GetThreadLocalStorage(thread, &tls)) )
|
||||
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetThreadLocalStorage(thread, &tls)))
|
||||
return NULL;
|
||||
|
||||
if ( ! tls) {
|
||||
if ( ! NSK_VERIFY((tls = malloc(sizeToAllocate)) != NULL) )
|
||||
if (!tls) {
|
||||
if (!NSK_VERIFY((tls = malloc(sizeToAllocate)) != NULL))
|
||||
return NULL;
|
||||
|
||||
memset(tls, 0, sizeToAllocate);
|
||||
|
||||
if ( ! NSK_JVMTI_VERIFY(pJvmtiEnv->SetThreadLocalStorage(thread, tls)) )
|
||||
if (!NSK_JVMTI_VERIFY(pJvmtiEnv->SetThreadLocalStorage(thread, tls)))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ JNIEXPORT jboolean JNICALL Java_vm_share_ProcessUtils_sendCtrlBreak
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static BOOL (WINAPI *_MiniDumpWriteDump) ( HANDLE, DWORD, HANDLE, MINIDUMP_TYPE, PMINIDUMP_EXCEPTION_INFORMATION,
|
||||
static BOOL (WINAPI *_MiniDumpWriteDump) (HANDLE, DWORD, HANDLE, MINIDUMP_TYPE, PMINIDUMP_EXCEPTION_INFORMATION,
|
||||
PMINIDUMP_USER_STREAM_INFORMATION, PMINIDUMP_CALLBACK_INFORMATION);
|
||||
void reportLastError(const char *msg) {
|
||||
long errcode = GetLastError();
|
||||
@ -171,9 +171,10 @@ jboolean doDumpCore() {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
_MiniDumpWriteDump = (
|
||||
BOOL(WINAPI *)( HANDLE, DWORD, HANDLE, MINIDUMP_TYPE, PMINIDUMP_EXCEPTION_INFORMATION,
|
||||
PMINIDUMP_USER_STREAM_INFORMATION, PMINIDUMP_CALLBACK_INFORMATION)) GetProcAddress(dbghelp, "MiniDumpWriteDump");
|
||||
_MiniDumpWriteDump =
|
||||
(BOOL(WINAPI *)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE, PMINIDUMP_EXCEPTION_INFORMATION,
|
||||
PMINIDUMP_USER_STREAM_INFORMATION, PMINIDUMP_CALLBACK_INFORMATION))
|
||||
GetProcAddress(dbghelp, "MiniDumpWriteDump");
|
||||
|
||||
if (_MiniDumpWriteDump == NULL) {
|
||||
printf("Failed to find MiniDumpWriteDump() in module dbghelp.dll");
|
||||
|
90
test/jdk/com/sun/jdi/JdbStopThreadTest.java
Normal file
90
test/jdk/com/sun/jdi/JdbStopThreadTest.java
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8211736
|
||||
* @summary Tests that the breakpoint location and prompt are printed in the debugger output
|
||||
* when breakpoint is hit and suspend policy is set to SUSPEND_EVENT_THREAD or SUSPEND_NONE
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run compile -g JdbStopThreadTest.java
|
||||
* @run main/othervm JdbStopThreadTest
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import lib.jdb.JdbCommand;
|
||||
import lib.jdb.JdbTest;
|
||||
|
||||
class JdbStopThreadTestTarg {
|
||||
public static void main(String[] args) {
|
||||
test();
|
||||
}
|
||||
|
||||
private static void test() {
|
||||
Thread thread = Thread.currentThread();
|
||||
print(thread); // @1 breakpoint
|
||||
String str = "test";
|
||||
print(str); // @2 breakpoint
|
||||
}
|
||||
|
||||
public static void print(Object obj) {
|
||||
System.out.println(obj);
|
||||
}
|
||||
}
|
||||
|
||||
public class JdbStopThreadTest extends JdbTest {
|
||||
public static void main(String argv[]) {
|
||||
new JdbStopThreadTest().run();
|
||||
}
|
||||
|
||||
private JdbStopThreadTest() {
|
||||
super(DEBUGGEE_CLASS);
|
||||
}
|
||||
|
||||
private static final String DEBUGGEE_CLASS = JdbStopThreadTestTarg.class.getName();
|
||||
private static final String PATTERN1_TEMPLATE = "^Breakpoint hit: \"thread=main\", " +
|
||||
"JdbStopThreadTestTarg\\.test\\(\\), line=%LINE_NUMBER.*\\R%LINE_NUMBER\\s+print\\(thread\\);.*\\R>\\s";
|
||||
private static final String PATTERN2_TEMPLATE = "^Breakpoint hit: \"thread=main\", " +
|
||||
"JdbStopThreadTestTarg\\.test\\(\\), line=%LINE_NUMBER.*\\R%LINE_NUMBER\\s+print\\(str\\);.*\\R>\\s";
|
||||
|
||||
@Override
|
||||
protected void runCases() {
|
||||
// Test suspend policy SUSPEND_EVENT_THREAD
|
||||
int bpLine1 = parseBreakpoints(getTestSourcePath("JdbStopThreadTest.java"), 1).get(0);
|
||||
jdb.command(JdbCommand.stopThreadAt(DEBUGGEE_CLASS, bpLine1));
|
||||
String pattern1 = PATTERN1_TEMPLATE.replaceAll("%LINE_NUMBER", String.valueOf(bpLine1));
|
||||
// Run to breakpoint #1
|
||||
jdb.command(JdbCommand.run().waitForPrompt(pattern1, true));
|
||||
new OutputAnalyzer(jdb.getJdbOutput()).shouldMatch(pattern1);
|
||||
|
||||
|
||||
// Test suspend policy SUSPEND_NONE
|
||||
jdb.command(JdbCommand.thread(1));
|
||||
int bpLine2 = parseBreakpoints(getTestSourcePath("JdbStopThreadTest.java"), 2).get(0);
|
||||
jdb.command(JdbCommand.stopGoAt(DEBUGGEE_CLASS, bpLine2));
|
||||
String pattern2 = PATTERN2_TEMPLATE.replaceAll("%LINE_NUMBER", String.valueOf(bpLine2));
|
||||
jdb.command(JdbCommand.cont().allowExit());
|
||||
new OutputAnalyzer(jdb.getJdbOutput()).shouldMatch(pattern2);
|
||||
}
|
||||
}
|
@ -150,10 +150,11 @@ public class Jdb implements AutoCloseable {
|
||||
# i.e., the > prompt comes out AFTER the prompt we we need to wait for.
|
||||
*/
|
||||
// compile regexp once
|
||||
private final String promptPattern = "[a-zA-Z0-9_-][a-zA-Z0-9_-]*\\[[1-9][0-9]*\\] [ >]*$";
|
||||
private final Pattern promptRegexp = Pattern.compile(promptPattern);
|
||||
private final static String promptPattern = "[a-zA-Z0-9_-][a-zA-Z0-9_-]*\\[[1-9][0-9]*\\] [ >]*$";
|
||||
final static Pattern PROMPT_REGEXP = Pattern.compile(promptPattern);
|
||||
|
||||
public List<String> waitForPrompt(int lines, boolean allowExit) {
|
||||
return waitForPrompt(lines, allowExit, promptRegexp);
|
||||
return waitForPrompt(lines, allowExit, PROMPT_REGEXP);
|
||||
}
|
||||
|
||||
// jdb prompt when debuggee is not started and is not suspended after breakpoint
|
||||
@ -183,11 +184,19 @@ public class Jdb implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
List<String> reply = outputHandler.get();
|
||||
for (String line: reply.subList(Math.max(0, reply.size() - lines), reply.size())) {
|
||||
if (promptRegexp.matcher(line).find()) {
|
||||
if ((promptRegexp.flags() & Pattern.MULTILINE) > 0) {
|
||||
String replyString = reply.stream().collect(Collectors.joining(lineSeparator));
|
||||
if (promptRegexp.matcher(replyString).find()) {
|
||||
logJdb(reply);
|
||||
return outputHandler.reset();
|
||||
}
|
||||
} else {
|
||||
for (String line : reply.subList(Math.max(0, reply.size() - lines), reply.size())) {
|
||||
if (promptRegexp.matcher(line).find()) {
|
||||
logJdb(reply);
|
||||
return outputHandler.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!jdb.isAlive()) {
|
||||
// ensure we get the whole output
|
||||
@ -195,7 +204,7 @@ public class Jdb implements AutoCloseable {
|
||||
logJdb(reply);
|
||||
if (!allowExit) {
|
||||
throw new RuntimeException("waitForPrompt timed out after " + (timeout/1000)
|
||||
+ " seconds, looking for '" + promptPattern + "', in " + lines + " lines");
|
||||
+ " seconds, looking for '" + promptRegexp.pattern() + "', in " + lines + " lines");
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
@ -203,7 +212,7 @@ public class Jdb implements AutoCloseable {
|
||||
// timeout
|
||||
logJdb(outputHandler.get());
|
||||
throw new RuntimeException("waitForPrompt timed out after " + (timeout/1000)
|
||||
+ " seconds, looking for '" + promptPattern + "', in " + lines + " lines");
|
||||
+ " seconds, looking for '" + promptRegexp.pattern() + "', in " + lines + " lines");
|
||||
}
|
||||
|
||||
public List<String> command(JdbCommand cmd) {
|
||||
@ -223,7 +232,7 @@ public class Jdb implements AutoCloseable {
|
||||
throw new RuntimeException("Unexpected IO error while writing command '" + cmd.cmd + "' to jdb stdin stream");
|
||||
}
|
||||
|
||||
return waitForPrompt(1, cmd.allowExit);
|
||||
return waitForPrompt(1, cmd.allowExit, cmd.waitForPattern);
|
||||
}
|
||||
|
||||
public List<String> command(String cmd) {
|
||||
|
@ -24,6 +24,7 @@
|
||||
package lib.jdb;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -118,6 +119,8 @@ import java.util.stream.Collectors;
|
||||
public class JdbCommand {
|
||||
final String cmd;
|
||||
boolean allowExit = false;
|
||||
// Default pattern to wait for command to complete
|
||||
Pattern waitForPattern = Jdb.PROMPT_REGEXP;
|
||||
|
||||
public JdbCommand(String cmd) {
|
||||
this.cmd = cmd;
|
||||
@ -128,6 +131,11 @@ public class JdbCommand {
|
||||
return this;
|
||||
}
|
||||
|
||||
public JdbCommand waitForPrompt(String pattern, boolean isMultiline) {
|
||||
waitForPattern = Pattern.compile(pattern, isMultiline ? Pattern.MULTILINE : 0);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public static JdbCommand run(String ... params) {
|
||||
return new JdbCommand("run " + Arrays.stream(params).collect(Collectors.joining(" ")));
|
||||
@ -145,10 +153,18 @@ public class JdbCommand {
|
||||
public static JdbCommand stopAt(String targetClass, int lineNum) {
|
||||
return new JdbCommand("stop at " + targetClass + ":" + lineNum);
|
||||
}
|
||||
public static JdbCommand stopThreadAt(String targetClass, int lineNum) {
|
||||
return new JdbCommand("stop thread at " + targetClass + ":" + lineNum);
|
||||
}
|
||||
public static JdbCommand stopGoAt(String targetClass, int lineNum) {
|
||||
return new JdbCommand("stop go at " + targetClass + ":" + lineNum);
|
||||
}
|
||||
public static JdbCommand stopIn(String targetClass, String methodName) {
|
||||
return new JdbCommand("stop in " + targetClass + "." + methodName);
|
||||
}
|
||||
|
||||
public static JdbCommand thread(int threadNumber) {
|
||||
return new JdbCommand("thread " + threadNumber);
|
||||
}
|
||||
// clear <class id>:<line> -- clear a breakpoint at a line
|
||||
public static JdbCommand clear(String targetClass, int lineNum) {
|
||||
return new JdbCommand("clear " + targetClass + ":" + lineNum);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -129,22 +129,17 @@ public class TestAnonClassNames {
|
||||
static void testClassNames(List<String> classNames) {
|
||||
System.out.println("test: " + classNames);
|
||||
|
||||
List<String> options = new ArrayList<String>();
|
||||
options.add("-proc:only");
|
||||
options.add("-classpath");
|
||||
options.add(System.getProperty("test.classes"));
|
||||
|
||||
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
|
||||
JavaCompiler.CompilationTask compileTask =
|
||||
javaCompiler.getTask(null, // Output
|
||||
null, // File manager
|
||||
null, // Diagnostics
|
||||
options,
|
||||
List.of("-proc:only", // options
|
||||
"-classpath",
|
||||
System.getProperty("test.classes")),
|
||||
classNames,
|
||||
null); // Sources
|
||||
List<Processor> processors = new ArrayList<Processor>();
|
||||
processors.add(new ClassNameProber());
|
||||
compileTask.setProcessors(processors);
|
||||
compileTask.setProcessors(List.of(new ClassNameProber()));
|
||||
Boolean goodResult = compileTask.call();
|
||||
if (!goodResult) {
|
||||
error("Errors found during compile.");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -84,16 +84,12 @@ public class TypeParamBounds extends JavacTestingAbstractProcessor {
|
||||
|
||||
// The names of the bounds of each type parameter of Gen.
|
||||
static Map<String, String[]> boundNames =
|
||||
new HashMap<String, String[]>();
|
||||
|
||||
static {
|
||||
boundNames.put("T", new String[] {"Object"});
|
||||
boundNames.put("U", new String[] {"Object"});
|
||||
boundNames.put("V", new String[] {"Number"});
|
||||
boundNames.put("W", new String[] {"U"});
|
||||
boundNames.put("X", new String[] {"Runnable"});
|
||||
boundNames.put("Y", new String[] {"CharSequence", "Runnable"});
|
||||
boundNames.put("Z", new String[] {"Object", "Runnable"});
|
||||
}
|
||||
Map.of("T", new String[] {"Object"},
|
||||
"U", new String[] {"Object"},
|
||||
"V", new String[] {"Number"},
|
||||
"W", new String[] {"U"},
|
||||
"X", new String[] {"Runnable"},
|
||||
"Y", new String[] {"CharSequence", "Runnable"},
|
||||
"Z", new String[] {"Object", "Runnable"});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user