tracker issue : CF-4093045

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

Methods are overwritten by CF version with the same name

| View in Tracker

Status/Resolution/Reason: Closed/Deferred/DesignLimitation

Reporter/Name(from Bugbase): Jork Zijlstra / Jork Zijlstra (Jork Zijlstra)

Created: 11/26/2015

Components: Core Runtime

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Linux All

Vote Count: 0

Problem Description:
When creating a (private) method named '_binary" in a component it causes a runtime exception "argumentNotFound" or IllegalArgumentException: argument type mismatch. Although when looking at your own code you see that your calling your own _isBinary with the correct number off arguments and of they are of correct type.

After some debugging it looks like _isBinary is injected at runtime, but this is a _isBinary version of the CF core not your own created method.
Futhermore the illegalArgumentException is caused because the CF _isBinary seems to have the following signature _isBinary(string, binaryencoding).

So in short your own _isBinary method is overriden by the CF _isBinary version which might take different parameters.

Steps to Reproduce:
- create component
- create (private) method _isBinary
- call _isBinary at runtime

Actual Result:
An exception on of argument was nog found or argument type mismatch

Expected Result:
Your own created methods should not be overriden by cf versions

Any Workarounds:
Use a different name for your method

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4093045

External Customer Info:
External Company:  
External Customer Name: Jork Zijlstra
External Customer Email:  
External Test Config: My Hardware and Environment details:

Ubuntu 14.04, CF10,0,18,29633

Attachments:

  1. November 27, 2015 00:00:00: 1_isBinary.zip
  2. November 27, 2015 00:00:00: 2__Binary.zip
  3. November 27, 2015 00:00:00: 3_serversettings.pdf

Comments:

When creating the _isBinary in a cfm file an error is thrown that there is a duplicate method. So in a cfm file it is parsed differently. But it is still an weird error. You only programmed it once and so it only exists once in your component. I can understand that the steps to reproduce aren't clear enough, so tommorrow I will upload and example so that it can be tested with ease.
Comment by External U.
5200 | November 26, 2015 01:28:58 PM GMT
Jork, I tried it with build 10,0,18,296330 and I am not observing this issue. Please provide me information mentioned below: 1. Settings Summary. (Server Settings > Settings Summary > Save As PDF). 2. Exception stacktrace
Comment by Nimit S.
5201 | November 26, 2015 10:02:49 PM GMT
Sorry I made the mistake of entering this issue from memory. The actual method that causes the error is _toBinary not _isBinary. I hope that today I can upload a new archive with test code.
Comment by External U.
5202 | November 27, 2015 05:44:18 AM GMT
I am unable to repro it with _toBinary as well.
Comment by Nimit S.
5203 | November 27, 2015 06:00:09 AM GMT
Both me and a college (which helped to debug the error) can't reproduce it anymore. So I will have to withdraw the bug report. Sorry to take up your time.
Comment by External U.
5204 | November 27, 2015 06:36:35 AM GMT
No problem. I will withdraw this bug.
Comment by Nimit S.
5205 | November 27, 2015 06:47:24 AM GMT
We found it. it is in the _binary.zip. The problem seems that the methods that are defined in CFJSPage class overwrite the developer created methods
Comment by External U.
5206 | November 27, 2015 06:57:36 AM GMT
Can it be reopened or do I have to submit a new bug report?
Comment by External U.
5207 | November 27, 2015 08:26:36 AM GMT
I am able to repro the issue now. I am re-opening this bug.
Comment by Nimit S.
5208 | November 27, 2015 11:19:36 PM GMT
Need to change the core of CF which involves parser and code generation. Its little bit risky to make changes now. will take it up later.
Comment by Awdhesh K.
5209 | December 08, 2015 01:49:07 AM GMT
Thanks for the update. I my opinion changing it later would mean even a higher risk, since at that point there would be even more legacy code to change. Do you have any idea how much later, later is?
Comment by External U.
5210 | December 08, 2015 02:59:03 AM GMT
"Need to change the core of CF which involves parser and code generation" There is not need for that. The only thing you need to do is to move those 'private' methods out of that page. There are several well defined patterns to do these kinds of changes. Sourcemaking lists a lot of these patterns: https://sourcemaking.com/design_patterns Another (maybe faster) solution would be to make these 'private' functions `package private` instead of `public`. You could then simply add a 'wrapper' class to the same package that you can use to access these methods from outside the package. In any case, in my humble and naive opinion, this problem seems quite easy and painless to solve.
Comment by External U.
5211 | December 08, 2015 03:26:54 AM GMT
The methods that have this problem are: __caseValue, _addBD, _arrayAssign, _arrayGetAt, _arrayset, _arraySetAt, _autoscalarize, _autoscalarizeWithoutLocalScope, _autoscalarizeWS, _Binary, _checkCFImport, _checkCondition, _checkParam, _clone, _compare, _contains, _div, _divideBD, _echoExpr, _emptyTag, _emptyTcfTag, _escapeSingleQuotes, _get, _getImplicitMethod, _getImplicitMethods, _idiv, _initTag, _invoke, _invokeUDF, _isDefined, _isNull, _isTopPage, _iteratorCollection, _LhsResolve, _mergeToLocal, _mod, _multiplyBD, _negateBD, _popBody, _powBD, _pushBody, _queryRowDataToStruct, _resolve, _resolveAndAutoscalarize, _resolveAndAutoscalarizeWS, _set, _setCurrentLineNo, _setImplicitMethods, _setNonLocalScope, _structSetAt, _subtractBD, _templateName, _validateTagAttrConfiguration, _validateTagAttrValue, _validatingMap, _whitespace, ArrayGetAt, bindImportPath, bindPageVariable, bindPageVariables, checkRequestTimeout, checkSimpleParameter, createImplicitVariable, createInitialValue, GetComponentMetadata, getExtends, getImplements, GetMetadata, getOutput, getPagePath, getQueryParamCount, getResolvedComponentPath, initialize, internalIsBoolean, internalIsNumeric, internalIsNumericDate, invoke, isNotMap, registerUDF, registerUDFs, release, resolveCanonicalName, runPage, setResolvedComponentPath, StringCouldBeODBCDateTime, StructStemGet, URLSessionFormat, urlSessionFormat
Comment by External U.
5212 | December 08, 2015 03:59:28 AM GMT
Apparently this is a 5 year old issue? http://www.raymondcamden.com/2011/05/09/Interesting-issue-with-reserved-function-names-inside-CFCs
Comment by External U.
5213 | December 08, 2015 04:02:42 AM GMT