lucasstarsz / Slope-ECS

An Entity Component System written in Java, based on Austin Morlan's C++ ECS.
MIT License
14 stars 1 forks source link

java.lang.IllegalAccessException when running example guessing game #14

Closed nicvst closed 3 years ago

nicvst commented 3 years ago

Version: both 0.0.8 and 0.0.9.

Issue: When running the example guessing game, the following will occur:

> Task :GuessingGameExample.main()
Welcome to Guessing Game!
Your goal is to find the secret entity with the special number.

Would you like to play a round? (y/N): 
Alllllright, let's get into it!

Exception in thread "main" java.lang.IllegalStateException: java.lang.IllegalAccessException: class io.github.lucasstarsz.slopeecs.system.ECSSystemManager (in module slope.ecs) cannot access class examples.guessinggame.systems.NumberSystem (in module Slope.ECS.examples) because module Slope.ECS.examples does not export examples.guessinggame.systems to module slope.ecs
    at slope.ecs/io.github.lucasstarsz.slopeecs.system.ECSSystemManager.registerSystem(ECSSystemManager.java:81)
    at slope.ecs/io.github.lucasstarsz.slopeecs.World.registerSystem(World.java:183)
    at slope.ecs/io.github.lucasstarsz.slopeecs.system.ECSSystemBuilder.construct(ECSSystemBuilder.java:96)
    at slope.ecs/io.github.lucasstarsz.slopeecs.system.ECSSystemBuilder.<init>(ECSSystemBuilder.java:91)
    at slope.ecs/io.github.lucasstarsz.slopeecs.system.ECSSystemBuilder.<init>(ECSSystemBuilder.java:71)
    at Slope.ECS.examples/examples.guessinggame.game.GuessingGame.reset(GuessingGame.java:34)
    at Slope.ECS.examples/examples.guessinggame.GuessingGameExample.main(GuessingGameExample.java:23)
Caused by: java.lang.IllegalAccessException: class io.github.lucasstarsz.slopeecs.system.ECSSystemManager (in module slope.ecs) cannot access class examples.guessinggame.systems.NumberSystem (in module Slope.ECS.examples) because module Slope.ECS.examples does not export examples.guessinggame.systems to module slope.ecs
    at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:385)
    at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:693)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:490)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
Caused by: java.lang.IllegalAccessException: class io.github.lucasstarsz.slopeecs.system.ECSSystemManager (in module slope.ecs) cannot access class examples.guessinggame.systems.NumberSystem (in module Slope.ECS.examples) because module Slope.ECS.examples does not export examples.guessinggame.systems to module slope.ecs

    at slope.ecs/io.github.lucasstarsz.slopeecs.system.ECSSystemManager.registerSystem(ECSSystemManager.java:74)
    ... 6 more

> Task :GuessingGameExample.main() FAILED

Execution failed for task ':GuessingGameExample.main()'.
> Process 'command 'C:/Program Files/AdoptOpenJDK/jdk-15.0.2.7-hotspot/bin/java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

This is because the module Slope.ECS.examples does not export to slope.ecs , as given in the examples.guessinggame.module-info.java file.

Fix: This can simply fixed by setting the Slope.ECS.examples module to open. I'll create a PR for this.

lucasstarsz commented 3 years ago

Fixed by merge request #15. Awaiting release before pushing to main.