Let me see if I follow the plan for gen-class:
By and large, most common cases will be handled with the :gen-class
option of (ns ...).
For those that need to generate classes in a more flexible manner, the
more primitive gen-class function (as opposed to gen-and-load-class or
gen-and-save-class) will still be exposed to users who need/want to
make use of that?
e.g. Chas' idea for generating BeanInfo classes would fall under a
call to gen-class, which has no constraints on the name of the class
generated in relation to the namespace.
And on top of that, the ASM lib is built into the distribution so
anyone who wants to generate fully customized bytecode can do so.
Do I have that right?
/mike.
You asked for it. :-)
Here's a minimal applet .clj:
(ns net.n01se.Tree
(:gen-class
:extends java.applet.Applet))
Since it's missing a main fn, I would expect an exception like the this:
java.lang.UnsupportedOperationException: net.n01se.Tree/-main not
defined (NO_SOURCE_FILE:0)
Using svn 1136 I can compile and get the above exception from a normal
Clojure REPL, but if I try to use it as an applet:
$ appletviewer test.html
java.lang.ExceptionInInitializerError
at clojure.lang.Namespace.<init>(Namespace.java:31)
at clojure.lang.Namespace.findOrCreate(Namespace.java:116)
at clojure.lang.Var.internPrivate(Var.java:95)
at net.n01se.Tree.<clinit>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:798)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:727)
at sun.applet.AppletPanel.run(AppletPanel.java:380)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.security.AccessControlException: access denied
(java.lang.RuntimePermission createClassLoader)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:342)
at java.security.AccessController.checkPermission(AccessController.java:553)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:611)
at java.lang.ClassLoader.<init>(ClassLoader.java:218)
at java.security.SecureClassLoader.<init>(SecureClassLoader.java:71)
at java.net.URLClassLoader.<init>(URLClassLoader.java:99)
at clojure.lang.DynamicClassLoader.<init>(DynamicClassLoader.java:30)
at clojure.lang.RT.<clinit>(RT.java:243)
... 14 more
You can see it found my class okay, but it looks like there may be
some dynamic classloader stuff still going on?
--Chouser