Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/misc/URLClassPath.c
38829 views
1
/*
2
* Copyright (c) 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
23
* questions.
24
*/
25
26
#include <string.h>
27
28
#include "jni.h"
29
#include "jni_util.h"
30
#include "jlong.h"
31
#include "jvm.h"
32
#include "jdk_util.h"
33
34
#include "sun_misc_URLClassPath.h"
35
36
extern char*
37
getUTF(JNIEnv *env, jstring str, char* localBuf, int bufSize);
38
39
40
JNIEXPORT jboolean JNICALL
41
Java_sun_misc_URLClassPath_knownToNotExist0(JNIEnv *env, jclass cls, jobject loader,
42
jstring classname)
43
{
44
char *clname;
45
jboolean result = JNI_FALSE;
46
char buf[128];
47
48
if (classname == NULL) {
49
JNU_ThrowNullPointerException(env, NULL);
50
return result;
51
}
52
53
clname = getUTF(env, classname, buf, sizeof(buf));
54
if (clname == NULL) {
55
// getUTF() throws OOME before returning NULL, no need to throw OOME here
56
return result;
57
}
58
VerifyFixClassname(clname);
59
60
if (!VerifyClassname(clname, JNI_TRUE)) { /* expects slashed name */
61
goto done;
62
}
63
64
result = JVM_KnownToNotExist(env, loader, clname);
65
66
done:
67
if (clname != buf) {
68
free(clname);
69
}
70
71
return result;
72
}
73
74
JNIEXPORT jobjectArray JNICALL
75
Java_sun_misc_URLClassPath_getLookupCacheURLs(JNIEnv *env, jclass cls, jobject loader)
76
{
77
return JVM_GetResourceLookupCacheURLs(env, loader);
78
}
79
80
81
JNIEXPORT jintArray JNICALL
82
Java_sun_misc_URLClassPath_getLookupCacheForClassLoader(JNIEnv *env, jclass cls,
83
jobject loader,
84
jstring resource_name)
85
{
86
char *resname;
87
jintArray result = NULL;
88
char buf[128];
89
90
if (resource_name == NULL) {
91
JNU_ThrowNullPointerException(env, NULL);
92
return result;
93
}
94
95
resname = getUTF(env, resource_name, buf, sizeof(buf));
96
if (resname == NULL) {
97
// getUTF() throws OOME before returning NULL, no need to throw OOME here
98
return result;
99
}
100
result = JVM_GetResourceLookupCache(env, loader, resname);
101
102
done:
103
if (resname != buf) {
104
free(resname);
105
}
106
107
return result;
108
}
109
110
111