not sure I'm compiling correctly

6 views
Skip to first unread message

gianluca

unread,
Nov 7, 2009, 10:07:01 AM11/7/09
to multiverse
Hi all,

I wrote the class below to try out Multiverse:
---------------------------------------------------------------------------------------
package unsafe;

import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.multiverse.api.annotations.*;

@AtomicObject
public class Unsafe {

int value=0;
Random r=new Random(System.currentTimeMillis());

public void setValue(int i){value=i;}
public int getValue(){return value;}

public void inc(){
int tmp=getValue();
try {Thread.sleep(r.nextInt() % 50+50);} catch
(InterruptedException ex) {}
setValue(tmp+1);
}

class Changer extends Thread{
public void run(){
for (int i = 0; i < 100; i++) {
inc();
}
}
}

public Unsafe(){
Changer c1=new Changer();
Changer c2=new Changer();
c1.start();
c2.start();
try {
c1.join();
} catch (InterruptedException ex) {ex.printStackTrace();}
try {
c2.join();
} catch (InterruptedException ex) {ex.printStackTrace();}

System.out.println(getValue());

}

public static void main(String[] args) {
new Unsafe();
}
}
---------------------------------------------------------------------------------------
I'm compiling the code with
javac -cp multiverse-0.3.jar unsafe\*.java

and I trying to execute by launching
java -javaagent:multiverse-0.3.jar -cp . unsafe.Unsafe

but the Java Agent throws an exception and terminates the execution.
First 3 lines of output are:

> Starting the Multiverse JavaAgent
> STM integrity compromised, instrumentation problems encountered
> Failed while instrumenting class: unsafe/Unsafe in transformer: TranslocalFactory

The rest is a lot of ClassNotFoundException about classes which I
guess should be generated in compilation (for example
Unsafe__Tranlocal).

Can anyone point me in the right direction? I read the instructions
for compilation/execution on the project Wiki, but the jar names don't
match with what I see in the downloaded zip; I have no alphaagent.jar
or boot.jar, but instead multiverse-0.3.jar and multiverse-
noasm-0.3.jar (I downloaded the latest snapshot, 298).

thanks,
Gianluca


peter veentjer

unread,
Nov 9, 2009, 2:46:53 AM11/9/09
to multiverse
Hi Gianlucca,

the cause of the problem is that the wiki is out of data and that you
are using the old binaries (as we discussed on Skype). I'll try to
update the wiki and get you up and running today.

gianluca

unread,
Nov 9, 2009, 4:11:30 PM11/9/09
to multiverse
Hi Peter,

I had a look at the updated wiki and I'm now able to run my example.
Thanks for making the jar more easily accessible :)

Gianluca

Peter Veentjer

unread,
Nov 9, 2009, 4:17:08 PM11/9/09
to googlemu...@googlegroups.com
Cool :)

Keep me posted about other issues, and if you need any help you know
where to find it
Reply all
Reply to author
Forward
0 new messages