This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: kawa-java string compatibility proposal


Steve Yegge wrote:
The only glitch in this otherwise very convenient behavior occurs when a Java method expects a CharSequence, which is a relatively new superinterface of java.lang.String. In that case, Kawa doesn't
perform the conversion:


(let ((pattern (java.util.regex.Pattern:compile "(f+)(o+)")))
  (invoke pattern 'matcher "foo"))

If you configure CVS Kawa with --select-java5, it works:


#|kawa:1|# (let ((pattern (java.util.regex.Pattern:compile "(f+)(o+)")))
  (invoke pattern 'matcher "foo"))
java.util.regex.Matcher[pattern=(f+)(o+) region=0,3 lastmatch=]

The default "select" is "java2" - which means "jdk 1.2".  I could
define an option for "jdk 1.4" but I don't think it's worth it.
For now I think jdk 1.2 (intersected with gcj/classpath) is a
reasonable default.  Unfortunately, you can't use the same Kawa
source for jdk 1.4 and jdk 1.5.

Argument #1 ((f+)(o+)) to
'java.util.regex.Pattern.matcher(java.lang.CharSequence)' has wrong type
(java.util.regex.Pattern) (expected: java.lang.CharSequence)

The error message above seems a bit confused; the argument is a
gnu.lists.FString.

Kawa was somewhat inconsistent argument numbering, sometimes starting at 1 and sometimes at 0. That has been fixed in CVS Kawa:

<unknown>:0: warning - cannot convert literal (of type gnu.lists.FString) to java.lang.CharSequence
Argument #2 (foo) to java.util.regex.Pattern.matcher(java.lang.CharSequence)'
has wrong type (gnu.lists.FString)


(Argument #1 is the 'this' argument.)

We might be able to make the behavior fully seamless by having
gnu.lists.FString implement CharSequence.  There are only four
methods on CharSequence, and FString already implements three of
them.  The fourth is the subSequence() method, which could simply
call substring() and return the result.

Fixed in CVS - if you configure with --select-java5 .


More later.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]