From: Jantien S. <jan...@gx...> - 2007-09-24 07:42:19
|
Hi, =20 Currently I'm looking at the possibility of using Java PathFinder for a research project. I'm testing to run the main class in JPF and some other functions in the host JVM by creating a Model class and a NavtivePeer class. Both classes are printed below, as is the JPF output. When I try to run them in JPF, I get an IllegalAccessException. For some reason, the Model class can't find the functions defined in the NativePeer class. Is there something I forgot to do in order to let the model class see the NativePeer class? I hope you can help me with my problem. =20 Kind regards, Jantien Sessink =20 =20 -----------------------Model class------------------------------------------------------ package nl.gx.firsthop; =20 public class Test { =20 public static void main(String[] args) { Integer test =3D 0; System.out.println("test =3D " + test.toString()); =20 test =3D increase(test, 10); System.out.println("test =3D " + test.toString()); =20 test =3D decrease(test, 10); System.out.println("test =3D " + test.toString()); } =20 native static int increase(Integer t, int increase); =20 native static int decrease(Integer t, int decrease); } ------------------------------------------------------------------------ ---------------- =20 -----------------------NativePeer class------------------------------------------------- package nl.gx.firsthop; =20 import gov.nasa.jpf.jvm.MJIEnv; =20 class JPF_nl_gx_firsthop_Test { =20 public static int increase (MJIEnv env, int rcls, int rInteger0, int v1) { System.out.println("Increasing test....."); for(int i =3D 0; i < v1; i++){ rInteger0++; } return rInteger0; } =20 public static int decrease (MJIEnv env, int rcls, int rInteger0, int v1) { System.out.println("Decreasing test....."); for(int i =3D 0; i < v1; i++){ rInteger0--; } return rInteger0; } =20 } ------------------------------------------------------------------------ ---------------- =20 -----------------------JPF output------------------------------------------------------- JavaPathfinder v4.1 - (C) 1999-2007 RIACS/NASA Ames Research Center =20 =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D system under test application: nl.gx.firsthop.Test.class =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D search started: 9/24/07 8:54 AM test =3D 0 =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D error #1 gov.nasa.jpf.jvm.NoUncaughtExceptionsProperty java.lang.IllegalAccessException: calling nl.gx.firsthop.Test.increase at nl.gx.firsthop.Test.increase(Native Method) at nl.gx.firsthop.Test.main(Test.java:9) =20 =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D trace #1 ------------------------------------------------------ transition #0 thread: 0 gov.nasa.jpf.jvm.choice.ThreadChoiceFromSet {>main} =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D snapshot #1 no live threads =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D results error #1: gov.nasa.jpf.jvm.NoUncaughtExceptionsProperty "java.lang.IllegalAccessException: calling nl.gx.fi..." =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D search finished: 9/24/07 8:54 AM ------------------------------------------------------------------------ ---------------- |
From: Flavio L. <fl...@gm...> - 2007-09-24 14:16:32
|
Hi Jantien, I think the problem is that the class is defined with default visibility. If you add "public" to the definition of your peer class things might work. -Flavio On 9/24/07, Jantien Sessink <jan...@gx...> wrote: > > > > > Hi, > > > > Currently I'm looking at the possibility of using Java PathFinder for a > research project. I'm testing to run the main class in JPF and some other > functions in the host JVM by creating a Model class and a NavtivePeer class. > Both classes are printed below, as is the JPF output. When I try to run them > in JPF, I get an IllegalAccessException. For some reason, the Model class > can't find the functions defined in the NativePeer class. Is there something > I forgot to do in order to let the model class see the NativePeer class? > > I hope you can help me with my problem. > > > > Kind regards, > > Jantien Sessink > > > > > > -----------------------Model > class------------------------------------------------------ > > package nl.gx.firsthop; > > > > public class Test { > > > > public static void main(String[] args) { > > Integer test = 0; > > System.out.println("test = " + test.toString()); > > > > test = increase(test, 10); > > System.out.println("test = " + test.toString()); > > > > test = decrease(test, 10); > > System.out.println("test = " + test.toString()); > > } > > > > native static int increase(Integer t, int increase); > > > > native static int decrease(Integer t, int decrease); > > } > > ---------------------------------------------------------------------------------------- > > > > -----------------------NativePeer > class------------------------------------------------- > > package nl.gx.firsthop; > > > > import gov.nasa.jpf.jvm.MJIEnv; > > > > class JPF_nl_gx_firsthop_Test { > > > > public static int increase (MJIEnv env, int rcls, int rInteger0, int > v1) { > > System.out.println("Increasing test....."); > > for(int i = 0; i < v1; i++){ > > rInteger0++; > > } > > return rInteger0; > > } > > > > public static int decrease (MJIEnv env, int rcls, int rInteger0, int > v1) { > > System.out.println("Decreasing test....."); > > for(int i = 0; i < v1; i++){ > > rInteger0--; > > } > > return rInteger0; > > } > > > > } > > ---------------------------------------------------------------------------------------- > > > > -----------------------JPF > output------------------------------------------------------- > > JavaPathfinder v4.1 - (C) 1999-2007 RIACS/NASA Ames Research Center > > > > > > ====================================================== > system under test > > application: nl.gx.firsthop.Test.class > > > > ====================================================== > search started: 9/24/07 8:54 AM > > test = 0 > > > > ====================================================== > error #1 > > gov.nasa.jpf.jvm.NoUncaughtExceptionsProperty > > java.lang.IllegalAccessException: calling > nl.gx.firsthop.Test.increase > > at nl.gx.firsthop.Test.increase(Native Method) > > at nl.gx.firsthop.Test.main(Test.java:9) > > > > > > ====================================================== > trace #1 > > ------------------------------------------------------ > transition #0 thread: 0 > > gov.nasa.jpf.jvm.choice.ThreadChoiceFromSet {>main} > > > > ====================================================== > snapshot #1 > > no live threads > > > > ====================================================== > results > > error #1: gov.nasa.jpf.jvm.NoUncaughtExceptionsProperty > "java.lang.IllegalAccessException: calling nl.gx.fi..." > > > > ====================================================== > search finished: 9/24/07 8:54 AM > > ---------------------------------------------------------------------------------------- > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Javapathfinder-user mailing list > Jav...@li... > https://lists.sourceforge.net/lists/listinfo/javapathfinder-user > > -- Google Talk: fl...@gm... MSN Messenger: fl...@gm... Skype: flerda |
From: Peter C. M. <pcm...@em...> - 2007-09-24 18:02:38
|
JPF uses normal Java reflection to call the NativePeer methods, so =20 the NativePeer has to be a public class, and the native methods have =20 to be "public static..". Please also note that you need to mange the =20 name (parameter/return type) if you have overloaded native methods. =20 The name mangling follows JNI and is documented on the web site -- Peter On Sep 24, 2007, at 12:42 AM, Jantien Sessink wrote: > Hi, > > Currently I'm looking at the possibility of using Java PathFinder =20 > for a research project. I=92m testing to run the main class in JPF =20 > and some other functions in the host JVM by creating a Model class =20 > and a NavtivePeer class. Both classes are printed below, as is the =20 > JPF output. When I try to run them in JPF, I get an =20 > IllegalAccessException. For some reason, the Model class can=92t find =20= > the functions defined in the NativePeer class. Is there something I =20= > forgot to do in order to let the model class see the NativePeer class? > > I hope you can help me with my problem. |