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

 
 

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

Submitter:  Robin Abbi <coderobot>
Submitted:  Fri 18 Nov 2011 11:43:43 PM UTC
   
 
Category:  Scheme language Severity:  3 - Normal
Item Group:  Unexpected result Status:  Invalid
Privacy:  Public Assigned to:  bothner
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group administrator
Sun 20 Nov 2011 03:14:28 PM UTC, comment #4: 
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>
Group administrator
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

Results:
A:
i) OK, runs without error
ii) OK, runs without error
iii) OK, runs without error

B:
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

Conclusion:
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>
Group administrator
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 Files:
   
   
Comment:
   

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
  • -email is unavailable- added by bothner (Posted a comment)
  • -email is unavailable- added by coderobot (Submitted 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
    2011-11-28 bothner StatusWorks For Me Invalid
    2011-11-19 coderobot Attached File- Added build.xml, #24398
    2011-11-19 bothner StatusNone Works For Me
        Assigned toNone bothner

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code