No that is a good example let me extend it a little bit:
str=createObject(“java”, “java.lang.String”).valueOf(true);
Again no object from type String was produced with createobject, it only
produces a proxy objects to a class
But if I do this:
String=createObject(“java”, “java.lang.String”);
String.length();
It produces an instance of string in the second line and then it calls an
instance method, problem in every future call to this instance that is
inside the proxy has to go through the proxy object that is still around
it, it is like a door keeper that always check if we have a static call or
not.
we cannot change that fact, then you can still do this as well:
str=String.init();// create I a instance from the proxy
So the best is to use it as follows:
String=createObject(“java”, “java.lang.String”);
empty=String.init();
str=String.init(“Susi”);
Only use it to call static method or the create instances.
And if you need only one instance you do:
str=createObject(“java”, “java.lang.String”).init();
So technically there is no question, createObject-Java does not produce a
object from the class requested. The only question is, is this relevant for
the users using this function.
To be honest I was undecided from beginning about this, I think for someone
heavily relay on this it is relevenat, but for most users it is not.
So I think there is no right or wrong here, so I decided to rename the
function to JavaNew, not javaProxyNew or javaObjectNew.
I have not given the name JavaObjectNew for 2 reasons.
- Again, it is not producing a object and I try to avoid to actievely make
this misconception.
- The function JavaCast is not named cast2JavaObject, it also not speaks
from objects.
MichaAm Samstag, 18. April 2015 schrieb Adam Cameron :
On Saturday, 18 April 2015 20:32:38 UTC+1, Micha wrote:
“from a CFML perspective what is returned is a Java object”
That is the reason I have used the word proxy in the first place, because
this is wrong and most people use this functionality wrong what leads to
overhead in their code.
No.
What the function is intended to do is return an instance of a Java object.
In that I can go createObject(“java”, “java.lang.String”) and then use
that object anywhere Java expects a string demonstrates this to be the
case. And before you start citing String as a bad example, it was just
an example.
If under the hood you need to horse around with proxies and all other
sorts of magic to make it work is simply irrelevant as far as CFML
goes. It’s a Java object in the context of CFML.
You do make a point that you do some clever stuff (or at least emulate the
clever stuff Adobe had already done, let’s be honest) it exposing static
methods via the same function. But if anything this is where the
shortfall in createObject() lies. If to leverage a static method one needs
to use createOBJECT(), then - yes - that’s wrong. But in general, for
instantiatable (!) objects, what it’s doing is creating an object. But that
aside, CFML doesn’t make the distinction between the two cases, and this is
fine.
If there are performance issues with this approach to creating Java
objects, then this is your issue to fix, and is - again - irrelevant to
CFML.
You not longer seem to be able to see where your implementation of CFML
stops and actual CFML starts. The mere fact you need to do [something]
in Java to provide CFML functionality doesn’t mean you need to explain it
at CFML level in the naming of the CFML constructs. You’ve lost touch of
what CFML is.
–
Adam
–
You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com
<javascript:_e(%7B%7D,‘cvml’,‘lucee%2Bunsubscribe@googlegroups.com’);>.
To post to this group, send email to lucee@googlegroups.com
<javascript:_e(%7B%7D,‘cvml’,‘lucee@googlegroups.com’);>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/1f9740b4-677f-432c-9527-e72910034e8b%40googlegroups.com
https://groups.google.com/d/msgid/lucee/1f9740b4-677f-432c-9527-e72910034e8b%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.