1 /*
2 * Copyright (c) 1996, 2013, 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
207 utfSource = getUTF(env, source, sourceBuf, sizeof(sourceBuf));
208 if (utfSource == NULL) {
209 JNU_ThrowOutOfMemoryError(env, NULL);
210 goto free_utfName;
211 }
212 } else {
213 utfSource = NULL;
214 }
215 result = JVM_DefineClassWithSource(env, utfName, loader, body, length, pd, utfSource);
216
217 if (utfSource && utfSource != sourceBuf)
218 free(utfSource);
219
220 free_utfName:
221 if (utfName && utfName != buf)
222 free(utfName);
223
224 return result;
225 }
226
227 JNIEXPORT void JNICALL
228 Java_java_lang_ClassLoader_resolveClass0(JNIEnv *env, jobject this,
229 jclass cls)
230 {
231 if (cls == NULL) {
232 JNU_ThrowNullPointerException(env, 0);
233 return;
234 }
235
236 JVM_ResolveClass(env, cls);
237 }
238
239 /*
240 * Returns NULL if class not found.
241 */
242 JNIEXPORT jclass JNICALL
243 Java_java_lang_ClassLoader_findBootstrapClass(JNIEnv *env, jobject loader,
244 jstring classname)
245 {
246 char *clname;
247 jclass cls = 0;
248 char buf[128];
249
250 if (classname == NULL) {
251 return 0;
252 }
253
254 clname = getUTF(env, classname, buf, sizeof(buf));
255 if (clname == NULL) {
256 JNU_ThrowOutOfMemoryError(env, NULL);
257 return NULL;
258 }
|
1 /*
2 * Copyright (c) 1996, 2014, 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
207 utfSource = getUTF(env, source, sourceBuf, sizeof(sourceBuf));
208 if (utfSource == NULL) {
209 JNU_ThrowOutOfMemoryError(env, NULL);
210 goto free_utfName;
211 }
212 } else {
213 utfSource = NULL;
214 }
215 result = JVM_DefineClassWithSource(env, utfName, loader, body, length, pd, utfSource);
216
217 if (utfSource && utfSource != sourceBuf)
218 free(utfSource);
219
220 free_utfName:
221 if (utfName && utfName != buf)
222 free(utfName);
223
224 return result;
225 }
226
227 /*
228 * Returns NULL if class not found.
229 */
230 JNIEXPORT jclass JNICALL
231 Java_java_lang_ClassLoader_findBootstrapClass(JNIEnv *env, jobject loader,
232 jstring classname)
233 {
234 char *clname;
235 jclass cls = 0;
236 char buf[128];
237
238 if (classname == NULL) {
239 return 0;
240 }
241
242 clname = getUTF(env, classname, buf, sizeof(buf));
243 if (clname == NULL) {
244 JNU_ThrowOutOfMemoryError(env, NULL);
245 return NULL;
246 }
|