Static method keyword should include Java-style warning when used incorrectly

Description

This is per the conversation I had with Gert at Dev.Objective about the new “static” keyword in Lucee 5.

In Java I can do either of these:

MyClass.staticMethod();

or

MyClass c = new MyClass();
c.staticMethod();

Both compile under Java, and thus both should probably compile under Lucee as well. In Java, if I do the second option (i.e. create an object when I don’t need to since I’m just calling a static method), I’ll get a warning from the Java compiler letting me know I could use the shorter syntax in the first example (and in case I’m actually introducing a bug into my code where I didn’t mean to use a static method in this situation, etc).

It’d be nice of the Lucee compiler generated a similar warning, perhaps in the CF Debug output for the given page? Or in the console output perhaps?

Activity

Details

Assignee

Reporter

Labels

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

Affects versions

Priority

Created 21 June 2016 at 23:27
Updated 5 May 2023 at 09:41