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/common/jdk_util.c
38825 views
1
/*
2
* Copyright (c) 2005, 2011, 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 <stdlib.h>
27
#include <string.h>
28
#include <ctype.h>
29
#include <assert.h>
30
31
#include "jvm.h"
32
#include "jdk_util.h"
33
34
#ifndef JDK_UPDATE_VERSION
35
/* if not defined set to 00 */
36
#define JDK_UPDATE_VERSION "00"
37
#endif
38
39
JNIEXPORT void
40
JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
41
/* These JDK_* macros are set at Makefile or the command line */
42
const unsigned int jdk_major_version =
43
(unsigned int) atoi(JDK_MAJOR_VERSION);
44
const unsigned int jdk_minor_version =
45
(unsigned int) atoi(JDK_MINOR_VERSION);
46
const unsigned int jdk_micro_version =
47
(unsigned int) atoi(JDK_MICRO_VERSION);
48
49
const char* jdk_build_string = JDK_BUILD_NUMBER;
50
char build_number[4];
51
unsigned int jdk_build_number = 0;
52
53
const char* jdk_update_string = JDK_UPDATE_VERSION;
54
unsigned int jdk_update_version = 0;
55
int len_update_ver = 0;
56
char update_ver[5];
57
char jdk_special_version = '\0';
58
59
/* If the JDK_BUILD_NUMBER is of format bXX and XX is an integer
60
* XX is the jdk_build_number.
61
*/
62
int len = strlen(jdk_build_string);
63
if (jdk_build_string[0] == 'b' && len >= 2) {
64
int i = 0;
65
for (i = 1; i < len; i++) {
66
if (isdigit(jdk_build_string[i])) {
67
build_number[i-1] = jdk_build_string[i];
68
} else {
69
// invalid build number
70
i = -1;
71
break;
72
}
73
}
74
if (i == len) {
75
build_number[len-1] = '\0';
76
jdk_build_number = (unsigned int) atoi(build_number) ;
77
}
78
}
79
80
assert(jdk_build_number >= 0 && jdk_build_number <= 255);
81
82
len_update_ver = strlen(jdk_update_string);
83
if (len_update_ver >= 2 && len_update_ver <= 4) {
84
int update_digits = len_update_ver;
85
86
if (!isdigit(jdk_update_string[len_update_ver - 1])) {
87
jdk_special_version = jdk_update_string[len_update_ver -1];
88
update_digits = len_update_ver - 1;
89
}
90
strncpy(update_ver, jdk_update_string, update_digits);
91
update_ver[update_digits] = '\0';
92
jdk_update_version = (unsigned int) atoi(update_ver);
93
}
94
95
memset(info, 0, info_size);
96
info->jdk_version = ((jdk_major_version & 0xFF) << 24) |
97
((jdk_minor_version & 0xFF) << 16) |
98
((jdk_micro_version & 0xFF) << 8) |
99
(jdk_build_number & 0xFF);
100
info->update_version = jdk_update_version;
101
info->special_update_version = (unsigned int) jdk_special_version;
102
info->thread_park_blocker = 1;
103
// Advertise presence of sun.misc.PostVMInitHook:
104
// future optimization: detect if this is enabled.
105
info->post_vm_init_hook_enabled = 1;
106
info->pending_list_uses_discovered_field = 1;
107
}
108
109