8283287: ClassLoader.c cleanups
Reviewed-by: stuefe, alanb, rriggs
This commit is contained in:
parent
0c3094c818
commit
3e58a438e9
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,16 +23,16 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "jni.h"
|
||||
#include "jni_util.h"
|
||||
#include "jlong.h"
|
||||
#include "jvm.h"
|
||||
#include "check_classname.h"
|
||||
#include "java_lang_ClassLoader.h"
|
||||
#include <string.h>
|
||||
#include "jlong.h"
|
||||
#include "jni.h"
|
||||
#include "jni_util.h"
|
||||
#include "jvm.h"
|
||||
|
||||
static JNINativeMethod methods[] = {
|
||||
{"retrieveDirectives", "()Ljava/lang/AssertionStatusDirectives;", (void *)&JVM_AssertionStatusDirectives}
|
||||
@ -88,7 +88,7 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
|
||||
|
||||
if (data == NULL) {
|
||||
JNU_ThrowNullPointerException(env, 0);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Work around 4153825. malloc crashes on Solaris when passed a
|
||||
@ -96,25 +96,27 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
|
||||
*/
|
||||
if (length < 0) {
|
||||
JNU_ThrowArrayIndexOutOfBoundsException(env, 0);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// On AIX malloc(0) returns NULL which looks like an out-of-memory condition; so adjust it to malloc(1)
|
||||
// On AIX malloc(0) returns NULL which looks like an out-of-memory
|
||||
// condition; so adjust it to malloc(1)
|
||||
#ifdef _AIX
|
||||
body = (jbyte *)malloc(length == 0 ? 1 : length);
|
||||
body = (jbyte *)malloc(length == 0 ? 1 : length);
|
||||
#else
|
||||
body = (jbyte *)malloc(length);
|
||||
body = (jbyte *)malloc(length);
|
||||
#endif
|
||||
|
||||
if (body == 0) {
|
||||
if (body == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, 0);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
(*env)->GetByteArrayRegion(env, data, offset, length, body);
|
||||
|
||||
if ((*env)->ExceptionOccurred(env))
|
||||
if ((*env)->ExceptionOccurred(env)) {
|
||||
goto free_body;
|
||||
}
|
||||
|
||||
if (name != NULL) {
|
||||
utfName = getUTF(env, name, buf, sizeof(buf));
|
||||
@ -173,9 +175,9 @@ Java_java_lang_ClassLoader_defineClass2(JNIEnv *env,
|
||||
|
||||
body = (*env)->GetDirectBufferAddress(env, data);
|
||||
|
||||
if (body == 0) {
|
||||
if (body == NULL) {
|
||||
JNU_ThrowNullPointerException(env, 0);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
body += offset;
|
||||
@ -233,7 +235,7 @@ Java_java_lang_ClassLoader_defineClass0(JNIEnv *env,
|
||||
|
||||
if (data == NULL) {
|
||||
JNU_ThrowNullPointerException(env, 0);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Work around 4153825. malloc crashes on Solaris when passed a
|
||||
@ -241,19 +243,20 @@ Java_java_lang_ClassLoader_defineClass0(JNIEnv *env,
|
||||
*/
|
||||
if (length < 0) {
|
||||
JNU_ThrowArrayIndexOutOfBoundsException(env, 0);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// On AIX malloc(0) returns NULL which looks like an out-of-memory condition; so adjust it to malloc(1)
|
||||
// On AIX malloc(0) returns NULL which looks like an out-of-memory
|
||||
// condition; so adjust it to malloc(1)
|
||||
#ifdef _AIX
|
||||
body = (jbyte *)malloc(length == 0 ? 1 : length);
|
||||
body = (jbyte *)malloc(length == 0 ? 1 : length);
|
||||
#else
|
||||
body = (jbyte *)malloc(length);
|
||||
body = (jbyte *)malloc(length);
|
||||
#endif
|
||||
|
||||
if (body == 0) {
|
||||
if (body == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, 0);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
(*env)->GetByteArrayRegion(env, data, offset, length, body);
|
||||
@ -293,7 +296,7 @@ Java_java_lang_ClassLoader_findBootstrapClass(JNIEnv *env, jclass dummy,
|
||||
char buf[128];
|
||||
|
||||
if (classname == NULL) {
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
clname = getUTF(env, classname, buf, sizeof(buf));
|
||||
@ -322,7 +325,7 @@ Java_java_lang_ClassLoader_findLoadedClass0(JNIEnv *env, jobject loader,
|
||||
jstring name)
|
||||
{
|
||||
if (name == NULL) {
|
||||
return 0;
|
||||
return NULL;
|
||||
} else {
|
||||
return JVM_FindLoadedClass(env, loader, name);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user