我有以下引发错误的代码:
if(download_started){
if(initDownload.isRunning()) initDownload.cancel();
if(checkStatus.isRunning()) checkStatus.cancel();
if(processDownload.isRunning()) processDownload.cancel();
}
initDownload
, checkStutus
,processDownload
是 的实现javafx.concurrent.Task
,但是每次我调用该cancel
方法时,它都会引发错误:
java.lang.NoSuchMethodError: java.security.AccessController.doPriviledged
at javafx.concurrent.Task.cancel(Task.java:1009)
at javafx.concurrent.Task.cancel(Task.java:997)
at com.example.page.Download$5.handle(Download.java:156)
at com.example.page.Download$5.handle(Download.java:150)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:59)
顺便说一句,这是一个部署在 Android 中的 Javafx 应用程序。如何解决这个问题?
构建.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.7'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
}
mainClassName = 'com.rameses.Main'
jfxmobile {
android {
manifest = 'lib/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
}
}
jfxmobile {
android {
packagingOptions {
exclude 'build.properties'
}
}
}
dependencies {
compile fileTree(dir: 'lib', include: '*.jar')
}
dependencies {
compile 'com.gluonhq:charm-down-common:2.0.0';
desktopRuntime 'com.gluonhq:charm-down-desktop:2.0.0';
androidRuntime 'com.gluonhq:charm-down-android:2.0.0';
iosRuntime 'com.gluonhq:charm-down-ios:2.0.0';
}
任务实施:
public class InitDownloadTask extends Task<String> {
private Map params;
private MobileDownloadService mobileSvc;
public InitDownloadTask(Map params){
this.params = params;
mobileSvc = new MobileDownloadService();
}
@Override
protected String call() throws Exception {
String batchid = mobileSvc.initForDownload( params );
return batchid;
}
}