< prev index next >

src/jdk.jdwp.agent/share/native/libjdwp/transport.c

Print this page
rev 50999 : 8207233: Minor improvements of jdk C-coding
   1 /*
   2  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 194     /* Find the onLoad address */
 195     onLoad = findTransportOnLoad(handle);
 196     if (onLoad == NULL) {
 197         ERROR_MESSAGE(("transport library missing onLoad entry: %s", name));
 198         return JDWP_ERROR(TRANSPORT_LOAD);
 199     }
 200 
 201     /* Get transport interface */
 202     env = getEnv();
 203     if (env != NULL) {
 204         jdwpTransportEnv *t = NULL;
 205         JavaVM           *jvm = NULL;
 206         jint              rc;
 207         size_t            i;
 208         /* If a new version is added here, update 'case JNI_EVERSION' below. */
 209         jint supported_versions[2] = {JDWPTRANSPORT_VERSION_1_1, JDWPTRANSPORT_VERSION_1_0};
 210 
 211         JNI_FUNC_PTR(env,GetJavaVM)(env, &jvm);
 212 
 213         /* Try version 1.1 first, fallback to 1.0 on error */
 214         for (i = 0; i < sizeof(supported_versions); ++i) {
 215             rc = (*onLoad)(jvm, &callback, supported_versions[i], &t);
 216             if (rc != JNI_EVERSION) {
 217                 info->transportVersion = supported_versions[i];
 218                 break;
 219             }
 220         }
 221 
 222         if (rc != JNI_OK) {
 223             switch (rc) {
 224                 case JNI_ENOMEM :
 225                     ERROR_MESSAGE(("insufficient memory to complete initialization"));
 226                     break;
 227 
 228                 case JNI_EVERSION :
 229                     ERROR_MESSAGE(("transport doesn't recognize all supported versions: "
 230                                    "{ 1_1, 1_0 }"));
 231                     break;
 232 
 233                 case JNI_EEXIST :
 234                     ERROR_MESSAGE(("transport doesn't support multiple environments"));


   1 /*
   2  * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 194     /* Find the onLoad address */
 195     onLoad = findTransportOnLoad(handle);
 196     if (onLoad == NULL) {
 197         ERROR_MESSAGE(("transport library missing onLoad entry: %s", name));
 198         return JDWP_ERROR(TRANSPORT_LOAD);
 199     }
 200 
 201     /* Get transport interface */
 202     env = getEnv();
 203     if (env != NULL) {
 204         jdwpTransportEnv *t = NULL;
 205         JavaVM           *jvm = NULL;
 206         jint              rc;
 207         size_t            i;
 208         /* If a new version is added here, update 'case JNI_EVERSION' below. */
 209         jint supported_versions[2] = {JDWPTRANSPORT_VERSION_1_1, JDWPTRANSPORT_VERSION_1_0};
 210 
 211         JNI_FUNC_PTR(env,GetJavaVM)(env, &jvm);
 212 
 213         /* Try version 1.1 first, fallback to 1.0 on error */
 214         for (i = 0; i < sizeof(supported_versions)/sizeof(jint); ++i) {
 215             rc = (*onLoad)(jvm, &callback, supported_versions[i], &t);
 216             if (rc != JNI_EVERSION) {
 217                 info->transportVersion = supported_versions[i];
 218                 break;
 219             }
 220         }
 221 
 222         if (rc != JNI_OK) {
 223             switch (rc) {
 224                 case JNI_ENOMEM :
 225                     ERROR_MESSAGE(("insufficient memory to complete initialization"));
 226                     break;
 227 
 228                 case JNI_EVERSION :
 229                     ERROR_MESSAGE(("transport doesn't recognize all supported versions: "
 230                                    "{ 1_1, 1_0 }"));
 231                     break;
 232 
 233                 case JNI_EEXIST :
 234                     ERROR_MESSAGE(("transport doesn't support multiple environments"));


< prev index next >