Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/misc/URLClassPath.c
38829 views
/*1* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include <string.h>2627#include "jni.h"28#include "jni_util.h"29#include "jlong.h"30#include "jvm.h"31#include "jdk_util.h"3233#include "sun_misc_URLClassPath.h"3435extern char*36getUTF(JNIEnv *env, jstring str, char* localBuf, int bufSize);373839JNIEXPORT jboolean JNICALL40Java_sun_misc_URLClassPath_knownToNotExist0(JNIEnv *env, jclass cls, jobject loader,41jstring classname)42{43char *clname;44jboolean result = JNI_FALSE;45char buf[128];4647if (classname == NULL) {48JNU_ThrowNullPointerException(env, NULL);49return result;50}5152clname = getUTF(env, classname, buf, sizeof(buf));53if (clname == NULL) {54// getUTF() throws OOME before returning NULL, no need to throw OOME here55return result;56}57VerifyFixClassname(clname);5859if (!VerifyClassname(clname, JNI_TRUE)) { /* expects slashed name */60goto done;61}6263result = JVM_KnownToNotExist(env, loader, clname);6465done:66if (clname != buf) {67free(clname);68}6970return result;71}7273JNIEXPORT jobjectArray JNICALL74Java_sun_misc_URLClassPath_getLookupCacheURLs(JNIEnv *env, jclass cls, jobject loader)75{76return JVM_GetResourceLookupCacheURLs(env, loader);77}787980JNIEXPORT jintArray JNICALL81Java_sun_misc_URLClassPath_getLookupCacheForClassLoader(JNIEnv *env, jclass cls,82jobject loader,83jstring resource_name)84{85char *resname;86jintArray result = NULL;87char buf[128];8889if (resource_name == NULL) {90JNU_ThrowNullPointerException(env, NULL);91return result;92}9394resname = getUTF(env, resource_name, buf, sizeof(buf));95if (resname == NULL) {96// getUTF() throws OOME before returning NULL, no need to throw OOME here97return result;98}99result = JVM_GetResourceLookupCache(env, loader, resname);100101done:102if (resname != buf) {103free(resname);104}105106return result;107}108109110111