Bojan Dolinar

Greenhorn
+ Follow
since Nov 15, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bojan Dolinar

In our software, administrators can configure arbitrary operations on data. For example, administrator writes t1 + t2 and binds both variables. The expression is evaluated as a groovy script and it works just fine.
Now we want to supply a validation whether all the variables in expression are really bound. The simplest way would be to get a list of all dynamic variables from parser, but after a lot of searching I just didn't find a way to do it. I'm probably missing something really obvious, since that kind of information should be available. For example, when I edit groovy code in IDEA, all dynamic variables and methods are underlined.
Any pointers on this will be much appreciated. Thanks!
11 years ago

Jeff Verdegan wrote:I can't say I've ever heard of doing it on an immutable object though. Was that your point?



Exactly! Due to immutability you have to assign new object to reference, which defines the problem.

I was not aware of the fact that synchronized(X) is not atomic (I had to examine the context to find out whether this was a statement or just a situational consequence of your example). That was the reason I incorrectly decided code was still ok. Your explanation was great. Thank you for your time.

I was checking some old code of ours. It is multithreaded, but the author commited some beginner mistakes, for example not synchronizing booleans and so. But this piece of code might even work, but it seems bizarre to me:



Each of these methods locks object and in the synch block it assigns new object to the reference. Both integers are carrying two roles now: semantics and synchronization.
However, after some head scratching I figured that it should work. I wrote test and it passes. I'm still inclined to change the code since it looks more like a contrived example for programming exam as it just makes you wonder. This can't be an example of idiomatic MT programming, right? If not, I will just use AtomicInteger, probably.
Thanks Ritchie. It was a no-brainer. The whole registration process and making a thread took me much less time than finding out that I cannot login to Sun.
12 years ago
Two questions, really. What is the correct procedure to reopen bug case at Sun Developer Network?

Sure, I could ask there, but I just cannot login. If after two minutes of suffering I don't get 500 and I'm actually logged in, I cannot even start new thread. Has anyone succeeded in that?

This is the bug in question: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7022766
12 years ago