Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/jcl/common/bpinit.c
6000 views
1
/*******************************************************************************
2
* Copyright (c) 1998, 2017 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
#include <string.h>
24
25
#include "j9.h"
26
#include "j9consts.h"
27
#include "jni.h"
28
#include "j9protos.h"
29
30
#define JIMAGE_EXTENSION "jimage"
31
32
/* this file is owned by the VM-team. Please do not modify it without consulting the VM team */
33
34
#if (defined(J9VM_OPT_DYNAMIC_LOAD_SUPPORT))
35
36
37
char* getDefaultBootstrapClassPath(J9JavaVM * vm, char* javaHome)
38
{
39
PORT_ACCESS_FROM_JAVAVM(vm);
40
char separator = (char) j9sysinfo_get_classpathSeparator();
41
extern const char* const jclBootstrapClassPath[];
42
extern char* jclBootstrapClassPathAllocated[];
43
char **entry = NULL;
44
char *path = NULL;
45
char *lastEntry = NULL;
46
UDATA pathLength = 0;
47
UDATA javaHomeLength = strlen(javaHome);
48
49
for (entry = GLOBAL_TABLE(jclBootstrapClassPath); NULL != *entry; ++entry) {
50
lastEntry = *entry;
51
52
pathLength += strlen(lastEntry);
53
54
/*
55
* Entries that start with ! don't need our attention:
56
* The space for the exclamation mark will be consumed
57
* by a path separator.
58
*/
59
if ('!' != lastEntry[0]) {
60
pathLength += javaHomeLength;
61
pathLength += 1; /* for separator or NUL-terminator */
62
pathLength += sizeof("/lib/") - 1;
63
}
64
}
65
66
/* Always create space enough for the NUL-terminator. */
67
if (0 == pathLength) {
68
pathLength = 1;
69
}
70
71
path = j9mem_allocate_memory(pathLength, J9MEM_CATEGORY_VM_JCL);
72
if (NULL != path) {
73
UDATA i = 0;
74
char* subPath = path;
75
76
/* Always NUL-terminate the path. */
77
path[0] = '\0';
78
79
for (entry = GLOBAL_TABLE(jclBootstrapClassPath), i = 0; NULL != *entry; ++entry, ++i) {
80
UDATA subLength = 0;
81
82
/* add a separator before the second and subsequent entries */
83
if (0 != i) {
84
*subPath = separator;
85
subPath += 1;
86
pathLength -= 1;
87
}
88
89
lastEntry = *entry;
90
91
if ('!' == lastEntry[0]) {
92
j9str_printf(PORTLIB, subPath, (U_32)pathLength, "%s", lastEntry + 1);
93
j9mem_free_memory(*entry);
94
} else {
95
j9str_printf(PORTLIB, subPath, (U_32)pathLength,
96
"%s" DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR "%s",
97
/* classes.zip */ javaHome, *entry);
98
/* if this entry was allocated then free it as we will not use it
99
* after this point */
100
if (NULL != jclBootstrapClassPathAllocated[i]) {
101
j9mem_free_memory(jclBootstrapClassPathAllocated[i]);
102
}
103
}
104
*entry = NULL;
105
jclBootstrapClassPathAllocated[i] = NULL;
106
107
subLength = strlen(subPath);
108
subPath += subLength;
109
pathLength -= subLength;
110
}
111
}
112
113
return path;
114
}
115
116
#endif /* J9VM_OPT_DYNAMIC_LOAD_SUPPORT */
117
118