Adam Cameron
uptimeInMillis = createObject("java", "java.lang.management.ManagementFactory").getRuntimeMXBean().getUptime()
But:
a) wondering if there's a more CFML- /Lucee -idiomatic way of doing it;
b) that is not reset by a Lucee Server restart (via the admin), for obvious reasons. This is probably not an issue for what I need, but figured I'd mention it anyhow.rory
02/21/2022, 10:48 AMrory
02/21/2022, 10:48 AMAdam Cameron
bdw429s
02/21/2022, 6:14 PMcreateObject( 'java', 'lucee.loader.engine.CFMLEngineFactory' ).getInstance().uptime()
bdw429s
02/21/2022, 6:15 PMlong
which is what System.currentTimeMillis()
returned at the time the CFML engine was startingbdw429s
02/21/2022, 6:15 PMbdw429s
02/21/2022, 6:17 PMCFSCRIPT-REPL: ( getTickCount() - createObject( 'java', 'lucee.loader.engine.CFMLEngineFactory' ).getInstance().uptime() ) / 1000 / 60 / 60 / 24
4.871677847222
Adam Cameron
Adam Cameron
getInstance
(https://javadoc.lucee.org/lucee/loader/engine/CFMLEngineFactory.html#getInstance()), which returns a CFMLEngine
(https://javadoc.lucee.org/lucee/loader/engine/CFMLEngine.html). I do not see an uptime
method on that?Adam Cameron
Adam Cameron
bdw429s
02/22/2022, 6:05 PMpublic static CFMLEngine getInstance()
However, at runtime, the actual class instance you get is the CFMLEngineImpl
class which comes from the runtime (lco. or core file).
So what happens is after creating the interface, Micha will add methods to the actual implementation and not go back and update the interface. (He only likes to update interfaces for major Lucee versions, so they tend to stagnate). So this means the compiler wouldn't allow you to use that method from within Lucee's loader since it's not in the interface, but there's really no reason you can't use it in CFML (which is all based on reflection anyway).
As far as whether you "should" use it, pretty much all of Lucee's internal classes come with the "at-your-own-risk" sort of disclaimer. The fact that he never added that method to the interface just means things are a bit sloppy, it's not IMO any official statement of whether the method is fit to use.bdw429s
02/22/2022, 6:07 PMQuery
interface doesn't have all the methods from the QueryImpl
class. Micha likes to always use the interface as the "type" in the code, but I was unable to do that due to several methods having been added to the implementation and never added to the interface. Lucee 6 would be a great time to clean some of that up.Adam Cameron
So this means the compiler wouldn't allow you to use that method from within Lucee's loader since it's not in the interface, but there's really no reason you can't use it in CFMLYeah makes sense.
zackster
02/22/2022, 6:10 PMAdam Cameron
getInstance
factory method, and the one calls getUptime
on that... then getUpTime
really ought to be in the interface. I get that classes implementing interfaces can obvs also implement other methods, but what we're talking about here seems -as you say - sloppy to me.
If getInstance
starts to return some other implementation of CFMLEngineImpl
that doesn't additionally implement the getUptime
method... code breaks. And for purely sloppy reasons, which is kinda counter to the whole idea of interfaces in the first place.
Anyway, never mind... I doubt we'll ever be using a version of Lucee after 5.x anyhow, so if it works for now: all good. I'll put some tests on it so we know if it happens to break in the mean time.Adam Cameron
zackster
02/22/2022, 6:14 PMAdam Cameron
zackster
02/22/2022, 6:16 PMzackster
02/22/2022, 6:18 PMbdw429s
02/22/2022, 6:29 PMchanging the loader breaks the ability to update@zackster But this isn't a blanket true statement. Adding a method to an interface in the loader would only break if the method didn't exist in the implementation class from the runtime. i.e., if we dreamed up a brand new method to a runtime class and added it today, adding it to the loader would break anyone ⢠using a newer loader ⢠using an older runtime which makes sense. But this can't be a white flag we just throw up and never keep anything in sync
bdw429s
02/22/2022, 6:29 PMbdw429s
02/22/2022, 6:29 PM// FUTURE add to interface
Adam Cameron
bdw429s
02/22/2022, 6:30 PMbdw429s
02/22/2022, 6:31 PMAdam Cameron
Adam Cameron
Lucee needs to have an actual strategyOr just a code review policy that's "mate, we're not in a rush. Just take yer time and do it properly".
zackster
02/22/2022, 6:32 PMAdam Cameron
bdw429s
02/22/2022, 6:32 PMAdam Cameron
Adam Cameron
zackster
02/22/2022, 6:33 PMbdw429s
02/22/2022, 6:34 PMAdam Cameron
zackster
02/22/2022, 6:34 PMbdw429s
02/22/2022, 6:35 PMzackster
02/22/2022, 6:35 PMbdw429s
02/22/2022, 6:35 PMbdw429s
02/22/2022, 6:36 PMzackster
02/22/2022, 6:36 PMbdw429s
02/22/2022, 6:36 PMzackster
02/22/2022, 6:37 PMbdw429s
02/22/2022, 6:37 PMbdw429s
02/22/2022, 6:38 PMLucee 6 won't being updating the loader interfaceIs it possible to make a distinction between "_breaking"_ updates and non-breaking? For example, adding the uptime() method would break nothing.
zackster
02/22/2022, 6:38 PMbdw429s
02/22/2022, 6:39 PMbdw429s
02/22/2022, 6:40 PMzackster
02/22/2022, 6:40 PMbdw429s
02/22/2022, 6:41 PMbdw429s
02/22/2022, 6:41 PMzackster
02/22/2022, 6:41 PMzackster
02/22/2022, 6:41 PMzackster
02/22/2022, 6:41 PMbdw429s
02/22/2022, 6:42 PMbdw429s
02/22/2022, 6:42 PMbdw429s
02/22/2022, 6:42 PMzackster
02/22/2022, 6:42 PMbdw429s
02/22/2022, 6:42 PMbdw429s
02/22/2022, 6:43 PMzackster
02/22/2022, 6:43 PMbdw429s
02/22/2022, 6:44 PMbdw429s
02/22/2022, 6:44 PMbdw429s
02/22/2022, 6:44 PMzackster
02/22/2022, 6:45 PMbdw429s
02/22/2022, 6:45 PMbdw429s
02/22/2022, 6:45 PMbdw429s
02/22/2022, 6:45 PMzackster
02/22/2022, 6:48 PMzackster
02/22/2022, 6:51 PMbdw429s
02/22/2022, 6:54 PMzackster
02/22/2022, 8:16 PM