java mutator,Java,IllegalAccessorError:超类访问检查失败

I've been working on a little project of my own in Java, and recently, I compiled it and received this error:

Exception in thread "main" java.lang.IllegalAccessError: superclass access check failed: class kröw.zeale.v1.program.core.DataManager$ConstructList (in unnamed module @0x4563e9ab) cannot access class com.sun.javafx.collections.ObservableListWrapper (in module javafx.base) because module javafx.base does not export com.sun.javafx.collections to unnamed module @0x4563e9ab

Background:

So, I currently have three different classes, all in the same package. My hierarchy is as follows:

• Kröw

• DataManager

♦ ConstructList

In previous versions of my program, my hierarchy was like this:

• Kröw

♦ DataManager

- ConstructList

In both cases, ConstructList extended com.sun.javafx.collections.ObservableListWrapper. (I don't think that the class Construct is necessary here and I'd rather not show it, but I can if needed.)

Anyways, right now, my IDE can run the application as expected, however, when I export it, the above exception is given to me.

Full Stack Trace:

Exception in thread "main" java.lang.IllegalAccessError: superclass access check failed: class kröw.zeale.v1.program.core.DataManager$ConstructList (in unnamed module @0x4563e9ab) cannot access class com.sun.javafx.collections.ObservableListWrapper (in module javafx.base) because module javafx.base does not export com.sun.javafx.collections to unnamed module @0x4563e9ab

at java.base/java.lang.ClassLoader.defineClass1(Native Method)

at java.base/java.lang.ClassLoader.defineClass(Unknown Source)

at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)

at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)

at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source)

at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)

at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)

at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)

at java.base/java.lang.ClassLoader.loadClass(Unknown Source)

at kröw.zeale.v1.program.core.DataManager.(DataManager.java:22)

at kröw.zeale.v1.program.core.DataManager.getDataManager(DataManager.java:63)

at kröw.zeale.v1.program.core.Kröw.(Kröw.java:23)

Part of class Kröw that is mentioned in the error:

private static final DataManager DATA_MANAGER = DataManager.getDataManager(); // line 23

Parts of class DataManager that are mentioned in the error:

static DataManager getDataManager() { // line 66

return new DataManager();

}

and

public final ConstructList constructs = new ConstructList(); // line 22

Class ConstructList:

public class ConstructList extends ObservableListWrapper { // line 209

private ConstructList() {

super(new ArrayList<>()); // line 212

}

public LinkedList getDeadConstructs() {

...

}

public LinkedList getLivingConstructs() {

...

}

}

Now, I have looked at the resources that I could find, such as IllegalAccessError SO Question

(Notice how this said: "tried to access method" instead of "superclass access check failed")

The accepted answer to that solution was to check if anything is different between the compiled jar file and my source code, so I tried that and found some minor differences. Here are the changed lines of code from my decompiled jar file. (Decompiled using JD-GUI)

Class DataManager:

public final ConstructList constructs = new ConstructList(null);

Used to be:

public final ConstructList constructs = new ConstructList();

Class ConstructList:

private ConstructList() {

super();

}

Used to be:

private ConstructList() {

super(new ArrayList<>());

}

Now, in the decompiled code, the ConstructList() constructor does not have any parameters, and I see it being invoked with null being passed in, which looks like an error to me, but I'm not sure if it is the cause of my exception and I haven't been able to find anything via the internet, which is why I came here.

On another note, the decompiled code I've given was created by my IDE, using its export function. I would like to see if the null argument with my constructor is the problem, but I do not know how to compile my code in a different way to reflect that. If someone knows how I can change the exported code I am getting, please inform me.

Anyways, what I want to know is what part of my code this exception is caused by, and how I can fix it.

解决方案

It turns out you were compiling with Java 9 which utilizes the JDK's new module system. There is probably a valid way to fix your problem by implementing modules, however another solution is to simply compile with Java 8!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值