[ sisc-Bugs-2426937 ] define-java-classes inside module leaks out

"SourceForge.net" <[email protected]> Sun, 14 Dec 2008 11:34:13 +0000
Newsgroups gmane.comp.java.sisc.devel
Message-ID <[email protected]>
Bugs item #2426937, was opened at 2008-12-14 11:34
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=379534&aid=2426937&group_id=23735

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Norman Gray (normang)
Assigned to: Nobody/Anonymous (nobody)
Summary: define-java-classes inside module leaks out

Initial Comment:
A definition of a symbol inside a module appears to be disrupting definitions of the same symbol elsewhere.

Consider the following:



%% cat MyWriter.java
public class MyWriter {
   public void write(java.io.OutputStream w, int x) {
       System.out.println(x);
   }
   public void write(java.io.Writer w, int x) {
       System.out.println(x);
   }
}
%% javac MyWriter.java
%% cat s2j-module.scm
(import s2j)

(module s2j-module
   (s2j-test)
 (define-java-classes
   <my-writer>
   ;<com.hp.hpl.jena.rdf.model.model> ; where the problem originally appeared
   )
 (define (s2j-test)
   #f))
%% cat test-s2j-module.scm
(require-library 's2j-module)
(import s2j-module)

(format #t "test-s2j-module~%")
%% cat test-write.scm
(import s2j)

(define system-out
 ((generic-java-field-accessor 'out) (java-null (java-class '|java.lang.System|))))
(define-java-classes <java.io.output-stream-writer>)
(define-generic-java-methods write flush)
(let ((writer (java-new <java.io.output-stream-writer> system-out)))
 (write writer (->jstring "Wibble\n"))
 (flush writer))
%% sisc
SISC (1.16.6)
#;> (load "test-write.scm")
Wibble
#;> ^D
%% sisc
SISC (1.16.6)
#;> (load "test-s2j-module.scm")
test-s2j-module
#;> (load "test-write.scm")
Error in load: evaluation error at file:/checkouts/agast/repositories/qadi/code/qadi/src/test/scm/reduction/test-write.scm:7:1
---------------------------
To enable more detailed stack tracing, set the dynamic parameter max-stack-trace-depth to a non-zero value, e.g. 16.
---------------------------
Some stack trace entries may have been suppressed. To see all entries set the dynamic parameter suppressed-stack-trace-source-kinds to '().
===========================
Caused by Error: no applicable method for args (#<java java.io.OutputStreamWriter java.io.OutputStreamWriter@7aa93a16> #<java java.lang.String Wibble
>) in generic procedure #0=#<procedure write>
file:/checkouts/agast/repositories/qadi/code/qadi/src/test/scm/reduction/test-write.scm:8:3: <indeterminate call>
#;> ^D
%%





The s2j-module.scm file declares a module s2j-module, and defines a Java class, namely MyWriter; this class has a number of write(...) methods (it appears to require more than one method to be present).

The test-s2j-module.scm file simply imports this s2j-module module.

test-write.scm writes a string to System.out using the Writer.write(String) method.  Run by itself, test-write.scm works.  When run after test-s2j-module.scm, however, the same call to Writer.write(String) fails.  I can't see why that would be happening.



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=379534&aid=2426937&group_id=23735

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/