bugGNU Octave - Bugs: bug #40852, problem with getting values of...

 
 

bug #40852: problem with getting values of HashMap when key is Integer or String (java package)

Submitted by:  jean <lefredj>
Submitted on:  Mon 09 Dec 2013 05:01:23 PM UTC  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: InvalidAssigned to: None
Originator Name: lefredjOpen/Closed: Closed
Release: 3.6.4Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Tue 10 Dec 2013 01:46:23 PM UTC, comment #3:

The octave/java integration is now part of core octave and will be released along with the upcoming octave-3.8. For reference, the attached (modified) script works as expected (tested under Linux).

(file #29851)

Michael Goffioul <goffioul>
Project Member
Tue 10 Dec 2013 09:23:21 AM UTC, comment #2:

Thanks for your quick answer.

You're right for the getStringStringMap.

But the problem remains for the getIntegerStringMap.
I tried :
map1.get(1)

map1.get(int32(1))

map1.get(java_new("java.lang.Integer",1))

u = int32(1);
map1.get(u);

map1.get(java_new("java.lang.Integer",u))
map1.get(java_new("java.lang.Integer",int32(1)))

None of these returns the right answer.

Note that the two last return "error: [java] java.lang.NoSuchMethodException: java.lang.Integer"

You're talking about the octave/java integration in core octave. How does it work? I didn't find any documentation online.

jean <lefredj>
Mon 09 Dec 2013 05:17:14 PM UTC, comment #1:

1) you mixed-up getStringStringMap and getIntegerStringMap in your tests; things should work fine with getStringStringMap

2) due to automatic boxing/unboxing between octave and java, you need to be careful about what you're doing; if you want to pass a java.lang.Integer to java, you need to use a int32 on the octave-side; atm there's no equivalent to java.lang.Long (using int64 won't do the trick)

3) due to the nature of HashMap.get method, which accepts a Object argument, the octave/java binding will not be able to auto-cast a double into java.lang.Integer; the bindings don't know that the key type is integer (the octave/java bindings code pre-dates support for generic classes in java)

Please note that the java package is now obsolete and that the octave/java integration is now part of core octave.

Michael Goffioul <goffioul>
Project Member
Mon 09 Dec 2013 05:01:23 PM UTC, original submission:

If a java method returns a HashMap map where keys are Integer or String, the method map.get(key) returns void.

There seems to be no way to get the key with the right java.util.Integer or java.util.String type since octave does the conversion to int and string.

I join some simple java class and octave script that show the bug.

jean <lefredj>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #29851:  bugMapOctave_octave_3.8.m added by goffioul (447B - text/x-objcsrc)
file #29819:  bugMapOctave.jar added by lefredj (9KiB - application/x-java-archive)
file #29820:  bugMapOctave.m added by lefredj (440B - text/x-objcsrc)
file #29821:  BugMapOctave.java added by lefredj (976B - text/x-java)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by goffioul (Posted a comment)
  • -unavailable- added by lefredj (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 project members can vote.

     

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

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 10 Dec 2013 01:46:23 PM UTCgoffioulAttached File-=>Added bugMapOctave_octave_3.8.m, #29851
    Mon 09 Dec 2013 05:17:14 PM UTCgoffioulStatusNone=>Invalid
      Open/ClosedOpen=>Closed
    Mon 09 Dec 2013 05:01:23 PM UTClefredjAttached File-=>Added bugMapOctave.jar, #29819
      Attached File-=>Added bugMapOctave.m, #29820
      Attached File-=>Added BugMapOctave.java, #29821

    Back to the top


    Powered by Savane 3.1-cleanup1