Did we ever get a better way to create Java object...
# adobe
s
Did we ever get a better way to create Java objects than
createObject()
? I think Lucee has a more integrated syntax but I can't remember whether the tickets requesting better syntax in ACF ever happened?
b
I believe in 2021 you can do
new java(“path.to.class”)
. There are also options for defining entire Java classes in a CFM as well as extending classes or implementing interfaces from a CFC.
m
Correct. That
new java
change was added in CF2018 though. The native definitions are CF2021.
s
So
s = new java("java.lang.String").init("Hello, World!");
... ugh! Not really much better than
s = createObject("java", "java.lang.String").init("Hello, World!");
(the ACF docs seem to really suck in this area)
m
I agree. The suggestion was
s = new java:java.lang.String("Hello, World!")
but that was ignored apparently.
s
Don't get me started on bizarre language level decisions in the face of superior suggestions from the community...