tags:

views:

93

answers:

2

Hi there,

I'm translating this code to Clojure. As you can see, I have to extend the class ArthurFrame, yet I'm getting an IllegalAccessError everytime I use (proxy [ArthurFrame] [] ...).

Any idea why? Here is the class's source.

Thanks!

EDIT: Here is the full error stack for running (proxy [ArthurFrame] []) on the REPL.

EDIT 2: Actually it seems that even instantiating the class yields an error. Here is the output from (ArthurFrame. wid):

tried to access class com.trolltech.demos.ArthurFrame from class user$eval__2205
  [Thrown class java.lang.IllegalAccessError]

Restarts:
 0: [ABORT] Return to SLIME's top level.

Backtrace:
  0: user$eval__2205.invoke(NO_SOURCE_FILE:1)
  1: clojure.lang.Compiler.eval(Compiler.java:4642)
  2: clojure.core$eval__5254.invoke(core.clj:2031)
  3: swank.commands.basic$eval_region__907.invoke(basic.clj:40)
  4: swank.commands.basic$eval_region__907.invoke(basic.clj:31)
  5: swank.commands.basic$eval__927$listener_eval__929.invoke(basic.clj:54)
  6: clojure.lang.Var.invoke(Var.java:359)
  7: user$eval__2202.invoke(NO_SOURCE_FILE)
  8: clojure.lang.Compiler.eval(Compiler.java:4642)
  9: clojure.core$eval__5254.invoke(core.clj:2031)
 10: swank.core$eval_in_emacs_package__455.invoke(core.clj:59)
 11: swank.core$eval_for_emacs__533.invoke(core.clj:128)
 12: clojure.lang.Var.invoke(Var.java:367)
 13: clojure.lang.AFn.applyToHelper(AFn.java:179)
 14: clojure.lang.Var.applyTo(Var.java:476)
 15: clojure.core$apply__4379.invoke(core.clj:434)
 16: swank.core$eval_from_control__458.invoke(core.clj:66)
 17: swank.core$eval_loop__461.invoke(core.clj:71)
 18: swank.core$spawn_repl_thread__595$fn__627$fn__629.invoke(core.clj:183)
 19: clojure.lang.AFn.applyToHelper(AFn.java:171)
 20: clojure.lang.AFn.applyTo(AFn.java:164)
 21: clojure.core$apply__4379.invoke(core.clj:434)
 22: swank.core$spawn_repl_thread__595$fn__627.doInvoke(core.clj:180)
 23: clojure.lang.RestFn.invoke(RestFn.java:402)
 24: clojure.lang.AFn.run(AFn.java:37)
 25: java.lang.Thread.run(Thread.java:619)
+1  A: 

The most likely cause of your problem is that something has not been recompiled. Here's the javadoc description of the IllegalAccessError exception:

Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.

Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.

To be more specific, this normally happens when you have classes A and B, where B depends on some members of A. Then you do something like this:

  1. You compile A, then B.

  2. Make an incompatible change to A and recompile it without recompiling B. In this case, the change would involve reducing the visibility of some member of A that B uses so that the member should no longer be visible to B.

  3. Run an application that uses A and B and and you will get an IllegalAccessError.

EDIT

The proxy class that is trying to do the accessing looks like it must have been generated by the Clojure compiler. So maybe there is a Clojure compiler bug ... or maybe you changed the visibility of ArthurFrame after you ran the Clojure compiler. Either way, one possible fix is to change the visibility of the ArthurFrame to public.

Stephen C
+3  A: 

The problem is that ArthurFrame visibility is package not public so the proxy can't access it since the proxy doesn't belong to the package com.trolltech.demos. You have to make ArthurFrame public.

cgrand
Living and learning... I thought the default behaviour was to set it public!
konr