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: AW: java.sql.ResultSet.getObject() Kawa(?) bug, (as <int> 1)


Hoehle, Joerg-Cyril wrote:
Per Bothner wrote:

Kawa should be able to figure out that getObject(int) is a closer
match than getObject(String).  I'm not sure what it doesn't.
Actually, I think (though I haven't verified) that the reason that
getObject(String) is chosen is that <int> is not a sub-type of
<integer> - there are <integer> values that will not fit in an <int>,
but all <integers> can be converted to <String>, using toString.

To fix this we need a special hack to ensure that converting to
<String> has lower priority.  I'll have to think about how to do that.

bad: getObject getLong getBigDecimal getDouble getFloat getTimestamp
bad means: java.sql.SQLException: Column not found
(i.e. findColumn in backtrace), not the old "Argument  <2spaces>to
'...getInt' has wrong type", which seems gone now.
So what happens it that it picks the getObject(String) method,
converting the integer argument to a String using toString.

I tried a little test class with overloade getObjects, and then
did:
(let ((r :: <RS> (make <RS>)) (i :: <int> 12)) (invoke r 'getObject i))

That still picked getObject(String), because the compiler doesn't get
to inline the invoke in "immediate" mode.  The logic is in immediate
mode we want fast and simple compilation.  I tending to think that's a
mistake - it is better to have consistency between immediate mode
and compile-to-file mode, given that the compilation overhead is trivial
and partly made up by faster execution.  So I tried the attached patch,
which seems to fix things.  Could you try it?
--
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/
Index: Translator.java
===================================================================
RCS file: /cvs/kawa/kawa/kawa/lang/Translator.java,v
retrieving revision 1.66
diff -u -r1.66 Translator.java
--- Translator.java	25 Jul 2002 17:44:17 -0000	1.66
+++ Translator.java	15 Aug 2002 16:53:12 -0000
@@ -336,7 +336,7 @@
                 || (separate && decl.isProcedureDecl()))
               decl = null;
           }
-        else if (! immediate && value instanceof Named)
+        else if (value instanceof Named)
           {
             if (value instanceof AutoloadProcedure)
               {

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