This is the mail archive of the kawa@sourceware.org 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 regressions since 1.9.90?


On Oct 1, 2010, at 6:00 PM, Jamison Hope wrote:

Hi Per,

I just tried rebuilding some code with the latest Kawa from SVN which I had previously compiled using 1.9.90, and I now see a few warnings/errors which I didn't see before:

One is of the form "warning - type integer is incompatible with required type double" in statements such as (javax.vecmath.Vector3d -1.5 0 0). Apparently Kawa forgot how to promote an int to a double?

The other is "warning - no known slot 'Environment' in java.lang.Object" / "invalid type spec (must be "type" or 'type or <type>)"
in a file which looks like this:


(define-alias Environment foo.Environment) ;; i.e. not gnu.mapping.Environment

(define-simple-class EnvUser (baz.Superclass)
 ((main (args :: String[])) allocation: 'static :: void
  ((EnvUser):bar (Environment)))

 ((bar (e :: Environment)) ;; this is where the compiler complains
  (format #t "~A ~A~%" (this) e)))
;; EOF

If I rename my alias to "Env" instead of "Environment", then it compiles cleanly. Now here's the extra weird part: in trying to make a simple test case to demonstrate the problem, I discovered that it also depends upon which class I inherit from. If I make EnvUser a subclass of java.lang.Object, for instance, then it compiles cleanly even if the alias is called Environment. It's only with one particular superclass that I see the errors. Unfortunately it's not a class whose source I'm at liberty to publish right now, but as far as I can tell there isn't anything special about it; it's just a public abstract class written in Java. I'll keep digging, but in the mean time do you have any ideas?

I found what triggers the second problem: the superclass in question has a method called getEnvironment(). If I comment it out, then the Kawa subclass compiles. It doesn't even matter what the method's return type is. So this'll trigger it:


$ ls test
Base.java         Environment.java  Foo.scm
$ cat test/Environment.java
package test;

public class Environment {}
$ cat test/Base.java
package test;

public class Base {
  int getEnvironment() { return 42; }
}
$ cat test/Foo.scm
(define-alias Environment test.Environment)
(define-alias Base test.Base)

(define-simple-class Foo (Base)
  ((main (args :: String[])) allocation: 'static :: void
   ((Foo):bar (Environment)))

((bar (e :: Environment))
(format #t "~A ~A~%" (this) e)))
$ javac test/*.java
$ java kawa.repl -C test/Foo.scm
(compiling test/Foo.scm to test.Foo)
test/Foo.scm:8:15: warning - no known slot 'Environment' in java.lang.Object
test/Foo.scm:8:15: invalid type spec (must be "type" or 'type or <type>)



And now that I know what the pattern is, I see that it isn't anything special about the name "Environment", it's defining and using an alias Xxx when the superclass has a method getXxx(). Here's an even simpler test case:


$ ls test2
Base.java Sub.scm
$ cat test2/Base.java
package test2;
public class Base {
void getAbc() {}
}
$ cat test2/Sub.scm
(define-alias Abc java.lang.String)
(define-simple-class Sub (test2.Base)
((foo (arg :: Abc)) arg))
$ javac test2/Base.java
$ java kawa.repl -C test2/Sub.scm
(compiling test2/Sub.scm to test2.Sub)
test2/Sub.scm:3:17: warning - no known slot 'Abc' in java.lang.Object
test2/Sub.scm:3:17: invalid type spec (must be "type" or 'type or <type>)



Like I said before, this bug was introduced in 1.10. If I edit my classpath so that it finds kawa-1.9.90.jar instead, then the compilation succeeds:


$ java kawa.repl -C test2/Sub.scm
(compiling test2/Sub.scm to test2.Sub)
$

-Jamie

--
Jamison Hope
The PTR Group
www.theptrgroup.com




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