gianluca
unread,Nov 7, 2009, 10:07:01 AM11/7/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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