Skip to content

Commit 0b1194a

Browse files
Do not rely on jni_md from JAVA_HOME in mokapot and nespresso
1 parent b6d0234 commit 0b1194a

File tree

7 files changed

+228
-8
lines changed

7 files changed

+228
-8
lines changed

espresso/mx.espresso/suite.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@
222222
"native": "shared_lib",
223223
"deliverable": "nespresso",
224224
"platformDependent": True,
225-
"use_jdk_headers": True,
226225
"buildDependencies": [
227226
"com.oracle.truffle.espresso.mokapot",
228227
],
@@ -283,7 +282,6 @@
283282
"native": "shared_lib",
284283
"deliverable": "jvm",
285284
"platformDependent": True,
286-
"use_jdk_headers": True,
287285
"os_arch": {
288286
"darwin": {
289287
"<others>": {

espresso/src/com.oracle.truffle.espresso.mokapot/include/jni.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@
3737
#include <stdio.h>
3838
#include <stdarg.h>
3939

40-
/* jni_md.h contains the machine-dependent typedefs for jbyte, jint
40+
/* jni_<platform>.h contains the machine-dependent typedefs for jbyte, jint
4141
and jlong */
42-
43-
#include "jni_md.h"
42+
#if defined(_WIN32)
43+
#include "jni_windows.h"
44+
#elif defined(__linux__) || defined(__APPLE__)
45+
#include "jni_unix.h"
46+
#else
47+
#error unknown platform
48+
#endif
4449

4550
#ifdef __cplusplus
4651
extern "C" {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (c) 1996, 2020, 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+
#ifndef _JAVASOFT_JNI_MD_H_
27+
#define _JAVASOFT_JNI_MD_H_
28+
29+
#ifndef __has_attribute
30+
#define __has_attribute(x) 0
31+
#endif
32+
33+
#ifndef JNIEXPORT
34+
#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility)
35+
#ifdef ARM
36+
#define JNIEXPORT __attribute__((externally_visible,visibility("default")))
37+
#else
38+
#define JNIEXPORT __attribute__((visibility("default")))
39+
#endif
40+
#else
41+
#define JNIEXPORT
42+
#endif
43+
#endif
44+
45+
#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility)
46+
#ifdef ARM
47+
#define JNIIMPORT __attribute__((externally_visible,visibility("default")))
48+
#else
49+
#define JNIIMPORT __attribute__((visibility("default")))
50+
#endif
51+
#else
52+
#define JNIIMPORT
53+
#endif
54+
55+
#define JNICALL
56+
57+
typedef int jint;
58+
#ifdef _LP64
59+
typedef long jlong;
60+
#else
61+
typedef long long jlong;
62+
#endif
63+
64+
typedef signed char jbyte;
65+
66+
#endif /* !_JAVASOFT_JNI_MD_H_ */
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 1996, 2020, 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+
#ifndef _JAVASOFT_JNI_MD_H_
27+
#define _JAVASOFT_JNI_MD_H_
28+
29+
#ifndef JNIEXPORT
30+
#define JNIEXPORT __declspec(dllexport)
31+
#endif
32+
#define JNIIMPORT __declspec(dllimport)
33+
#define JNICALL __stdcall
34+
35+
// 'long' is always 32 bit on windows so this matches what jdk expects
36+
typedef long jint;
37+
typedef __int64 jlong;
38+
typedef signed char jbyte;
39+
40+
#endif /* !_JAVASOFT_JNI_MD_H_ */

espresso/src/com.oracle.truffle.espresso.native/include/jni.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@
3737
#include <stdio.h>
3838
#include <stdarg.h>
3939

40-
/* jni_md.h contains the machine-dependent typedefs for jbyte, jint
40+
/* jni_<platform>.h contains the machine-dependent typedefs for jbyte, jint
4141
and jlong */
42-
43-
#include "jni_md.h"
42+
#if defined(_WIN32)
43+
#include "jni_windows.h"
44+
#elif defined(__linux__) || defined(__APPLE__)
45+
#include "jni_unix.h"
46+
#else
47+
#error unknown platform
48+
#endif
4449

4550
#ifdef __cplusplus
4651
extern "C" {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (c) 1996, 2020, 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+
#ifndef _JAVASOFT_JNI_MD_H_
27+
#define _JAVASOFT_JNI_MD_H_
28+
29+
#ifndef __has_attribute
30+
#define __has_attribute(x) 0
31+
#endif
32+
33+
#ifndef JNIEXPORT
34+
#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility)
35+
#ifdef ARM
36+
#define JNIEXPORT __attribute__((externally_visible,visibility("default")))
37+
#else
38+
#define JNIEXPORT __attribute__((visibility("default")))
39+
#endif
40+
#else
41+
#define JNIEXPORT
42+
#endif
43+
#endif
44+
45+
#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility)
46+
#ifdef ARM
47+
#define JNIIMPORT __attribute__((externally_visible,visibility("default")))
48+
#else
49+
#define JNIIMPORT __attribute__((visibility("default")))
50+
#endif
51+
#else
52+
#define JNIIMPORT
53+
#endif
54+
55+
#define JNICALL
56+
57+
typedef int jint;
58+
#ifdef _LP64
59+
typedef long jlong;
60+
#else
61+
typedef long long jlong;
62+
#endif
63+
64+
typedef signed char jbyte;
65+
66+
#endif /* !_JAVASOFT_JNI_MD_H_ */
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 1996, 2020, 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+
#ifndef _JAVASOFT_JNI_MD_H_
27+
#define _JAVASOFT_JNI_MD_H_
28+
29+
#ifndef JNIEXPORT
30+
#define JNIEXPORT __declspec(dllexport)
31+
#endif
32+
#define JNIIMPORT __declspec(dllimport)
33+
#define JNICALL __stdcall
34+
35+
// 'long' is always 32 bit on windows so this matches what jdk expects
36+
typedef long jint;
37+
typedef __int64 jlong;
38+
typedef signed char jbyte;
39+
40+
#endif /* !_JAVASOFT_JNI_MD_H_ */

0 commit comments

Comments
 (0)