On Jun 13, 2009, at 10:46 PM, Stephen C. Gilardi wrote:
user=> (.setCharAt s 0 \c)java.lang.IllegalArgumentException: Can't call public method of non- public class: public void java.lang.AbstractStringBuilder.setCharAt(int,char) (NO_SOURCE_FILE:0)I'm not sure why.
StringBuilder extends AbstractStringBuilder (though the JavaDoc docs lie and say it extends Object). AbstractStringBuilder has default accessibility (not public, protected, or private) which makes the class inaccessible to code outside the java.lang package.
In both Java SE 5 and Java SE 6, StringBuilder does not contain a .setCharAt method definition. It relies on the inherited public method in AbstractStringBuilder. (I downloaded the source code for both versions from Sun to check.)
In Java SE 5, when Clojure checks whether or not .setCharAt on StringBuilder is public, it finds that it's a public method of a non- public base class and throws the exception you saw. (It looks like you're using a version of Clojure older than 18 May 2009 (Clojure svn r1371). Versions later than that print the more detailed message I saw.)
In Java SE 6, Clojure's checks for accessibility of this method succeed and the method call works.
I'm not sure whether or not Clojure could be modified to make this method call work in Java 5. Google searches turn up discussion that this pattern of using an undocumented abstract superclass with non- public accessibility is not common in the JDK.
--Steve
smime.p7s
Description: S/MIME cryptographic signature