bugKawa - Bugs: bug #15725, anon classes defined by (object...

 
 

bug #15725: anon classes defined by (object ...) not being written

Submitted by:  tk <huh>
Submitted on:  Sun 12 Feb 2006 07:39:00 PM UTC  
 
Category: Code generationSeverity: 3 - Normal
Item Group: Run-time exceptionStatus: Fixed
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 20 Feb 2006 06:03:37 AM UTC, comment #5:

Ok, I checked in a patch, partly based on your patch. Thanks.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Fri 17 Feb 2006 05:47:14 PM UTC, comment #4:

attached patch changes compiler to ensure that the
main class in a compiled archive is always the first.
loader modifed to assume this convention.

tk <huh>
Wed 15 Feb 2006 01:17:40 AM UTC, comment #3:

The name of the main class should not depend on whether there are other auxiliary classes.

However, I also think that the name of the main class should be the same whather we're compiling to class files or to an archive. This isn't essential, but I think that seems desirable.

This can be "fixed" by removing this line in Compilation's compileToArchive method:
mexp.setName(LambdaExp.fileFunctionName);

Since the name of the main class when compiling to class files depends on the name of the source file, it follows we can't depend on a fixed name like "atFileLevel". So picking the first class in the archive makes sense.

One possible solution is to make sure we call addClass on the main file before we call it on the other classes. However, we have to be a little bit careful. There might be a module-name declaration in the source file, so at least naming the main class must wait a little bit. (However, it is reasonable to disallow a module-name after we have seen an expression that creates a class.)

Perhaps you could send me your patch. I won't necessarily use it, but I'll think about the options.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Tue 14 Feb 2006 07:38:57 PM UTC, comment #2:

I have a potential fix for this bug, depending on the cause,
which is ambiguous. As the previous comment shows, classes are
named differently in the compiled archive depending on whether
the source file contains an (object ...) form. When the object
form is present, class names are generated based on the file
name, otherwise their names are based on "atFileLevel"
(i.e. LambdaExp.fileFunctionName).

But the loader expects the main class to be named "atFileLevel",
so the filename-derived classname breaks. The fix I've implemented
arranges for the the main class to always be the first entry
written to the archive, so the loader can assume the same
regardless of the class name.

If the actual problem is that the class names are being generated
incorrectly, this is the wrong fix. If the preceding description
is correct, then I can provide a patch.

tk <huh>
Sun 12 Feb 2006 11:38:08 PM UTC, comment #1:

original description of bug wasn't accurate. problem is that
when the (object ...) form appears in a source file, the
classes are named differently in the compiled archive, in
a way that the kawa.load.loadCompiled doesn't expect.

$ cat bug.scm
(define (foo)
#f)

#|
(define (foo2)
(object ()
((fun) <int>
(+ 1 2))))
|#

$ rlwrap java -jar kawa-1.8.1alpha.jar
#|kawa:1|# (compile-file "bug.scm" "bug.zip")

$ unzip -t bug.zip
Archive: bug.zip
testing: atFileLevel.class OK
No errors detected in compressed data of bug.zip.

$ cat bug.scm
(define (foo)
#f)

(define (foo2)
(object ()
((fun) <int>
(+ 1 2))))

#|kawa:2|#
#|kawa:3|# (compile-file "bug.scm" "bug.zip")
#|kawa:4|#
[3]+ Stopped rlwrap java -jar kawa-1.8.1alpha.jar
$ unzip -t bug.zip
Archive: bug.zip
testing: bug$0.class OK
testing: bug.class OK
No errors detected in compressed data of bug.zip.

tk <huh>
Sun 12 Feb 2006 07:39:00 PM UTC, original submission:

classes defined with (object ..) are not being written
to the output archive.
(current 2/12/06 version of kawa)

$ cat bug.scm
(define (foo)
(object ()
((fun) <int>
(+ 1 2))))

$ rlwrap java -jar kawa-1.8.1alpha.jar
#|kawa:1|# (compile-file "bug.scm" "bug.zip")
#|kawa:2|# (load "bug.zip")
class not found in load
at kawa.standard.load.loadCompiled(load.java:88)
at kawa.standard.load.apply(load.java:196)
at kawa.standard.load.apply2(load.java:157)
at kawa.standard.load.apply1(load.java:147)
at gnu.mapping.Procedure.apply(Procedure.java:145)
at gnu.mapping.Procedure.apply(Procedure.java:128)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:261)
at kawa.Shell.run(Shell.java:230)
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: atFileLevel
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at gnu.bytecode.ZipLoader.loadClass(ZipLoader.java:100)
at kawa.standard.load.loadCompiled(load.java:77)
... 11 more
#|kawa:3|#
$ unzip -t bug.zip
Archive: bug.zip
testing: bug$0.class OK
testing: bug.class OK
No errors detected in compressed data of bug.zip.

tk <huh>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #1893:  cdiff added by huh (5KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 6 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Mon 20 Feb 2006 06:03:37 AM UTCbothnerOpen/ClosedOpen=>Closed
Mon 20 Feb 2006 06:03:36 AM UTCbothnerStatusConfirmed=>Fixed
Fri 17 Feb 2006 05:47:14 PM UTChuhAttached File-=>Added cdiff, #3412
  Carbon-Copy-=>Added -unavailable-
Wed 15 Feb 2006 01:17:40 AM UTCbothnerStatusNone=>Confirmed
  Assigned toNone=>bothner

Back to the top


Powered by Savane 3.1-cleanup1