bugKawa - Bugs: bug #15881, classnotfound exception compiling...

 
 

bug #15881: classnotfound exception compiling application of define-syntax macro

Submitter:  tk <huh>
Submitted:  Thu 23 Feb 2006 03:55:26 PM UTC
   
 
Category:  Code generation Severity:  3 - Normal
Item Group:  Run-time exception Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 31 Oct 2006 07:53:46 PM UTC, comment #3: 

I checked in the attached patch.

I fixed the concern in comment #2 by making the Class->Type map a WeakHashMap.

Please let me know how this works for you.

Per Bothner <bothner>
Group administrator
Wed 10 May 2006 06:55:11 PM UTC, comment #2: 


the "possible fix" suggested in comment #1 (i.e. adding Type.make(clas) to loadCompiled in load.java) does indeed have an undesirable side effect -- leaking memory. When a file containing compiled code is reloaded, handles on the old code are not released. The hack is still useful as a temporary fix, but its correctness is questionable.

tk <huh>
Mon 27 Feb 2006 10:47:38 PM UTC, comment #1: 


Possible fix -- works for my code, but I haven't sorted out whether this has
undesirable side-effects. The modification to load.java establishes the
reflectClass for the ObjectType of the module's main class at load time.
(if reflectClass isn't set, ObjectType.getReflectClass tries to set it
later using Class.forName -- this with a ClassNotFoundException, because
the class will not be accessible by name in the current classloader).



RCS file: /cvs/kawa/kawa/kawa/standard/load.java,v
retrieving revision 1.57
diff -c -r1.57 load.java
* kawa/standard/load.java     20 Feb 2006 06:02:41 -0000      1.57
--- kawa/standard/load.java     27 Feb 2006 22:30:28 -0000
*************
* 79,84 **
--- 79,85 ----
            throw new RuntimeException("load: "+name+" - no module in archive");
        gnu.kawa.reflect.ClassMemberLocation.defineAll(proc, env);
        ((ModuleBody) proc).run();
+       gnu.bytecode.Type.make(clas);
        }
      catch (java.io.IOException ex)
        {

tk <huh>
Thu 23 Feb 2006 03:55:26 PM UTC, original submission:  

When transforming a form using a define-syntax macro, the compiler
throws a class not found exception trying to reference the main
class of the module the macro appears in. This happens only on the
first invocation of the compiler, subsequently the transformation
completes without exception.

Exception occurs whether using compile-file or repl.

No word yet on a fix.


$ cat bug.scm
(define-syntax dotimes
  (syntax-rules ()
    ((_ (var count) . body)
     (let ((n count))
       (let iter ((var :: <int> 0))
         (when (< var n)
           (begin . body)
           (iter (+ var 1))))))))

$ rlwrap java -jar kawa-1.8.1alpha.jar
#|kawa:1|# (compile-file "bug.scm" "bug.zip")
#|kawa:2|# (load"bug.zip")
#|kawa:3|# (dotimes (i 10) i)
java.lang.RuntimeException: no such class: bug
        at gnu.bytecode.ObjectType.getReflectClass(ObjectType.java:77)
        at gnu.expr.ModuleInfo.setupModuleExp(ModuleInfo.java:49)
        at gnu.expr.ModuleExp.firstDecl(ModuleExp.java:427)
        at gnu.expr.NameLookup.push(NameLookup.java:74)
        at gnu.expr.Compilation.pushChain(Compilation.java:2170)
        at gnu.expr.Compilation.pushChain(Compilation.java:2168)
        at gnu.expr.Compilation.setCurrentScope(Compilation.java:2161)
        at kawa.lang.Translator.setCurrentScope(Translator.java:560)
        at kawa.lang.Translator.scanForm(Translator.java:953)
        at kawa.lang.Macro.scanForm(Macro.java:194)
        at kawa.lang.Translator.scanForm(Translator.java:993)
        at gnu.kawa.lispexpr.LispLanguage.parse(LispLanguage.java:56)
        at kawa.Shell.run(Shell.java:207)
        at kawa.Shell.run(Shell.java:172)
        at kawa.Shell.run(Shell.java:159)
        at kawa.repl.main(repl.java:768)
Caused by: java.lang.ClassNotFoundException: bug
        at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:219)
        at gnu.bytecode.ObjectType.getReflectClass(ObjectType.java:65)
        ... 15 more
#|kawa:4|# (dotimes (i 10) i)
#|kawa:5|#

$ unzip -t bug.zip
Archive:  bug.zip
    testing: bug.class                OK

tk <huh>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #11121:  mac-class.patch added by bothner (2KiB - text/x-patch - Patch.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bothner (Updated the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-02-28 bothner Open/ClosedOpen Closed
    2006-10-31 bothner StatusNone Fixed
        Assigned toNone bothner
        Attached File- Added mac-class.patch, #11121

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code