bugKawa - Bugs: bug #34859, (require ...) behaves differently...


bug #34859: (require ...) behaves differently between repl and direct invocation

Submitted by:  Robin Abbi <coderobot>
Submitted on:  Fri 18 Nov 2011 11:43:43 PM UTC  
Category: Scheme languageSeverity: 3 - Normal
Item Group: Unexpected resultStatus: Invalid
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

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


Mon 28 Nov 2011 04:25:17 AM UTC, comment #5:

"it looks ... as if the ant task and kawa -C may be not identical processes."

The difference is the --main flag, which is enabled because the Ant task says main="true".

And setting main makes hello and goodbye non-exported:

See http://www.gnu.org/software/kawa/Compiling.html#Application-compilation :
"If there is no explicit module-export in a module compiled with --main then no names are exported. (The default otherwise is for all names to be exported.)"

So the fix is to either edit the kawac task to say main="false" or to add:
(module-export hello goodbye)
to messages.scm.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Sun 20 Nov 2011 03:14:28 PM UTC, comment #4:

build.xml included at this url: https://savannah.gnu.org/bugs/download.php?file_id=24398

Robin Abbi <coderobot>
Sun 20 Nov 2011 04:18:09 AM UTC, comment #3:

I'm not seeing the problem with combination B iii.
The method hello should be public in messages.class, so you should not see the IllegalAccessError.

Perhaps you could show or attach the build.xml file you're using?

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Sat 19 Nov 2011 09:18:54 PM UTC, comment #2:

I downloaded the latest from svn.

I did an experiment:

A. Compile using kawa -C
B. Compile using kawac ant task.

For each of A and B, run controller class thus:
i) <path-to>/kawa controller
ii) java -cp <path-to>/kawa-1.11.jar:. controller
iii) <path-to>/kawa and then interactively enter the code from controller.scm

i) OK, runs without error
ii) OK, runs without error
iii) OK, runs without error

i) OK, runs without error
ii) OK, runs without error
iii)java.lang.IllegalAccessError: tried to access method messages.hello(Ljava/lang/Object;)Ljava/lang/String; from class atInteractiveLevel$2

I'm too new to Kawa to make a valid conclusion, but it looks to me as a beginner as if the ant task and kawa -C may be not identical processes. But as I say, I'm new to Kawa so I could be well off track. I'm enclosing a copy of my build.xml for information.

(file #24398)

Robin Abbi <coderobot>
Sat 19 Nov 2011 12:42:57 AM UTC, comment #1:

It works for me ...
However, note:
(1) I used the latest Kawa from the source Subversion repository.
Could you try with that?
(2) I did not use the kawac ant task. If after trying (1) you still have the problem, either try invoking kawa (or java kawa.repl) directly from the command-line (preferable) or also include the build.xml file you're using.
(3) I simplified to use the default package and current directory - i.e. <messages> rather than <com.example.messages>.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Fri 18 Nov 2011 11:43:43 PM UTC, original submission:

1. Create a library 'messages.scm' with two functions:

(define hello
(lambda (name)
(format "hello ~a" name)))

(define goodbye
(lambda (name)
(format "goodbye ~a" name)))

2. Compile using the kawac Ant task.

3. Create a program "controller.scm" to use the above defined functions

(require <com.example.messages>)
(format #t "~a~%" (com.example.messages:hello "world"))

Compile (using kawac as before)

Run: java -cp build/classes:kawa-1.11.jar com.example.controller

Output: "hello world"

4. Now try to do the same thing from the repl

Start the repl:

java -cp build/classes:kawa-1.11.jar kawa.repl

then at the prompt:

(require <com.example.messages>) [ENTER]
(format "~a~!" (com.example.messages:goodbye "world"))

and get the output:

"no slot 'goodbye' in com.example.messages"

6. Workaround: If I explicitly use (export goodbye) in messages.scm then the repl finds the method ok.

I was not expecting this difference in behaviours between invocation direct and invocation at the repl. Possibly same as bug report #32726?

Robin Abbi <coderobot>


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

Attach File(s):

Attached Files
file #24398:  build.xml added by coderobot (1012B - text/xml)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by bothner (Posted a comment)
  • -unavailable- added by coderobot (Submitted the item)

    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 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 28 Nov 2011 04:25:17 AM UTCbothnerStatusWorks For Me=>Invalid
    Sat 19 Nov 2011 09:18:54 PM UTCcoderobotAttached File-=>Added build.xml, #24398
    Sat 19 Nov 2011 12:42:57 AM UTCbothnerStatusNone=>Works For Me
      Assigned toNone=>bothner

    Back to the top

    Powered by Savane 3.1-cleanup