我在 GitHub actions 上有以下工作。我想跳过 macOS x86 配置:有办法做到这一点吗?
build-and-push-native-libraries:
name: Build and push native library on ${{ matrix.os }} ${{ matrix.architecture }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macOS, windows-latest]
java: [15]
architecture: [x86, x64]
include:
- compiler: gcc
gcc: 8
runs-on: ${{ matrix.os }}
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
architecture: ${{ matrix.architecture }}
- uses: actions/checkout@v2
- if: startsWith(matrix.os, 'ubuntu') == true
name: Change the permissions of the build …
Run Code Online (Sandbox Code Playgroud) 我编写了以下使用成员指针函数的类:
#include <stdlib.h>
#include <vector>
template<class Type>
class PrimitiveAccessor {
public :
PrimitiveAccessor(
JNIEnv* env, const char name[], const char ctorSig[],
Type (JNIEnv::*callTypeMethodFunction) (jobject, jmethodID)
) {
this->env = env;
this->type = (jclass)env->NewGlobalRef(env->FindClass(name));
this->callTypeMethodFunction = callTypeMethodFunction;
}
~PrimitiveAccessor(){
env->DeleteGlobalRef(this->type);
}
private:
JNIEnv* env;
jclass type;
jmethodID constructorId;
jmethodID callTypeMethodId;
Type (JNIEnv::*callTypeMethodFunction) (jobject, jmethodID);
};
class Environment {
public:
Environment(JNIEnv* env) {
this->env = env;
this->init();
}
~Environment(){
this->env = 0;
delete(this->jintAccessor);
this->jintAccessor = 0;
}
private:
JNIEnv* env;
PrimitiveAccessor<jint>* jintAccessor; …
Run Code Online (Sandbox Code Playgroud) 我已经在头文件(Environment.h)中声明了以下类,并且我想使超类 FieldAccessor 抽象:
#include <jni.h>
class FieldAccessor {
public:
FieldAccessor(
JNIEnv* env
) {
this->jNIEnv = env;
}
virtual jobject getValue(jobject, jobject) = 0;
protected:
JNIEnv* jNIEnv;
};
template<typename Type>
class PrimitiveFieldAccessor : public FieldAccessor {
public :
PrimitiveFieldAccessor (
JNIEnv* env, const char name[], const char ctorSig[],
Type (JNIEnv::*getFieldValueFunction) (jobject, jfieldID)
);
jobject getValue(jobject, jobject);
private:
jclass type;
jmethodID constructorId;
Type (JNIEnv::*getFieldValueFunction) (jobject, jfieldID);
};
Run Code Online (Sandbox Code Playgroud)
但我得到以下编译错误:
#include <jni.h>
class FieldAccessor {
public:
FieldAccessor(
JNIEnv* env
) {
this->jNIEnv = …
Run Code Online (Sandbox Code Playgroud) 我将以下遗留代码迁移到 Java 16,但是由于这个新版本引入了强封装,它不起作用:
try {
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(new URLClassLoader(
new URL[] {}),
new File("C:/external-folder/my.jar").toURI().toURL()
);
} catch (Exception exc) {
exc.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
有办法让它发挥作用吗?