134 set_value(0);
135 }
136 }
137
138 template <> void DCmdArgument<jlong>::destroy_value() { }
139
140 template <> void DCmdArgument<bool>::parse_value(const char* str,
141 size_t len, TRAPS) {
142 // len is the length of the current token starting at str
143 if (len == 0) {
144 set_value(true);
145 } else {
146 if (len == strlen("true") && strncasecmp(str, "true", len) == 0) {
147 set_value(true);
148 } else if (len == strlen("false") && strncasecmp(str, "false", len) == 0) {
149 set_value(false);
150 } else {
151 ResourceMark rm;
152
153 char* buf = NEW_RESOURCE_ARRAY(char, len + 1);
154 strncpy(buf, str, len);
155 buf[len] = '\0';
156 Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(),
157 "Boolean parsing error in command argument '%s'. Could not parse: %s.\n", _name, buf);
158 }
159 }
160 }
161
162 template <> void DCmdArgument<bool>::init_value(TRAPS) {
163 if (has_default()) {
164 this->parse_value(_default_string, strlen(_default_string), THREAD);
165 if (HAS_PENDING_EXCEPTION) {
166 fatal("Default string must be parsable");
167 }
168 } else {
169 set_value(false);
170 }
171 }
172
173 template <> void DCmdArgument<bool>::destroy_value() { }
174
175 template <> void DCmdArgument<char*>::parse_value(const char* str,
|
134 set_value(0);
135 }
136 }
137
138 template <> void DCmdArgument<jlong>::destroy_value() { }
139
140 template <> void DCmdArgument<bool>::parse_value(const char* str,
141 size_t len, TRAPS) {
142 // len is the length of the current token starting at str
143 if (len == 0) {
144 set_value(true);
145 } else {
146 if (len == strlen("true") && strncasecmp(str, "true", len) == 0) {
147 set_value(true);
148 } else if (len == strlen("false") && strncasecmp(str, "false", len) == 0) {
149 set_value(false);
150 } else {
151 ResourceMark rm;
152
153 char* buf = NEW_RESOURCE_ARRAY(char, len + 1);
154 strncpy(buf, str, len + 1);
155 Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(),
156 "Boolean parsing error in command argument '%s'. Could not parse: %s.\n", _name, buf);
157 }
158 }
159 }
160
161 template <> void DCmdArgument<bool>::init_value(TRAPS) {
162 if (has_default()) {
163 this->parse_value(_default_string, strlen(_default_string), THREAD);
164 if (HAS_PENDING_EXCEPTION) {
165 fatal("Default string must be parsable");
166 }
167 } else {
168 set_value(false);
169 }
170 }
171
172 template <> void DCmdArgument<bool>::destroy_value() { }
173
174 template <> void DCmdArgument<char*>::parse_value(const char* str,
|