• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFML 2016 incompatabilities

New Here ,
Jan 23, 2017 Jan 23, 2017

Copy link to clipboard

Copied

I'm trying to migrate from CF9 to CF2016.  It is going pretty smoothly except for a couple of things.

Keep in mind, the application logic is largely written in Java.  CF is used simply to load and call Java objects and generate UI.

The problems I've encountered seem to be related in that CF2016 can't seem to find a java method (in our library) that matches the call signature or vice-versa.

1) ArrayAppend

This works in CF9 but not in CF2016

<CFSET Session.Items.ArrayAppend( Session.Items, Session.SubItem)>

Error in log file is: The ArrayAppend method was not found.Either there are no methods with the specified method name and argument types or the ArrayAppend method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.

In our library, SubItem is a subtype of Item.

To work around it, I simply did this:

<CFSET Session.Items[ Session.ItemsNdx ] = Session.SubItem>

2) Attributes in custom tag

This doesn't work in 2016 but does in CF9:

<CFSET Attributes.items.set( JavaCast( "int", ndx ), item2 )>

<CFSET Attributes.items.set( JavaCast( "int", ndx + 1 ), item1 )>

Workaround was this:

<CFSET Attributes.items.setElementAt( item2 , JavaCast( "int", ndx ) )>

<CFSET Attributes.items.setElementAt( item1 , JavaCast( "int", ndx + 1 ) )>

3) Finding the contstructor

<CFSET foo = CreateObject( "Java", "com.company.Foo" )>

<CFSET init = foo.init( Session.Thing, Session.Items, version )>

Seems to be complain about the second argument (Items) with:

Unable to find a constructor for class com.company.Foo that accepts parameters of type ( com.company.Thing, coldfusion.runtime.Array, java.lang.String ).

I have no workaround for this yet.  It works if I create a Foo constructor like this: Foo( Thing, version), which eliminates the 2nd argument and adjust the constructor like this: Foo( Thing thing, String  version).

It seems like CF2016 is having difficulty with arrays (Vectors).  Any ideas?

Views

545

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 23, 2017 Jan 23, 2017

Copy link to clipboard

Copied

LATEST

Just a guess but I'm guessing that you are relying on undocumented features in CF. CF9 may have used the Java array data type as-is whereas CF-2016 uses a "CF" array data type? I've not ever seen scope.array.ArrayAppend() documented in CF; instead CF documents ArrayAppend(). Your first example would be:

     <CFSET ArrayAppend( Session.Items, Session.SubItem) />

I think your other examples are similar issues:

     <CFSET Attributes.items.setElementAt( item2 , JavaCast( "int", ndx ) )>

should be:

     <CFSET Attributes.items[ndx] = item2 />

I'm told there have been significant speed improvement between CF9 & CF-2016 (even CF11) and array and structure handling probably had to change for these improvements. Again, just a guess.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation