Interesting issue with reserved function names inside CFCs

This post is more than 2 years old.

Earlier today Tony Nelson pinged me about an odd ColdFusion issue he ran into. It turned out to be an issue I've seen before outside of CFCs that - for whatever reason - acted somewhat different inside of a CFC. Let me explain a bit. First, let's look at his CFC.

component {

function init(string foo, string bar, string baz) {
	_set(foo, bar, baz);


function _set(string foo, string bar, string baz) {



Nothing crazy here, just an init method that automatically calls a method called _set that takes three arguments. Each argument is optional (don't forget about that chnage) so any amount of strings sent in should be fine. Now let's look at calling code:

<cfset z = new test("foo", "bar", "baz")>

When executed, you get:

Parameter validation error for the _SET function.

The function accepts 2 to 2 parameters.

Eh? I decided to simplify things a bit to see if it would help. I changed it to one CFM that looked like so:

<cffunction name="_set"> <cfreturn 1> </cffunction>


Whenever I debug I try to simplify as much as possible. When run, I got:

The names of user-defined functions cannot be the same as built-in ColdFusion functions.

The name _set is the name of a built-in ColdFusion function.

Ahah! So I've seen this before in terms of UDFs with the same name as BIFs, but _set isn't a ColdFusion function, is it? Turns out it is - just behind the scenes. Turns out if you look at the Java object coldfusion.runtime.CfJspPage, you see this method defined:

<cfset foo = createObject("java","coldfusion.runtime.CfJspPage")> <cfdump var="#foo#">

I tried making UDFs with names from a few of the methods defined here and they all threw errors. For the most part I avoid weird names like _set so this wouldn't trip me up, but some of the methods did look like something I'd consider using like release(). It appears as if when executing as a CFM only, ColdFusion was better able to handle the error. But when executed via a CFC method the error is more ambiguous. In case you want to see a full list of the methods and don't want to run the code above, I whipped up this little script:

<cfset foo = createObject("java","coldfusion.runtime.CfJspPage")> <cfset methods = foo.getClass().getDeclaredMethods()> <cfset allMethods = []> <cfloop index="m" array="#methods#"> <cfif not arrayFind(allMethods, m.getName())> <cfset arrayAppend(allMethods, m.getName())> </cfif> </cfloop> <cfset arraySort(allMethods, "textnocase")> <cfloop index="m" array="#allMethods#"> <cfoutput>#m#<br/><br/></cfoutput> </cfloop>

And here's the output:


Finally, it does not as if this is documented. The Live Docs page for reserved words has this to say:

Built-in function names, such as Now or Hash

But there is no warning about possible conflicts with these "hidden" methods. Has anyone else run into this?

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Hal Helms posted on 5/10/2011 at 10:32 AM

Thanks, Ray: very helpful

Comment 2 by Ciaran Archer posted on 5/10/2011 at 12:28 PM

Thanks for the writeup: can I ask what is the thinking behind using the _functionName convention? i.e. Why use an underscore?

Comment 3 by Raymond Camden posted on 5/10/2011 at 2:43 PM

@Hal: You are welcome

@Claran: You mean in the original CFC? That was Tony's code, not mine. If I had to guess - both for why Adobe used it sometimes and him, it would be to help 'mark' the methods as being special within the CFC/class.

Comment 4 by Jeremy Battle posted on 5/11/2011 at 9:08 AM

Very interesting, I could definitely see myself using a few of those non-underscored functions . I wonder if other parts of the coldfusion.runtime have a similar issue or if its particular to CfjspPage. Might have to check that out myself!

Comment 5 by Jeremy Battle posted on 5/11/2011 at 9:09 AM

Woops, that should say non-underscored function *names*, I wouldn't actually try to use the functions themselves, heh.

Comment 6 by salvatore fusto posted on 5/26/2011 at 11:41 AM

so this is why i had a lot of problems using the "_" char in coding.
thanks a lot Ray

Comment 7 by Jork Zijlstra posted on 12/8/2015 at 9:31 AM

Thanks for the list of methods. Apparently they still haven't fixed it.

Comment 8 (In reply to #7) by Raymond Camden posted on 12/8/2015 at 11:04 AM

Not surprised. It probably isn't documented either. I'd edit the docs, but the Wiki form is gone now.

Comment 9 (In reply to #8) by Jork Zijlstra posted on 12/8/2015 at 12:41 PM

No, it isn't in the documentation. I had to find it out the hard way. I did add all the exposed methods to the bug report so that other developers might find it earlier in the adobe bugbase.