src/hotspot/share/prims/wbtestmethods/parserTests.cpp
author pliden
Mon, 14 May 2018 15:42:59 +0200
changeset 50102 454fa295105c
parent 49449 ef5d5d343e2a
child 54847 59ea39bb2809
permissions -rw-r--r--
8202976: Add C1 lea patching support for x86 Reviewed-by: kvn, neliasso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
     1
/*
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 47659
diff changeset
     2
 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
     4
 *
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
     8
 *
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    13
 * accompanied this code).
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    14
 *
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    18
 *
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    21
 * questions.
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    22
 *
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    23
 */
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    24
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    25
#include "precompiled.hpp"
47659
a8e9aff89f7b 8189608: Remove duplicated jni.h
ihse
parents: 47216
diff changeset
    26
#include "jni.h"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 27879
diff changeset
    27
#include "classfile/javaClasses.inline.hpp"
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    28
#include "classfile/symbolTable.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 27879
diff changeset
    29
#include "memory/oopFactory.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 29081
diff changeset
    30
#include "memory/resourceArea.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 27879
diff changeset
    31
#include "oops/objArrayOop.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49192
diff changeset
    32
#include "prims/whitebox.inline.hpp"
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    33
#include "prims/wbtestmethods/parserTests.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49192
diff changeset
    34
#include "runtime/interfaceSupport.inline.hpp"
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 47659
diff changeset
    35
#include "runtime/jniHandles.inline.hpp"
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    36
#include "services/diagnosticArgument.hpp"
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    37
#include "services/diagnosticFramework.hpp"
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    38
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    39
//There's no way of beforeahnd knowing an upper size
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    40
//Of the length of a string representation of
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    41
//the value of an argument.
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    42
#define VALUE_MAXLEN 256
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    43
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    44
// DiagnosticFramework test utility methods
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    45
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    46
/*
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    47
 * The DiagnosticArgumentType class contains an enum that says which type
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    48
 * this argument represents. (JLONG, BOOLEAN etc).
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    49
 * This method Returns a char* representation of that enum value.
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    50
 */
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    51
static const char* lookup_diagnosticArgumentEnum(const char* field_name, oop object) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    52
  Thread* THREAD = Thread::current();
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    53
  const char* enum_sig = "Lsun/hotspot/parser/DiagnosticCommand$DiagnosticArgumentType;";
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    54
  TempNewSymbol enumSigSymbol = SymbolTable::lookup(enum_sig, (int) strlen(enum_sig), THREAD);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    55
  int offset = WhiteBox::offset_for_field(field_name, object, enumSigSymbol);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    56
  oop enumOop = object->obj_field(offset);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    57
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    58
  const char* ret = WhiteBox::lookup_jstring("name", enumOop);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    59
  return ret;
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    60
}
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    61
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    62
/*
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    63
 * Takes an oop to a DiagnosticArgumentType-instance and
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    64
 * reads the fields from it. Fills an native DCmdParser with
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    65
 * this info.
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    66
 */
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    67
static void fill_in_parser(DCmdParser* parser, oop argument)
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    68
{
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    69
  const char* name = WhiteBox::lookup_jstring("name", argument);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    70
  const char* desc = WhiteBox::lookup_jstring("desc", argument);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    71
  const char* default_value = WhiteBox::lookup_jstring("defaultValue", argument);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    72
  bool mandatory = WhiteBox::lookup_bool("mandatory", argument);
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    73
  bool isarg = WhiteBox::lookup_bool("argument", argument);
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    74
  const char*  type = lookup_diagnosticArgumentEnum("type", argument);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    75
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    76
   if (strcmp(type, "STRING") == 0) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    77
     DCmdArgument<char*>* argument = new DCmdArgument<char*>(
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    78
     name, desc,
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    79
     "STRING", mandatory, default_value);
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    80
     if (isarg) {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    81
      parser->add_dcmd_argument(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    82
     } else {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    83
      parser->add_dcmd_option(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    84
     }
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    85
   } else if (strcmp(type, "NANOTIME") == 0) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    86
     DCmdArgument<NanoTimeArgument>* argument = new DCmdArgument<NanoTimeArgument>(
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    87
     name, desc,
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    88
     "NANOTIME", mandatory, default_value);
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    89
     if (isarg) {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    90
      parser->add_dcmd_argument(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    91
     } else {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    92
      parser->add_dcmd_option(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    93
     }
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    94
   } else if (strcmp(type, "JLONG") == 0) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    95
     DCmdArgument<jlong>* argument = new DCmdArgument<jlong>(
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    96
     name, desc,
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
    97
     "JLONG", mandatory, default_value);
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    98
     if (isarg) {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
    99
      parser->add_dcmd_argument(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   100
     } else {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   101
      parser->add_dcmd_option(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   102
     }
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   103
   } else if (strcmp(type, "BOOLEAN") == 0) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   104
     DCmdArgument<bool>* argument = new DCmdArgument<bool>(
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   105
     name, desc,
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   106
     "BOOLEAN", mandatory, default_value);
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   107
     if (isarg) {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   108
      parser->add_dcmd_argument(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   109
     } else {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   110
      parser->add_dcmd_option(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   111
     }
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   112
   } else if (strcmp(type, "MEMORYSIZE") == 0) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   113
     DCmdArgument<MemorySizeArgument>* argument = new DCmdArgument<MemorySizeArgument>(
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   114
     name, desc,
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   115
     "MEMORY SIZE", mandatory, default_value);
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   116
     if (isarg) {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   117
      parser->add_dcmd_argument(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   118
     } else {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   119
      parser->add_dcmd_option(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   120
     }
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   121
   } else if (strcmp(type, "STRINGARRAY") == 0) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   122
     DCmdArgument<StringArrayArgument*>* argument = new DCmdArgument<StringArrayArgument*>(
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   123
     name, desc,
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   124
     "STRING SET", mandatory);
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   125
     if (isarg) {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   126
      parser->add_dcmd_argument(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   127
     } else {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   128
      parser->add_dcmd_option(argument);
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   129
     }
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   130
   }
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   131
}
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   132
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   133
/*
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   134
 * Will Fill in a java object array with alternating names of parsed command line options and
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   135
 * the value that has been parsed for it:
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   136
 * { name, value, name, value ... }
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   137
 * This can then be checked from java.
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   138
 */
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   139
WB_ENTRY(jobjectArray, WB_ParseCommandLine(JNIEnv* env, jobject o, jstring j_cmdline, jchar j_delim, jobjectArray arguments))
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   140
  ResourceMark rm;
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   141
  DCmdParser parser;
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   142
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   143
  const char* c_cmdline = java_lang_String::as_utf8_string(JNIHandles::resolve(j_cmdline));
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   144
  const char c_delim = j_delim & 0xff;
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   145
  objArrayOop argumentArray = objArrayOop(JNIHandles::resolve_non_null(arguments));
20368
c6a566a70b59 8025570: Naked oop in test/serviceability/ParserTest
coleenp
parents: 13728
diff changeset
   146
  objArrayHandle argumentArray_ah(THREAD, argumentArray);
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   147
20368
c6a566a70b59 8025570: Naked oop in test/serviceability/ParserTest
coleenp
parents: 13728
diff changeset
   148
  int length = argumentArray_ah->length();
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   149
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   150
  for (int i = 0; i < length; i++) {
20368
c6a566a70b59 8025570: Naked oop in test/serviceability/ParserTest
coleenp
parents: 13728
diff changeset
   151
    oop argument_oop = argumentArray_ah->obj_at(i);
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   152
    fill_in_parser(&parser, argument_oop);
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   153
  }
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   154
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   155
  CmdLine cmdline(c_cmdline, strlen(c_cmdline), true);
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   156
  parser.parse(&cmdline,c_delim,CHECK_NULL);
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   157
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12262
diff changeset
   158
  Klass* k = SystemDictionary::Object_klass();
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   159
  objArrayOop returnvalue_array = oopFactory::new_objArray(k, parser.num_arguments() * 2, CHECK_NULL);
20368
c6a566a70b59 8025570: Naked oop in test/serviceability/ParserTest
coleenp
parents: 13728
diff changeset
   160
  objArrayHandle returnvalue_array_ah(THREAD, returnvalue_array);
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   161
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   162
  GrowableArray<const char *>*parsedArgNames = parser.argument_name_array();
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   163
  GenDCmdArgument* arglist = parser.arguments_list();
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   164
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   165
  for (int i = 0; i < parser.num_arguments(); i++) {
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   166
    oop parsedName = java_lang_String::create_oop_from_str(parsedArgNames->at(i), CHECK_NULL);
20368
c6a566a70b59 8025570: Naked oop in test/serviceability/ParserTest
coleenp
parents: 13728
diff changeset
   167
    returnvalue_array_ah->obj_at_put(i*2, parsedName);
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   168
    GenDCmdArgument* arg = parser.lookup_dcmd_option(parsedArgNames->at(i), strlen(parsedArgNames->at(i)));
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   169
    if (!arg) {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   170
      arg = arglist;
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   171
      arglist = arglist->next();
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   172
    }
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   173
    char buf[VALUE_MAXLEN];
27879
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   174
    if (arg) {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   175
      arg->value_as_str(buf, sizeof(buf));
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   176
    } else {
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   177
      sprintf(buf, "<null>");
419385282044 8065783: DCMD parser fails to recognize one character argument when it's positioned last
jbachorik
parents: 20368
diff changeset
   178
    }
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   179
    oop parsedValue = java_lang_String::create_oop_from_str(buf, CHECK_NULL);
20368
c6a566a70b59 8025570: Naked oop in test/serviceability/ParserTest
coleenp
parents: 13728
diff changeset
   180
    returnvalue_array_ah->obj_at_put(i*2+1, parsedValue);
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   181
  }
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   182
20368
c6a566a70b59 8025570: Naked oop in test/serviceability/ParserTest
coleenp
parents: 13728
diff changeset
   183
  return (jobjectArray) JNIHandles::make_local(returnvalue_array_ah());
12262
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   184
fb3b9fede660 7148488: Whitebox tests for the Diagnostic Framework Parser
nloodin
parents:
diff changeset
   185
WB_END