Menu

#69 Field.set() throws an exception when setting a static long

open
nobody
5
2017-10-01
2009-09-16
No

*** platform ***
JPF svn revision: 1849
Java version: java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)

*** input program ***
import java.lang.reflect.*;
public class ReflectionSet {
private static long ff;
public static void main(String[] args) throws Exception {
ReflectionSet test=new ReflectionSet();
Field field=ReflectionSet.class.getDeclaredFields()[0];
field.set(test,3);
}
}

*** jpf output ***
[SEVERE] JPF exception, terminating: exception in native method java.lang.reflect.Field.set
java.lang.ArrayIndexOutOfBoundsException: 1
at gov.nasa.jpf.jvm.Fields.getLongValue(Fields.java:164)
at gov.nasa.jpf.jvm.ElementInfo.getLongField(ElementInfo.java:537)
at gov.nasa.jpf.jvm.MJIEnv.getLongField(MJIEnv.java:344)
at gov.nasa.jpf.jvm.JPF_java_lang_reflect_Field.setValue(JPF_java_lang_reflect_Field.java:428)
at gov.nasa.jpf.jvm.JPF_java_lang_reflect_Field.set__Ljava_lang_Object_2Ljava_lang_Object_2__V(JPF_java_lang_reflect_Field.java:392)
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)
...

*** java output ***
-

Discussion

  • Milos Gligoric

    Milos Gligoric - 2009-09-16

    JPF and JVM give different results for the attached program

     
  • Anunay kant

    Anunay kant - 2017-10-01

    milos,

    jpf still havent developed low mechanism abstractions ,some methods that use the native librarires will be ignored by jpf the field.set function uses the same native library abstraction .thus every block of code that uses these will give JPF Exception as in this case Illegal Argument Exception .
    please go through this

    https://babelfish.arc.nasa.gov/trac/jpf/wiki/devel/mji#no1

    I hope this helped you.

     

Log in to post a comment.

MongoDB Logo MongoDB