/*
* 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
class VMConnection {
private final int traceFlags;
synchronized void notifyOutputComplete() {
notifyAll();
}
synchronized void waitOutputComplete() {
// Wait for stderr and stdout
while (outputCompleteCount < 2) {
try {wait();} catch (InterruptedException e) {}
}
}
}
return connector;
}
}
return null;
}
private Map <String, com.sun.jdi.connect.Connector.Argument> parseConnectorArgs(Connector connector, String argString) {
/*
* We are parsing strings of the form:
* name1=value1,[name2=value2,...]
* However, the value1...valuen substrings may contain
* embedded comma(s), so make provision for quoting inside
* the value substrings. (Bug ID 4285874)
*/
"(quote=[^,]+,)|" + // special case for quote=.,
"(\\w+=)" + // name=
"(((\"[^\"]*\")|" + // ( "l , ue"
"('[^']*')|" + // 'l , ue'
"([^,'\"]+))+,)"; // v a l u e )+ ,
while (m.find()) {
int startPosition = m.start();
int endPosition = m.end();
if (startPosition > 0) {
/*
* It is an error if parsing skips over any part of argString.
*/
throw new IllegalArgumentException
argString));
}
/*
* strip off enclosing quote chars
* needed for quote enclosed delimited substrings
*/
}
}
}
throw new IllegalArgumentException
}
}
/*
* It is an error if any part of argString is left over,
* unless it was empty to begin with.
*/
throw new IllegalArgumentException
}
return arguments;
}
return true;
}
}
return false;
}
private static List<String> splitStringAtNonEnclosedWhiteSpace(String value) throws IllegalArgumentException {
char[] arr;
int startPosition = 0;
int endPosition = 0;
final char SPACE = ' ';
final char DOUBLEQ = '"';
final char SINGLEQ = '\'';
/*
* An "open" or "active" enclosing state is where
* the first valid start quote qualifier is found,
* and there is a search in progress for the
* relevant end matching quote
*
* enclosingTargetChar set to SPACE
* is used to signal a non open enclosing state
*/
char enclosingTargetChar = SPACE;
throw new IllegalArgumentException
}
// split parameter string into individual chars
switch (arr[i]) {
case SPACE: {
// do nothing for spaces
// unless last in array
if (isLastChar(arr, i)) {
endPosition = i;
// break for substring creation
break;
}
continue;
}
case DOUBLEQ:
case SINGLEQ: {
if (enclosingTargetChar == arr[i]) {
// potential match to close open enclosing
if (isNextCharWhitespace(arr, i)) {
// if peek next is whitespace
// then enclosing is a valid substring
endPosition = i;
// reset enclosing target char
// break for substring creation
break;
}
}
if (enclosingTargetChar == SPACE) {
// no open enclosing state
// handle as normal char
if (isPreviousCharWhitespace(arr, i)) {
startPosition = i;
// peek forward for end candidates
// set open enclosing state by
// setting up the target char
enclosingTargetChar = arr[i];
} else {
// no more target chars left to match
// end enclosing, handle as normal char
if (isNextCharWhitespace(arr, i)) {
endPosition = i;
// break for substring creation
break;
}
}
}
}
continue;
}
default: {
// normal non-space, non-" and non-' chars
if (enclosingTargetChar == SPACE) {
// no open enclosing state
if (isPreviousCharWhitespace(arr, i)) {
// start of space delim substring
startPosition = i;
}
if (isNextCharWhitespace(arr, i)) {
// end of space delim substring
endPosition = i;
// break for substring creation
break;
}
}
continue;
}
}
// break's end up here
if (startPosition > endPosition) {
throw new IllegalArgumentException
}
// extract substring and add to List<String>
// set new start position
i = startPosition = endPosition;
} // for loop
return al;
}
}
}
// outside arraybounds is considered an implicit space
return true;
}
return true;
}
return false;
}
}
if (index == -1) {
argString = "";
} else {
}
throw new IllegalArgumentException
}
this.traceFlags = traceFlags;
}
if (connector instanceof LaunchingConnector) {
vm = launchTarget();
} else if (connector instanceof AttachingConnector) {
vm = attachTarget();
} else if (connector instanceof ListeningConnector) {
vm = listenTarget();
} else {
throw new InternalError
}
if (vm.canBeModified()){
}
/*
* Now that the vm connection is open, fetch the debugee
* classpath and set up a default sourcepath.
* (Unless user supplied a sourcepath on the command line)
* (Bug ID 4186582)
*/
if (vm instanceof PathSearchingVirtualMachine) {
} else {
}
}
return vm;
}
/*
* Too late if the connection already made
*/
return false;
}
return false;
}
return true;
}
return "";
}
}
throw new VMNotConnectedException();
} else {
return vm;
}
}
boolean isOpen() {
}
boolean isLaunch() {
return (connector instanceof LaunchingConnector);
}
public void disposeVM() {
try {
}
} finally {
}
}
}
// Normally, we want all uncaught exceptions. We request them
// via the same mechanism as Commands.commandCatchException()
// so the user can ignore them later if they are not
// interested.
// FIXME: this works but generates spurious messages on stdout
// during startup:
// Set uncaught java.lang.Throwable
// Set deferred uncaught java.lang.Throwable
(new StringTokenizer("uncaught java.lang.Throwable"));
}
private void resolveEventRequests() {
}
int i;
try {
// printDirect()
}
} catch (IOException ex) {
if (!s.startsWith("Bad file number")) {
throw ex;
}
// else we got a Bad file number IOException which just means
// that the debuggee has gone away. We'll just treat it the
// same as if we got an EOF.
}
}
/**
* Create a Thread that will retrieve and display any output.
* Needs to be high priority, else debugger may exit before
* it can be displayed.
*/
public void run() {
try {
} catch (IOException ex) {
} finally {
}
}
};
}
try {
} catch (IOException e) {
e.getMessage());
}
}
/* launch child target vm */
try {
return vm;
} catch (IOException ioe) {
} catch (IllegalConnectorArgumentsException icae) {
} catch (VMStartException vmse) {
}
return null; // Shuts up the compiler
}
/* attach to running target vm */
try {
} catch (IOException ioe) {
} catch (IllegalConnectorArgumentsException icae) {
}
return null; // Shuts up the compiler
}
/* listen for connection from target vm */
try {
return vm;
} catch (IOException ioe) {
} catch (IllegalConnectorArgumentsException icae) {
}
return null; // Shuts up the compiler
}
}