2
votes

I was recently trying to use the cfscript version of cfcomponent along with JavaDoc notation and getting error:

The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.

Null Pointers are another name for undefined values.

From CF docs:

/** 
 * custom metadata for a cfc defined using annotation as well as key-value pairs 
 * @cfcMetadata1 "cfc metadata1"
 */ 
component cfcMetadata2 = "cfc metadata2"
{ 
    /** 
     * custom metadata for a property defined using annotation as well as key-value pairs 
     * @propMetadata1 "property metadata1"
     */ 
    property type="numeric" name="age" default="10" propMetadata2="property metadata2"; 

    /** 
     * custom metadata for a function/argument using both annotation and key-value pairs 
     * @arg1.argmdata1 "arg metadata1"
     * output true 
     * @fnMetadata1 "function metadata1"
     */ 
    public string function foo(required numeric arg1=20 argmdata2="arg metadata2") fnMetadata2="function metadata2"
    { 
        writedump(getmetadata(this)); 
        return arg1; 
    } 
}

My Code:

/**
 * @displayName Test
 * @output false
 *
 * @since 2016-10-25
 * @version 1.0
 */
component {

    /**
     * I am a test function.
     * 
     * @limitFrom.required false
     * @limitFrom.default 0
     *
     * @limitBy.required false
     * @limitBy.default 0
     *
     * @returnFormat "json"
     *
     * @since 2016-10-25
     * @version 1.0
     */
    remote query function test(
        numeric limitFrom,
        numeric limitBy
    ) {
        return queryNew("");
    }
}

This is only happening when I am trying to assign default value to the arguments using the JavaDoc notation i.e.,

@limitFrom.default 0

@limitBy.default 0

Removing these and everything is fine. Not sure why this is happening?

1
Since all of the other attributes seem to work, may be a bug. Total guess, but ... given that "default" is a keyword in many languages, I would not be surprised if that was somehow involved in causing the internal parsing to fall over ... - Leigh
Did you ever figure out if it was a bug or code issue? - Leigh
@Leigh I tried it again and the error is only if I am using default for function arguments. I also used default for property and it worked as expected so, it seems like a bug. - Beginner
Yeah, sounds like it. Might want to file a bug report for the next guy (if you have not already). - Leigh

1 Answers

1
votes

I know you specifically asked about JavaDoc notation, but I'm not a fan, and it's possible that you haven't seen any alternative. I prefer this syntax.

component
  displayName="test"
  output="false"
  hint="blah blah description..."
{

    // beware of `default`--it doesn't do what you might think.
    //  it's ignored unless you use ORM
    property type="numeric" name="age" default="10"
        hint="blah blah description..."
        propMetadata2="property metadata2";

    remote query function test(
        numeric limitFrom=0 hint="blah blah description...",
        numeric limitBy=0 hint="blah blah description..."
    )
    hint="I am a test function"
    {
        return queryNew("");
    }

}