Hi all,

just to make the ticket complete (somehow I can create tickets but
cannot annotate them as a watcher  in assembla - but maybe I am doing
something wrong).

Below you see a simple TestCase.
* This source code below compiles using javac 1.6.0.15 (MacOSX 10.6)
* The identity method can be successfully invoked within java
* The call to .identity using the clojures Reflector fails.

The point is not whether this Java code is potentially flawed but that
there exist code (especially the JDI implementation) that cannot be
used refeclively from clojure yet it is OK to invoke it using JVM
bytecodes.

My patched Reflector that usees the target instance's class to find
the public method is working though. I can send you the patch.

-- Jakob

============================================================
TestCase.java ====
public class TestCase {
    public interface Intf {
        public String identity(String value);
    }
    static class B {
        public String identity(String value) {
            return value;
        }
    }
    static class A extends B implements Intf {
    }
    public Intf newImpl() {
        return new A();
    }
    public static void main(String[] args) {
        System.out.println(new TestCase().newImpl().identity("test"));
    }
}

===============================================================  JAVA
======
$ java -classpath classes TestCase
test

===============================================================  REPL
======
$ java -classpath src:classes:lib/clojure-1.2.0-master-SNAPSHOT.jar
clojure.main
Clojure 1.2.0-master-SNAPSHOT
user=> (.identity (.newImpl (.newInstance (Class/forName "TestCase")))
"test")
java.lang.IllegalArgumentException: Can't call public method of non-
public class: public java.lang.String TestCase
$B.identity(java.lang.String) (NO_SOURCE_FILE:0)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to