IllegalAccessException in Java 9+ #93

Closed
opened 2018-11-16 16:59:35 -05:00 by Tim269 · 16 comments
Tim269 commented 2018-11-16 16:59:35 -05:00 (Migrated from github.com)

Hey - thank you so much for mainting this plugin <3. Here is a error I stumpling about recently.

[22:54:19 WARN]: java.lang.IllegalAccessException: Can not set final net.minecraft.server.v1_13_R2.NonNullList field net.minecraft.server.v1_13_R2.PlayerInventory.items to net.minecraft.server.v1_13_R2.NonNullList
[22:54:19 WARN]:        at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:76)
[22:54:19 WARN]:        at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:80)
[22:54:19 WARN]:        at java.base/jdk.internal.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:79)
[22:54:19 WARN]:        at java.base/java.lang.reflect.Field.set(Field.java:780)
[22:54:19 WARN]:        at com.lishid.openinv.internal.v1_13_R2.SpecialPlayerInventory.setItemArrays(SpecialPlayerInventory.java:161)
[22:54:19 WARN]:        at com.lishid.openinv.internal.v1_13_R2.SpecialPlayerInventory.<init>(SpecialPlayerInventory.java:43)
[22:54:19 WARN]:        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[22:54:19 WARN]:        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[22:54:19 WARN]:        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[22:54:19 WARN]:        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
[22:54:19 WARN]:        at com.lishid.openinv.util.InternalAccessor.createObject(InternalAccessor.java:103)
[22:54:19 WARN]:        at com.lishid.openinv.util.InternalAccessor.newSpecialPlayerInventory(InternalAccessor.java:210)
[22:54:19 WARN]:        at com.lishid.openinv.OpenInv.getSpecialInventory(OpenInv.java:327)
[22:54:19 WARN]:        at com.lishid.openinv.commands.OpenInvPluginCommand.openInventory(OpenInvPluginCommand.java:148)
[22:54:19 WARN]:        at com.lishid.openinv.commands.OpenInvPluginCommand.access$100(OpenInvPluginCommand.java:33)
[22:54:19 WARN]:        at com.lishid.openinv.commands.OpenInvPluginCommand$1$1.run(OpenInvPluginCommand.java:89)
[22:54:19 WARN]:        at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftTask.run(CraftTask.java:63)
[22:54:19 WARN]:        at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:423)
[22:54:19 WARN]:        at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:1008)
[22:54:19 WARN]:        at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:439)
[22:54:19 WARN]:        at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:943)
[22:54:19 WARN]:        at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:841)
[22:54:19 WARN]:        at java.base/java.lang.Thread.run(Thread.java:834)
Hey - thank you so much for mainting this plugin <3. Here is a error I stumpling about recently. ``` [22:54:19 WARN]: java.lang.IllegalAccessException: Can not set final net.minecraft.server.v1_13_R2.NonNullList field net.minecraft.server.v1_13_R2.PlayerInventory.items to net.minecraft.server.v1_13_R2.NonNullList [22:54:19 WARN]: at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:76) [22:54:19 WARN]: at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwFinalFieldIllegalAccessException(UnsafeFieldAccessorImpl.java:80) [22:54:19 WARN]: at java.base/jdk.internal.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:79) [22:54:19 WARN]: at java.base/java.lang.reflect.Field.set(Field.java:780) [22:54:19 WARN]: at com.lishid.openinv.internal.v1_13_R2.SpecialPlayerInventory.setItemArrays(SpecialPlayerInventory.java:161) [22:54:19 WARN]: at com.lishid.openinv.internal.v1_13_R2.SpecialPlayerInventory.<init>(SpecialPlayerInventory.java:43) [22:54:19 WARN]: at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [22:54:19 WARN]: at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [22:54:19 WARN]: at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [22:54:19 WARN]: at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) [22:54:19 WARN]: at com.lishid.openinv.util.InternalAccessor.createObject(InternalAccessor.java:103) [22:54:19 WARN]: at com.lishid.openinv.util.InternalAccessor.newSpecialPlayerInventory(InternalAccessor.java:210) [22:54:19 WARN]: at com.lishid.openinv.OpenInv.getSpecialInventory(OpenInv.java:327) [22:54:19 WARN]: at com.lishid.openinv.commands.OpenInvPluginCommand.openInventory(OpenInvPluginCommand.java:148) [22:54:19 WARN]: at com.lishid.openinv.commands.OpenInvPluginCommand.access$100(OpenInvPluginCommand.java:33) [22:54:19 WARN]: at com.lishid.openinv.commands.OpenInvPluginCommand$1$1.run(OpenInvPluginCommand.java:89) [22:54:19 WARN]: at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftTask.run(CraftTask.java:63) [22:54:19 WARN]: at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:423) [22:54:19 WARN]: at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:1008) [22:54:19 WARN]: at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:439) [22:54:19 WARN]: at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:943) [22:54:19 WARN]: at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:841) [22:54:19 WARN]: at java.base/java.lang.Thread.run(Thread.java:834) ```
RoboMWM commented 2018-11-16 17:22:27 -05:00 (Migrated from github.com)

/version openinv may be helpful and what happens that causes this.

`/version openinv` may be helpful and what happens that causes this.
Tim269 commented 2018-11-16 17:24:25 -05:00 (Migrated from github.com)

Oh sorry. I'm using OpenInv version 3.3.6 and git-Paper-432 (1.13.2)

Oh sorry. I'm using `OpenInv version 3.3.6` and `git-Paper-432` (1.13.2)
catb0t commented 2018-11-16 17:46:25 -05:00 (Migrated from github.com)

What were you doing before the exception?

What were you doing before the exception?
Tim269 commented 2018-11-16 17:50:01 -05:00 (Migrated from github.com)

I tried to execute /openinv <player> or /openender <player>. However any empty inventory pops up (not the actual one) along with the error in my server console.

I tried to execute `/openinv <player>` or `/openender <player>`. However any empty inventory pops up (not the actual one) along with the error in my server console.
Jikoo commented 2018-11-16 23:33:43 -05:00 (Migrated from github.com)

Huh, what java version are you using? I've never seen java.base/ prepended on stack trace lines.

I'll look into it, but I'm not sure what could be causing that - we remove the final modifier prior to setting. It's not a SecurityManager or anything like that, it'd be a different error. The modifier just appears to not be changed.

Huh, what java version are you using? I've never seen `java.base/` prepended on stack trace lines. I'll look into it, but I'm not sure what could be causing that - we [remove the final modifier](https://github.com/lishid/OpenInv/blob/master/internal/v1_13_R2/src/main/java/com/lishid/openinv/internal/v1_13_R2/SpecialPlayerInventory.java#L160) prior to setting. It's not a SecurityManager or anything like that, it'd be a different error. The modifier just appears to not be changed.
Tim269 commented 2018-11-17 05:57:20 -05:00 (Migrated from github.com)

I'm so sorry for being that bad at providing information. I assume my error is caused by my java version as I'm using "11.0.1" 2018-10-16 LTS

I'm so sorry for being that bad at providing information. I assume my error is caused by my java version as I'm using `"11.0.1" 2018-10-16 LTS`
andris155 commented 2018-12-03 14:06:16 -05:00 (Migrated from github.com)

Same problem in Java 11

Same problem in Java 11
RoboMWM commented 2018-12-03 16:12:52 -05:00 (Migrated from github.com)

Curious if this has anything to do with some of the reflection stuff being removed in post-version 8 java.

Curious if this has anything to do with some of the reflection stuff being removed in post-version 8 java.
Jikoo commented 2018-12-06 20:20:43 -05:00 (Migrated from github.com)

Yeah, I assume somewhere in Java 9 OpenInv broke. Not sure how to handle it, honestly. I really don't want to encourage people to stay on Java 8, but all the good alternatives I can come up with are massive changes I definitely don't have time to implement for a while.

I guess the easiest temp fix would be to just override every ISpecialPlayerInventory manipulation method and redirect the entire inventory contents to a different list/array which actually is the internal one. It'd be way more messy and prone to accidental breakages than it is now (for updates, I basically copy+paste, then review method diffs) but it should allow us to limp along.

Yeah, I assume somewhere in Java 9 OpenInv broke. Not sure how to handle it, honestly. I really don't want to encourage people to stay on Java 8, but all the good alternatives I can come up with are massive changes I definitely don't have time to implement for a while. I guess the easiest temp fix would be to just override every ISpecialPlayerInventory manipulation method and redirect the entire inventory contents to a different list/array which actually is the internal one. It'd be way more messy and prone to accidental breakages than it is now (for updates, I basically copy+paste, then review method diffs) but it should allow us to limp along.
Jikoo commented 2019-01-15 19:37:22 -05:00 (Migrated from github.com)

Do containers open silently at all? Looks like it should be broken as well.

Do containers open silently at all? Looks like it should be broken as well.
Tim269 commented 2019-01-16 16:09:40 -05:00 (Migrated from github.com)

Not sure what all is defined as containers - but chests do open silently as they used to be.

Not sure what all is defined as containers - but chests do open silently as they used to be.
Jikoo commented 2019-01-16 20:22:40 -05:00 (Migrated from github.com)

Interesting, so reflection in Java 9+ still allows accessing private variables, but doesn't allow removing the final modifier. Could be worse I guess.

Interesting, so reflection in Java 9+ still allows accessing private variables, but doesn't allow removing the final modifier. Could be worse I guess.
Thrasilias commented 2019-03-30 17:07:35 -04:00 (Migrated from github.com)

when will this be fixed. seems to be a little bit inactive ans people need this..

when will this be fixed. seems to be a little bit inactive ans people need this..
Jikoo commented 2019-04-08 08:36:26 -04:00 (Migrated from github.com)

when will this be fixed. seems to be a little bit inactive ans people need this..

I haven't had much free time lately, though I'll admit this isn't a high priority for me due to the low percentage of servers using anything other than Java 8.
I'll try to make a junky copy+paste workaround this week, but if anyone wants to take a stab at a higher quality solution that's certainly welcome.

>when will this be fixed. seems to be a little bit inactive ans people need this.. I haven't had much free time lately, though I'll admit this isn't a high priority for me due to the low percentage of servers using anything other than Java 8. I'll try to make a junky copy+paste workaround this week, but if anyone wants to take a stab at a higher quality solution that's certainly welcome.
Jikoo commented 2019-04-12 20:57:10 -04:00 (Migrated from github.com)

Please try OpenInv 3.3.8-SNAPSHOT. Theoretically should work, but it's nowhere near as clean as it could be.

Please try [OpenInv 3.3.8-SNAPSHOT](https://github.com/lishid/OpenInv/files/3075576/OpenInv.zip). Theoretically should work, but it's nowhere near as clean as it could be.
Jikoo commented 2019-05-05 17:08:54 -04:00 (Migrated from github.com)

4.0.0 fixes Java 9+ issues.

[4.0.0](https://github.com/lishid/OpenInv/releases/tag/4.0.0) fixes Java 9+ issues.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: minster586/OpenInv#93
No description provided.