/* * Copyright (c) 1998, 2017, 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. 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.
*/
/* * Read a module from the stream. The ID used in the wire protocol * is converted to a reference which is returned. The reference is * global and strong, but it should *not* be deleted by the caller * since it is freed when this stream is destroyed.
*/
jobject
inStream_readModuleRef(JNIEnv *env, PacketInputStream *stream)
{
jobject ref = inStream_readObjectRef(env, stream); if (ref == NULL && stream->error == JDWP_ERROR(INVALID_OBJECT)) {
stream->error = JDWP_ERROR(INVALID_MODULE); return NULL;
}
return ref;
}
/* * Read an object from the stream. The ID used in the wire protocol * is converted to a reference which is returned. The reference is * global and strong, but it should *not* be deleted by the caller * since it is freed when this stream is destroyed.
*/
jobject
inStream_readObjectRef(JNIEnv *env, PacketInputStream *stream)
{
jobject ref;
jobject *refPtr;
jlong id = inStream_readLong(stream); if (stream->error) { return NULL;
} if (id == NULL_OBJECT_ID) { return NULL;
}
/* * Read a raw object id from the stream. This should be used rarely. * Normally, inStream_readObjectRef is preferred since it takes care * of reference conversion and tracking. Only code that needs to * perform maintence of the commonRef hash table uses this function.
*/
jlong
inStream_readObjectID(PacketInputStream *stream)
{ return inStream_readLong(stream);
}
jclass
inStream_readClassRef(JNIEnv *env, PacketInputStream *stream)
{
jobject object = inStream_readObjectRef(env, stream); if (object == NULL) { /* * Could be error or just the null reference. In either case, * stop now.
*/ return NULL;
} if (!isClass(object)) {
stream->error = JDWP_ERROR(INVALID_CLASS); return NULL;
} return object;
}
jthread
inStream_readThreadRef(JNIEnv *env, PacketInputStream *stream)
{
jobject object = inStream_readObjectRef(env, stream); if (object == NULL) { /* * Could be error or just the null reference. In either case, * stop now.
*/ return NULL;
} if (!isThread(object)) {
stream->error = JDWP_ERROR(INVALID_THREAD); return NULL;
} return object;
}
jthreadGroup
inStream_readThreadGroupRef(JNIEnv *env, PacketInputStream *stream)
{
jobject object = inStream_readObjectRef(env, stream); if (object == NULL) { /* * Could be error or just the null reference. In either case, * stop now.
*/ return NULL;
} if (!isThreadGroup(object)) {
stream->error = JDWP_ERROR(INVALID_THREAD_GROUP); return NULL;
} return object;
}
jstring
inStream_readStringRef(JNIEnv *env, PacketInputStream *stream)
{
jobject object = inStream_readObjectRef(env, stream); if (object == NULL) { /* * Could be error or just the null reference. In either case, * stop now.
*/ return NULL;
} if (!isString(object)) {
stream->error = JDWP_ERROR(INVALID_STRING); return NULL;
} return object;
}
jclass
inStream_readClassLoaderRef(JNIEnv *env, PacketInputStream *stream)
{
jobject object = inStream_readObjectRef(env, stream); if (object == NULL) { /* * Could be error or just the null reference. In either case, * stop now.
*/ return NULL;
} if (!isClassLoader(object)) {
stream->error = JDWP_ERROR(INVALID_CLASS_LOADER); return NULL;
} return object;
}
jarray
inStream_readArrayRef(JNIEnv *env, PacketInputStream *stream)
{
jobject object = inStream_readObjectRef(env, stream); if (object == NULL) { /* * Could be error or just the null reference. In either case, * stop now.
*/ return NULL;
} if (!isArray(object)) {
stream->error = JDWP_ERROR(INVALID_ARRAY); return NULL;
} return object;
}
/* * Next 3 functions read an Int and convert to a Pointer!? * If sizeof(jxxxID) == 8 we must read these values as Longs.
*/
FrameID
inStream_readFrameID(PacketInputStream *stream)
{ if (sizeof(FrameID) == 8) { /*LINTED*/ return (FrameID)inStream_readLong(stream);
} else { /*LINTED*/ return (FrameID)inStream_readInt(stream);
}
}
/* This is Standard UTF-8, convert to Modified UTF-8 if necessary */
new_length = utf8sToUtf8mLength((jbyte*)string, length); if ( new_length != length ) { char *new_string;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.