bugKawa - Bugs: bug #48347, Exception on import of class with...

 
 

bug #48347: Exception on import of class with public instance fields and without no-args ctor

Submitted by:  Nathan S. <nathans>
Submitted on:  Wed 29 Jun 2016 08:01:35 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Run-time exceptionStatus: Invalid
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 29 Jun 2016 08:58:59 PM UTC, comment #1:

The import form, when used in that variant, requires Example to be a "module class" or at least Kawa tries to view it as such, which it isn't, for various reasons, including that it doesn't have a default constructor.

Kawa import is not the same as Java import. (import Example)
means "import the public names of (fields in) Example into the current scope".
For static fields there is no problem, but for instance fields it first tries to construct an instance.

This should be a compile-time error, I admit.

There is no need for the import if Example is in the default package: just use Example directory.

Otherwise read: http://www.gnu.org/software/kawa/FAQs.html
If Example is in package p, then you could do:
(import (class p Example))

More useful reading:
http://www.gnu.org/software/kawa/Module-classes.html
http://www.gnu.org/software/kawa/Importing.html

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Wed 29 Jun 2016 08:01:35 PM UTC, original submission:

Steps to reproduce:

Create a file Example.java with contents:

Create a file test.scm with contents:

Run "javac Example.java". Then with the current directory included on the classpath run "kawa -f test.scm". An exception is thrown from gnu.expr.ModuleContext.findInstance because it attempts to invoke the no-args constructor of Example and there is not one. It does not seem to matter if I put Example in a package other than the default package.

Strangely, if I change the visibility of Example's item field from public to private the error does not occur.

Nathan S. <nathans>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #37627:  Example.java added by nathans (102B - text/x-java)
file #37628:  test.scm added by nathans (49B - application/vnd.lotus-screencam)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 28 Jul 2016 11:26:41 PM UTCbothnerOpen/ClosedOpen=>Closed
    Wed 29 Jun 2016 08:58:59 PM UTCbothnerStatusNone=>Invalid
      Assigned toNone=>bothner
    Wed 29 Jun 2016 08:01:35 PM UTCnathansAttached File-=>Added Example.java, #37627
      Attached File-=>Added test.scm, #37628

    Back to the top


    Powered by Savane 3.1-cleanup1