bugKawa - Bugs: bug #40710, Class aliases and array definition

 
 

bug #40710: Class aliases and array definition

Submitter:  Matthieu Vachon <maoueh>
Submitted:  Tue 26 Nov 2013 03:24:04 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 26 Nov 2013 05:32:22 PM UTC, comment #2: 

Ah nice, I'm so used to old Kawa notations that I was sure it was the right way to declare it :)

Thank you for your answer.

Matthieu Vachon <maoueh>
Tue 26 Nov 2013 05:12:03 PM UTC, comment #1: 

Ah, but it does work, if you use the right syntax:

#|kawa:1|# (define-alias <MyString> <java.lang.String>)
#|kawa:2|# (make <MyString>[] size: 1)
[#!null]

Don't think of the syntax <Foo> as the syntax for a class or type-specifier.  It's just an ordinary name, as is <Foo[]>.  It's just that <Foo> and <Foo[]> have a default binding to the class or array type if class Foo exists (at compile-time).  But in newer versions of Kawa, so does the syntax without angle-brackets:

#|kawa:4|# (define-alias MyString java.lang.String)
#|kawa:5|# (make MyString[] size: 1)
[#!null]
#|kawa:6|# (make java.lang.String[] size: 1)
[#!null]

You can also mix the forms:

#|kawa:8|# (define-alias MyString <java.lang.String>)
#|kawa:9|# (make MyString[] size: 1)
[#!null]

There is a slight difference between <ClassName> and plain ClassName, but it is pretty subtle, mainly in noting intent.

Per Bothner <bothner>
Group administrator
Tue 26 Nov 2013 03:24:04 PM UTC, original submission:  

It would be cool if aliases could be resolved to aliased class when creating arrays.

For example, the following will fail in the REPL:


(define-alias <MyString> <java.lang.String>)
(make <MyString[]> size: 1)


This will generate the following output in the REPL:


$ kawa
#|kawa:1|# (scheme-implementation-version)
1.14
#|kawa:2|# (define-alias <MyString> <java.lang.String>)
#|kawa:3|# (make <MyString[]> size: 1)
<unknown>: internal compile error - caught java.lang.RuntimeException: no such class: MyString
    gnu.bytecode.ObjectType.getReflectClass(ObjectType.java:129)
    gnu.bytecode.ClassType.addEnclosingMember(ClassType.java:204)
    gnu.bytecode.ClassType.getEnclosingMember(ClassType.java:191)
    gnu.bytecode.ClassType.doFixups(ClassType.java:1146)
    gnu.bytecode.ClassType.writeToStream(ClassType.java:1166)
    gnu.bytecode.ClassType.writeToArray(ClassType.java:1224)
    gnu.expr.ModuleExp.evalToClass(ModuleExp.java:88)
    gnu.expr.ModuleExp.evalModule1(ModuleExp.java:251)
    gnu.expr.ModuleExp.evalModule(ModuleExp.java:205)
    kawa.Shell.run(Shell.java:279)
    kawa.Shell.run(Shell.java:194)
    kawa.Shell.run(Shell.java:175)
    kawa.repl.main(repl.java:873)


There will be a similar error when compiling the code. For now, the simple workaround is to use the non-aliased class name.

Matthieu Vachon <maoueh>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bothner (Posted a comment)
  • -email is unavailable- added by maoueh (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-11-26 bothner Open/ClosedOpen Closed
    2013-11-26 bothner StatusNone Invalid
        Assigned toNone bothner

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code