tracker issue : CF-4204179

select a category, or use search below
(searches all categories and all time range)
Title:

References to Java objects extending 'Map' interface don't work with integer keys

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Tim P. / ()

Created: 04/12/2019

Components: Language, Java Integration

Versions: 2018

Failure Type: Crash

Found In Build/Fixed In Build: ColdFusion 2018,0,03,314033 / CF2018U5

Priority/Frequency: Critical / Some users will encounter

Locale/System: ALL / Win All

Vote Count: 3

Problem Description: in all previous CF versions, a Java object which extends the 'Map' interface could be reliably referenced from CF in the same way a CF-created (using StructNew()) struct is.  This appears to have changed in the 2018 release

Steps to Reproduce: run the following code:

foo = CreateObject("java","java.util.TreeMap").init(); // this works if you use StructNew() here
i = 1;
foo[i] = "hello #Now()#";
WriteOutput(foo[i]);

Actual Result: crash:
 	Cannot index into class java.util.TreeMap with index 1 of type class java.lang.Integer.
StackTrace 	coldfusion.runtime.ArrayNotIndexableException: Cannot index into class java.util.TreeMap with index 1 of type class java.lang.Integer.
 at coldfusion.runtime.CfJspPage.ArrayGetAt(CfJspPage.java:1192)
 at coldfusion.runtime.CfJspPage._arrayGetAt(CfJspPage.java:1403)
 at coldfusion.runtime.CfJspPage._arrayGetAt(CfJspPage.java:1398)
 at coldfusion.runtime.CfJspPage._arrayGetAt(CfJspPage.java:932)
 at coldfusion.runtime.CfJspPage._arrayGetAt(CfJspPage.java:916)
 at cf28ea24ef2dce1d2d4f8c2d9f9b2d467a3f6eb30d2ecfm1790102911.runPage(...)
.
'arrayGetAt' is the problem here - 'foo' is not an array - it appears that the logic is determining the access methods for 'foo' based on the type of 'i' instead of on the type of 'foo'

Expected Result: (no error)

Any Workarounds: update the reference in the WriteOutput to use JavaCast:
WriteOutput(foo[JavaCast("string",i)]);

Attachments:

Comments:

Critical for many of our customers
Vote by Todd P.
30650 | April 23, 2019 05:10:25 PM GMT
It appears that this has been fixed internally ("reason code: fixed" above) - is there an ETA for this fix to be publicly available?
Comment by Tim P.
30837 | May 29, 2019 02:23:12 PM GMT
It appears that this has been fixed internally ("reason code: fixed" above) - is there an ETA for this fix to be publicly available?
Comment by Tim P.
30838 | May 29, 2019 02:23:32 PM GMT