You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When attempting to call some Java methods from Lua an IllegalAccessException is thrown
To Reproduce
Steps to reproduce the behavior:
Create a public interface with some methods
Create an implementation of that interface as package-private (no access modifier)
Add a method (static or otherwise, doesn't matter) in the same package that returns the interface type, but actually returns the package-private implementation (in the example below, it's a static method inside the interface, but any approach works as long as it returns the implementation)
Call the class’s methods normally in Java — everything works as expected
Try calling the same method via LuaJava (or plain reflection) — you’ll get an IllegalAccessException
Current behavior
LuaJava throws an IllegalAccessException.
Expected behavior
The method should be called normally.
Platform:
Arch: x86_64
OS: Linux
Lua Version: LuaJIT
Additional context
I realize this is more of a Java reflection quirk, but I figured it was worth opening this to get ideas on how to work around it.
One possible solution I came up with: before invoking the method, check if it's inaccessible but public (to avoid calling anything that's meant to stay private). If that’s the case, call setAccessible(true), which seems to let the call go through just fine.
The text was updated successfully, but these errors were encountered:
I have confirmed that checking if a method is public and inaccessible then setting it accessible does seem to resolve this issue. However is there another way?
Describe the bug
When attempting to call some Java methods from Lua an
IllegalAccessException
is thrownTo Reproduce
Steps to reproduce the behavior:
IllegalAccessException
Current behavior
LuaJava throws an
IllegalAccessException
.Expected behavior
The method should be called normally.
Platform:
Additional context
I realize this is more of a Java reflection quirk, but I figured it was worth opening this to get ideas on how to work around it.
One possible solution I came up with: before invoking the method, check if it's inaccessible but public (to avoid calling anything that's meant to stay private). If that’s the case, call
setAccessible(true)
, which seems to let the call go through just fine.The text was updated successfully, but these errors were encountered: