users@glassfish.java.net

IllegalAccessError when accessing an anonymous inner class

From: <glassfish_at_javadesktop.org>
Date: Mon, 22 Mar 2010 12:19:22 PDT

I have need of a sorted list so I called Collections.Sort(Collection, Comparator) using an inner class for the Comparator:

Collections.sort(menus, new Comparator<Menu>() {

                        public int compare(Menu m1, Menu m2) {
                                int firstPriority = m1.getPriority();
                                int secondPriority = m2.getPriority();
                                if (firstPriority < secondPriority) {
                                        return -1;
                                } else if (firstPriority == secondPriority) {
                                        return 0;
                                } else {
                                        return 1;
                                }
                        }
                });

Whenever I try and run this I get an IllegalAccessError:

java.lang.IllegalAccessError: tried to access class uk.co.monkeypower.openchurch.core.layout.beans.LayoutManagerBean$1 from class uk.co.monkeypower.openchurch.core.layout.beans.LayoutManagerBean

This would seem like some sort of ClassLoader issue - can anyone shed any light?
[Message sent by forum member 'phunni']

http://forums.java.net/jive/thread.jspa?messageID=393185