From: Timothy H. <tim...@ma...> - 2003-01-07 14:00:08
|
On Monday, January 6, 2003, at 10:00 PM, david may wrote: > I found this today, and it seems usefull. > are there any gotchas to this method oc creating > new class in jscheme? Thanks for the reference and the nice simple test below! It certainly looks like a fun domain to play in! There will be problems with security violations (e.g. it won't work with unsigned applets and using Java Web Start you'll have to sign the jars). > > Sometimes you want to make a subclass just to > override the paint method. Good point. This has in fact been the only reason we need to write Java code for Jscheme applications. Have you tried to use this to create an instance of Panel (or JPanel) that overrides paint? > > the jar file is here.. > http://www.csg.is.titech.ac.jp/~chiba/javassist/ > > ------------ a simple test ----------- > (import "javassist.*") > (define pool (javassist.ClassPool.getDefault)) > (define cc (.makeClass pool "Silly")) > (define m (CtNewMethod.make > "public int silly(int dx) { return 2+dx; }" cc)) > (.addMethod cc m) > > (define cloader (Loader. pool)) > (define anewclass (.loadClass cloader "Silly")) > (define ss1 (.newInstance anewclass)) > > (.silly ss 1) shouldn't this be (.silly ss1 1) ---Tim--- |