1 /* src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.cpp
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 #include "native/jni.h"
31 #include "native/llni.h"
32 #include "native/native.h"
34 #if defined(ENABLE_JNI_HEADERS)
35 # include "native/vm/include/gnu_java_lang_VMCPStringBuilder.h"
38 #include "vm/builtin.h"
39 #include "vm/exceptions.hpp"
40 #include "vm/globals.hpp"
41 #include "vm/javaobjects.hpp"
45 * Class: gnu/java/lang/VMCPStringBuilder
47 * Signature: ([CII)Ljava/lang/String;
49 JNIEXPORT jstring JNICALL Java_gnu_java_lang_VMCPStringBuilder_toString(JNIEnv *env, jclass clazz, jcharArray value, jint startIndex, jint count)
51 /* This is a native version of
52 java.lang.String.<init>([CIIZ)Ljava/lang/String; */
55 /* exceptions_throw_stringindexoutofboundsexception("offset: " + offset); */
56 exceptions_throw_stringindexoutofboundsexception();
61 /* exceptions_throw_stringindexoutofboundsexception("count: " + count); */
62 exceptions_throw_stringindexoutofboundsexception();
66 /* equivalent to: offset + count < 0 || offset + count > data.length */
68 java_handle_chararray_t* ca = (java_handle_chararray_t*) value;
71 int32_t length = LLNI_array_size(ca);
74 if (length - startIndex < count) {
75 /* exceptions_throw_stringindexoutofboundsexception("offset + count: " + (offset + count)); */
76 exceptions_throw_stringindexoutofboundsexception();
80 java_handle_t* h = builtin_new(class_java_lang_String);
85 java_lang_String s(h, ca, (int32_t) count, (int32_t) startIndex);
87 return (jstring) s.get_handle();
91 /* native methods implemented by this file ************************************/
93 static JNINativeMethod methods[] = {
94 { (char*) "toString", (char*) "([CII)Ljava/lang/String;", (void*) (uintptr_t) &Java_gnu_java_lang_VMCPStringBuilder_toString },
98 /* _Jv_gnu_java_lang_VMCPStringBuilder *****************************************
100 Register native functions.
102 *******************************************************************************/
106 void _Jv_gnu_java_lang_VMCPStringBuilder_init(void)
110 u = utf_new_char("gnu/java/lang/VMCPStringBuilder");
112 native_method_register(u, methods, NATIVE_METHODS_COUNT);
118 * These are local overrides for various environment variables in Emacs.
119 * Please do not remove this and leave it at the end of the file, where
120 * Emacs will automagically detect them.
121 * ---------------------------------------------------------------------
124 * indent-tabs-mode: t