Java function bug

54 views
Skip to first unread message

John Doe

unread,
Aug 27, 2016, 3:52:05 AM8/27/16
to Tasker
When I press on coffee cup in Java action I can see a string object never created, with the name of latest sms sender. It's not possible to remove it. I've got an SMS profile event. I don't know the relationship about sms and Java object. Tasker 4.8u5 and Android 6.0.1.

Pent

unread,
Aug 27, 2016, 4:57:22 AM8/27/16
to Tasker
So the string changes every time you get an SMS ? Or there's
a new string everytime ?

Pent

John Doe

unread,
Aug 27, 2016, 6:36:25 AM8/27/16
to Tasker
Yes, exactly. This strange string object is updated Always with the latest sms sender.

Pent

unread,
Aug 28, 2016, 3:30:50 AM8/28/16
to Tasker
I created a profile with a Received Text event and received a text but I couldn't reproduce this.

The SMS profile does what ? Try searching for Java actions which might create such an
object.

Pent

John Doe

unread,
Aug 28, 2016, 3:51:20 AM8/28/16
to Tasker
Hi,

sorry my fault. I've got a sms task related to a sms profile where I create a string object using "new". However this is only a local object, how is it possible that I see this object in a new task? Maybe I'm missing something. Can you explain to me how is it possible?

Thanks.

John Doe

unread,
Aug 28, 2016, 3:52:51 AM8/28/16
to Tasker
Just to clear, I'm doing in the task:

myobj = new String(%SMSRN);

Robert Ryan

unread,
Aug 28, 2016, 4:08:59 AM8/28/16
to tas...@googlegroups.com

On August 28, 2016 1:52:54 AM John Doe <playappa...@gmail.com> wrote:
> Just to clear, I'm doing in the task:
> myobj = new String(%SMSRN);


I've run into this before. In a java function, literal strings should be enclosed in quotes. Try this:

myobj = new String("%SMSRN");

John Doe

unread,
Aug 28, 2016, 4:28:05 AM8/28/16
to Tasker
Oh OK, thank you very much. I will try, however I don't understand if it's a Tasker bug or not.

Robert Ryan

unread,
Aug 28, 2016, 8:38:34 AM8/28/16
to tas...@googlegroups.com

This isn't a bug. It is more a case of mistaken identify. Unlike Tasker variables, which use %, Java objects have no special identifying marker. In Java, bobby is a perfectly legal object name, whereas "bobby" is a string.

John Doe

unread,
Aug 28, 2016, 11:03:40 AM8/28/16
to Tasker

I'm sorry but I don't understand. I think that what happens is:
1) Tasker replace the variable contents before to call String constructor, converting to something like "This is my test"
2) The constructor of String is called with a string that contains "This is my test"

If there isn't replace the string object contains instead %Thisismyvar but it contains the correct value, so the replace works. But when Tasker convert %SMSRN to a temporary string to pass it to the string constructor, it turns the variable in a global Java object. This is wrong because the object must be local, in addition even if it's a global object, you can't destroy it using the delete function. So the fact that you have not removable entry means that there is something wrong somewhere IMHO.

Robert Ryan

unread,
Aug 28, 2016, 1:58:54 PM8/28/16
to tas...@googlegroups.com

Well, Pent would be the one to ask about the internal workings.

I do know that I have run into this situation several times when using Java functions. The problem has always been caused by my forgetting to enclose something in quotes.

>in addition even if it's a global object, you can't destroy it using the delete function.

This is strange.  I've always been able to remove these dummy objects using the Java delete function.

Pent

unread,
Aug 30, 2016, 3:43:01 AM8/30/16
to Tasker

I'm sorry but I don't understand. I think that what happens is:
1) Tasker replace the variable contents before to call String constructor, converting to something like "This is my test"
2) The constructor of String is called with a string that contains "This is my test"

That sounds right.

If there isn't replace the string object contains instead %Thisismyvar but it contains the correct value, so the replace works. But when Tasker convert %SMSRN to a temporary string to pass it to the string constructor, it turns the variable in a global Java object. This is wrong

That would be wrong, but I havn't been able to reproduce it.  Also you said that the NAME of the object was the contents of %SMSRN, in which case clearly something is very wrong, but which I also can't reproduce.

because the object must be local, in addition even if it's a global object, you can't destroy it using the delete function. So the fact that you have not removable entry means that there is something wrong somewhere IMHO.

Note that the coffee cup selector doesn't just show *defined* objects, but also those mentioned in Java Function and Java Delete actions (if I remember right), doing a delete on those won't remove them from the list.

I tried this:

Variable Set, %Val, 12345
Java Function, myobj = new String( %Val )

In another task, I couldn't see myobj with the coffee cup, nor any other
named object except the built-in ones. If I called the object myObj, I could
see it in the selector in another task, even if I hadn't
yet run the task (and thus hadn't get created the object), as expected.

Pent

John Doe

unread,
Aug 30, 2016, 7:43:20 AM8/30/16
to Tasker
In my case I would see a string object named 12345. Have you tried to create an SMS profile connected with a task that perform myobj = new String(%SMSRN)? Please try in this way and send an SMS to your phone. The only difference I can see from this object if I compare it with another string is the package name. Example: if I create a string object called foo and I press on the coffee cup I see:

foo
string

SMSSenderName
java.lang.string <------complete package name here

CONTEXT
context

IBUFFER
Bitmap

 

Pent

unread,
Aug 31, 2016, 6:25:29 AM8/31/16
to Tasker



In my case I would see a string object named 12345. Have you tried to create an SMS profile connected with a task that perform myobj = new String(%SMSRN)?

Yes, my wife is sick of sending me SMS now :-)

Can't get the content of the variable to appear as a variable name in the
selector :-(

Sorry, I propose we abandon this one now as it's pretty low impact and
the vast majority of people won't use the action anyway. Thanks for
trying to help me reproduce.

Pent
Reply all
Reply to author
Forward
0 new messages