static.variable of the component only loads on creating an object to the component

Description

The component's static variable declared by dot notation loads only on while creating the object to the component. So accessing that static variable before creating the object to the component throws an error like The static member [ DOTNOTATION ] does not exist in the Component [ test.testcases.LDEV3900_.teststa ], only the following static members are available: [ GETSTATICBYSTATIC, INCONSTRUCTOR ]. Seems ACF-2021 works fine in this scenario.

test.cfm

teststa.cfc

 

Lucee 5.3.9.103-SNAPSHOT


ACF-2021

Environment

None

Attachments

2

Activity

Show:

Zac Spitzer 23 September 2022 at 09:22

Pothys - MitrahSoft 23 March 2022 at 09:59

, As per the above comments, I closed this ticket.

Pothys - MitrahSoft 14 March 2022 at 15:24

Thanks for the explanations and inputs.

I've done tests with the above your examples

For the first example, ACF2021 increases the instanceCount to 1.
Again, For the second example, ACF2021 increases the instanceCount to 1.
Also, For the third example, ACF2021 throws the error s... happens! for the teststa::instanceCount.

I agreed with your point.

Michael Offner 14 March 2022 at 13:35

this is a bug in ACF in my opinion.

a component has 3 constructors, one static and 2 instance constructors.

the static constructor is within static{} , then you have the body constructor that is all code directly within component {} and last the is the function init(){}

The 2 instance constructors are only execute when you create an instance, so i do not expect “dotNotation“ do be loaded.

You could argue that for example in java this get loaded

You could argue that Lucee should detect the static defintions and read them and only them anyway when init the static context.

But i’m completely against this, because this is not intuitive and what if i wanna define that static variable when the instance is created.

Take this code as an example

in ACF then i can do the following?

What does ACF do in this situations?

I have a guess why ACF acts as it does. I think they create an instance even you only do teststa::getStaticBystatic() simply becaue this is the easiest way to a static context. I know because we did it also in the alpha version of this feature and this had exactly this ugly effects.

please execute the following code in ACF

 

Does ACF throw the error? it should not.

Is the instanceCount 0 or 1? Should be 0 because no instance got created.

Pothys - MitrahSoft 10 March 2022 at 08:04

I added a testcase to this ticket
Pull Request:

Won't Do

Details

Assignee

Reporter

Priority

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 9 March 2022 at 14:13
Updated 23 September 2022 at 09:24
Resolved 23 March 2022 at 10:00