making JPF_java_io_Reader

21 views
Skip to first unread message

Alvaro Silvera

unread,
Mar 1, 2012, 9:11:47 AM3/1/12
to java-pa...@googlegroups.com
inside our SUT we use the net.n3.nanoxml to parse xml.

this library use the int BufferedReader::read() method declared in the
int Reader::read() superclass.

I am using the native peer BufferedReader of net-iocache and the
BufferedReader::readLine() works fine but it doesn't have the read()
method.

Because it didn't leave me add the method in the
JPF_java_io_BufferedReader class (it mentioned something about an
orphan method) I created my own native peer JPF_java_io_Reader.

When running the test it shows an exception. Researching the code it
doesn't seem that I have referenced the object in the heap and think
that it has to do with the fact that is a superclass's method.

Someone had this kind of issue before?

Someone has any suggestion about how to solve this?


On the other side, once the peer will be finished and working I would
like to commit it to be available for the community but the link on
http://babelfish.arc.nasa.gov/trac/jpf/wiki/about/contribute is broken
Where can I find the contribution section?


copy and paste the peer and the exception as reference:

public class JPF_java_io_Reader {

public static int read____I(MJIEnv env, int robj) throws IOException {
byte[] buff = new byte[1];
int id = env.getIntField(robj, "id");

int num = CacheLayer.getInstance().read(id, buff);

return num > 0 ? buff[0] : -1;

}
}


java.lang.NullPointerException
at gov.nasa.jpf.jvm.ElementInfo.getIntField(ElementInfo.java:1045)
at gov.nasa.jpf.jvm.MJIEnv.getIntField(MJIEnv.java:456)
at gov.nasa.jpf.jvm.JPF_java_io_Reader.read____I(JPF_java_io_Reader.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at gov.nasa.jpf.jvm.NativeMethodInfo.executeNative(NativeMethodInfo.java:147)
at gov.nasa.jpf.jvm.bytecode.EXECUTENATIVE.execute(EXECUTENATIVE.java:71)
at gov.nasa.jpf.jvm.ThreadInfo.executeInstruction(ThreadInfo.java:2217)
at gov.nasa.jpf.jvm.ThreadInfo.executeTransition(ThreadInfo.java:2170)
at gov.nasa.jpf.jvm.SystemState.executeNextTransition(SystemState.java:712)
at gov.nasa.jpf.jvm.JVM.forward(JVM.java:1759)
at gov.nasa.jpf.search.Search.forward(Search.java:533)
at gov.nasa.jpf.search.DFSearch.search(DFSearch.java:78)
at gov.nasa.jpf.JPF.run(JPF.java:566)
at gov.nasa.jpf.JPF.start(JPF.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at gov.nasa.jpf.tool.Run.call(Run.java:76)
at gov.nasa.jpf.tool.RunJPF.main(RunJPF.java:99)
---------------------- JPF error stack trace ---------------------
gov.nasa.jpf.JPFNativePeerException: exception in native method
java.io.Reader.read
at gov.nasa.jpf.jvm.NativeMethodInfo.executeNative(NativeMethodInfo.java:198)
at gov.nasa.jpf.jvm.bytecode.EXECUTENATIVE.execute(EXECUTENATIVE.java:71)
[SEVERE] JPF exception, terminating: exception in native method
java.io.Reader.read
at gov.nasa.jpf.jvm.ThreadInfo.executeInstruction(ThreadInfo.java:2217)
at gov.nasa.jpf.jvm.ThreadInfo.executeTransition(ThreadInfo.java:2170)
at gov.nasa.jpf.jvm.SystemState.executeNextTransition(SystemState.java:712)
at gov.nasa.jpf.jvm.JVM.forward(JVM.java:1759)
at gov.nasa.jpf.search.Search.forward(Search.java:533)
at gov.nasa.jpf.search.DFSearch.search(DFSearch.java:78)
at gov.nasa.jpf.JPF.run(JPF.java:566)
at gov.nasa.jpf.JPF.start(JPF.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at gov.nasa.jpf.tool.Run.call(Run.java:76)
at gov.nasa.jpf.tool.RunJPF.main(RunJPF.java:99)
Caused by: java.lang.NullPointerException
at gov.nasa.jpf.jvm.ElementInfo.getIntField(ElementInfo.java:1045)
at gov.nasa.jpf.jvm.MJIEnv.getIntField(MJIEnv.java:456)
at gov.nasa.jpf.jvm.JPF_java_io_Reader.read____I(JPF_java_io_Reader.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at gov.nasa.jpf.jvm.NativeMethodInfo.executeNative(NativeMethodInfo.java:147)
... 15 more

Peter Mehlitz

unread,
Mar 1, 2012, 12:57:40 PM3/1/12
to java-pa...@googlegroups.com
apparently, your peer uses a wrong or stale reference value. Keep in mind these might change between different paths, i.e. reference values are not search global and you can't just store them as such in your peers/listeners.

Reg. the contribution, it depends what it is you contribute:

* smaller, one time bug fixes are best done through sending patches, either to the mailing list (if they are small) or directly to me

* if you have frequent ones, then it is better to have your own Mercurial clone of the respective project and give its maintainer access to it so that we can diff/merge

* if you have your own project, you can either do this on a different host (e.g. bitbucket.org or code.google.com) and send us some description we can add to the "external projects" page on the wiki, or you could - if this is of general interest and a long term maintained project - apply for an account on babelfish and we add a repo there. In this case, you would have to use NOSA as the license and you have to do some legal paperwork though

Thanks, for pointing this out, I will add this to the missing contribution page on the wiki

-- Peter

Alvaro Silvera

unread,
Mar 1, 2012, 1:41:44 PM3/1/12
to java-pa...@googlegroups.com
Please, notice that the error is in this part --> int id =
env.getIntField(robj, "id");

I understand that is jpf the one in charge of administrate the
references between the native peers and the model layer objects. So,
beyond of what the peer does, the excepton is why it can't find that
reference in its map.

I wonder if the error is caused by the instance that I am using in the
model layer is a sub class of Reader (BufferedReader )
There are some native peers set (working) formed by superclass + subclass?

Thanks for your answer
Alvaro

Reply all
Reply to author
Forward
0 new messages