/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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 4997445
* @summary Test that with server=y, when VM runs to System.exit() no error happens
*
* @build VMConnection RunToExit Exit0
*/
public class RunToExit {
/* Increment this when ERROR: seen */
static volatile boolean ready = false;
/*
* Helper class to direct process output to a StringBuffer
*/
this.buffer = new StringBuffer();
}
}
public void run() {
try {
byte b[] = new byte[100];
for (;;) {
// The first thing that will get read is
// Listening for transport dt_socket at address: xxxxx
// which shows the debuggee is ready to accept connections.
ready = true;
if (n < 0) {
break;
}
}
} catch (IOException ioe) { }
error_seen++;
}
}
}
/*
* Find a connector by name
*/
return connector;
}
}
return null;
}
/*
* Launch a server debuggee with the given address
*/
} else {
exe += "java";
}
" -agentlib:jdwp=transport=dt_socket" +
" " + class_name;
return p;
}
/*
* - pick a TCP port
* - Launch a server debuggee: server=y,suspend=y,address=${port}
* - run it to VM death
* - verify we saw no error
*/
// find a free port
// launch the server debuggee
// wait for the debugge to be ready
while (!ready) {
try {
throw ee;
}
}
// attach to server debuggee and resume it so it can exit
// The first event is always a VMStartEvent, and it is always in
// an EventSet by itself. Wait for it.
if (event instanceof VMStartEvent) {
break;
}
throw new RuntimeException("Test failed - debuggee did not start properly");
}
// if the server debuggee ran cleanly, we assume we were clean
} else {
throw new RuntimeException("Test failed - server debuggee generated an error when it terminated");
}
}
}