CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2021
    Posts
    5

    IllegalAccessError, cannot acces class

    Please, I am using AIDE IDE on android with libgdx and everything was okay until I got error message:
    Code:
    06-25 22:38:02.730 14459 14484 E   AndroidRuntime                ava.lang.IllegalAccessError: 
                   jIllegal class access ('com.hmmmgames.dungroll.DungeonRollcall' attempting to access 'com.hmmmgames.dungroll.creatures.Creature') 
                   jin attempt to invoke virtual method java.lang.String com.hmmmgames.dungroll.creatures.Creature.myid() 
                   j(declaration of 'com.hmmmgames.dungroll.DungeonRollcall' appears in /data/app/com.hmmmgames.dungroll-1/base.apk)
    
    06-25 22:38:02.730 14459 14484 E   AndroidRuntime                               at com.hmmmgames.dungroll.DungeonRollcall.add(DungeonRollcall.java:102)
    Please, how do I fix?

    Creature.java(summarized)
    Code:
    class Creature
    {
        public static class Action {
            public String name;
            
        }
    
        public static final int ME = -1;
        public static final int MY_CLAN_FRIEND = 1;
        public static final int MY_FOREIGN_FRIEND = 2;
        public static final int MY_CLAN = 3;
        public static final int MY_CLAN_ALLY = 4;
        public static final int UNKNOWN_CREATURE = 5;
        public static final int UNKNOWN_CLAN = 6;
        public static final int MY_CLAN_ENEMY = 7;
        public static final int MY_FOREIGN_ENEMY = 8;
        public static final int ENEMY_CLAN = 9;
        public static final int TOTAL_TARGETS = 9;
        
        
        public Map<String, Double> stats;
        public Map<String, Double> liking;
        //holds knowledge of what each creature is doing
        //can be outdated... that's the fun :P.
        //Some may choose to tell you knowledge or not.
        public Map<String, String> knowledge;
        
        public String name;
        
        public ClanWrap clan;
        public GroupWrap group;
        public GroupWrap previousGroup;
        
        public CreatureWrap target;
        public boolean toKill = false;
        public boolean isFighting = false;
        public boolean retreating = false;
        public double startingEnemyHealth;
        //use this to find action of creature
        //creature.name+action
        public String action;
        
        public int rampageTime = 0;
        public int regard = 0;
        public double startingHealth = 0;
        public String currentAction = "";
        public String pendingAction = "";
        
        public DungeonRoomWrap currentRoom;
        public ArrayList<Clan.Surname> bloodline;
        private double movingProgress;
        
        public static String[] tactical = {"wisdom","patience","sanity"};
        
        public boolean played = false;
        private String uuid;
    	
    	public String myid() {
    		return uuid;
    	}
        
        public Creature(Group parentGroup) {
            group = new GroupWrap(parentGroup);
            clan = new ClanWrap(group.get().clan.get());
            liking = new HashMap<>();
            bloodline = new ArrayList<>();
            stats = new HashMap<>();
            knowledge = new HashMap<>();
            
            uuid = DungeonRollcall.uuid();
            DungeonRollcall.add(this);
            
            
        }
    DungeonRollcall.java
    Code:
        }
        
        public static boolean add(Creature data) {
            //assert(allCreatures.containsKey(data.myid()));
    		log(DungeonRollcall.class.getClassLoader().toString());
    		log(Clan.class.getClassLoader().toString());
    		log(Creature.class.getClassLoader().toString());
            allCreatures.put(data.myid(), data);
            addedData = true;
            return true;
        }
    	
        
        public static boolean add(Group data) {
            assert(allGroups.containsKey(data.uuid));
            allGroups.put(data.uuid, data);
            addedData = true;
            return true;
        }
        
        public static boolean add(Clan data) {
            assert(allClans.containsKey(data.uuid));
            allClans.put(data.uuid, data);
            addedData = true;
            return true;
        }
        
        public static boolean add(DungeonRoom data) {
            assert(allDungeonRooms.containsKey(data.uuid));
            allDungeonRooms.put(data.uuid, data);
            addedData = true;
            return true;
        }
        
        public static boolean add(DungeonFloor data) {
            assert(allDungeonFloors.containsKey(data.uuid));
            allDungeonFloors.put(data.uuid, data);
    
            addedData = true;
            return true;
        }
        
        public static String uuid() {
            if (!addedData) {
                assert(false);
                log("old UUID not used");
            }
            addedData = false;
            return UUID.randomUUID().toString();
        }
    }
    I've tried making uuid field public before, it didn't work. Also removed getter, still didn't work. Can still access toString() of Creature from DungeonRollcall. Why? Please how do I fix?
    Last edited by VictorN; June 26th, 2021 at 06:53 AM. Reason: Inserted line breaks in the error message

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,874

    Re: IllegalAccessError, cannot acces class

    The posted code looks like it should work. Are there other versions of the Creature class where myid() was not public?
    Norm

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,495

    Re: IllegalAccessError, cannot acces class

    Does the Creature class need to be instantiated through a derived class?

  4. #4
    Join Date
    Jun 2021
    Posts
    5

    Re: IllegalAccessError, cannot acces class

    No, the previous version had a public uuid and no myid, so I thought myid getter might work, the version before that had no uuid. And creature is not gotten through derivative and is not used as one. I tried this on another device that had not used java before, where no dex or class or system files could be loaded, still got error.

  5. #5
    Join Date
    Jun 2021
    Posts
    5

    Re: IllegalAccessError, cannot acces class

    It cannot access other things like currentAction, but can access stuff all classes have like toString.
    And I find it strange it says virtual method? Doesn't that mean that the instance is null?(Couldn't edit)

  6. #6
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,874

    Re: IllegalAccessError, cannot acces class

    Did you do a clean and a full rebuild?

    Try making the Creature class public.
    Last edited by Norm; June 26th, 2021 at 03:15 PM.
    Norm

  7. #7
    Join Date
    Jun 2021
    Posts
    5

    Re: IllegalAccessError, cannot acces class

    Quote Originally Posted by Norm View Post
    Did you do a clean and a full rebuild?

    Try making the Creature class public.

    Yes I did a full rebuild, but Norm....
    Norm... ... ... ... Norm...public class Creature...I must have forgotten the public when I typed.... ...
    ...
    I CAN'T BELIEVE I DIDN'T SEE IT! I SEARCHED FOR HOURS BEFORE POSTING THIS THREAD! THANK YOU!!!!!!!!!!!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured