Giter VIP home page Giter VIP logo

Comments (5)

Harsh4902 avatar Harsh4902 commented on August 30, 2024

Update:

I have added some native peer methods in gov.nasa.jpf.vm.JPF_java_util_zip_ZipFile peer class so we can allow host JVM to handle methods of ZipFile class. By adding this, I got object of ZipEntry class. Now I am not getting NullPointerException, but I am not able to cast this ZipEntry object into JarEntry object. Here is the stack trace of error:

gov.nasa.jpf.vm.NoUncaughtExceptionsProperty
java.lang.ClassCastException: java.util.zip.ZipEntry cannot be cast to java.util.jar.JarEntry
	at java.util.zip.ZipFile$1.getEntry(ZipFile.java:161)
	at java.util.jar.JarFile.getEntry0(JarFile.java:584)
	at java.util.jar.JarFile.getManEntry(JarFile.java:946)
	at java.util.jar.JarFile.getManifestFromReference(JarFile.java:416)
	at java.util.jar.JarFile.getManifest(JarFile.java:408)
	at com.example.JarReader.main(JarReader.java:24)

from jpf-core.

cyrille-artho avatar cyrille-artho commented on August 30, 2024

I think the object should be returned as an instance of JarEntry rather than ZipEntry, so the cast to the subclass (JarEntry) succeeds.

from jpf-core.

Harsh4902 avatar Harsh4902 commented on August 30, 2024

Update:

I have added some native peer methods in gov.nasa.jpf.vm.JPF_java_util_zip_ZipFile peer class so we can allow host JVM to handle methods of ZipFile class. By adding this, I got object of ZipEntry class. Now I am not getting NullPointerException, but I am not able to cast this ZipEntry object into JarEntry object. Here is the stack trace of error:

gov.nasa.jpf.vm.NoUncaughtExceptionsProperty
java.lang.ClassCastException: java.util.zip.ZipEntry cannot be cast to java.util.jar.JarEntry
	at java.util.zip.ZipFile$1.getEntry(ZipFile.java:161)
	at java.util.jar.JarFile.getEntry0(JarFile.java:584)
	at java.util.jar.JarFile.getManEntry(JarFile.java:946)
	at java.util.jar.JarFile.getManifestFromReference(JarFile.java:416)
	at java.util.jar.JarFile.getManifest(JarFile.java:408)
	at com.example.JarReader.main(JarReader.java:24)

@pparizek @cyrille-artho I found a reason for this error.
Please look at this implementation of native peer for getEntry method of ZipFile class:

@MJI
  public int getEntry__Ljava_lang_String_2Ljava_util_function_Function_2__Ljava_util_zip_ZipEntry_2(MJIEnv env, int thisRef, int entryNameRef, int funcRef) {
    ZipFileProxy zfp = getZFP(env, thisRef);
    if (zfp == null) {
      return MJIEnv.NULL;
    }
    String name = env.getStringObject(entryNameRef);
    ZipEntry entry = zfp.zf.getEntry(name);
    if (entry == null) {
      return MJIEnv.NULL;
    }

    return createZipEntryObject(env, entry);

in this method I am calling getEntry(String) which will return object of ZipEntry but I have to call getEntry(String,Function) so we can get object of any class which is extending ZipEntry based on a function we are passing and due to this we were getting ClassCastException.

from jpf-core.

Harsh4902 avatar Harsh4902 commented on August 30, 2024

Now my question is, can we somehow get the object of the Function class from the funcRef variable?

from jpf-core.

cyrille-artho avatar cyrille-artho commented on August 30, 2024

There are ways to get the application-level objects that correspond to the descriptors (int values) at the JPF-native level. See JPF_java_lang_reflect_Constructor.getMethodInfo. However, it looks like you want to call the function instead? Would code such as the one in class JPF_gov_nasa_jpf_SerializationConstructor.java, method newInstance___3Ljava_lang_Object_2__Ljava_lang_Object_2 work for you (if you adapt it to your circumstance; in that method, a coonstructor is called, so a call on an existing instance is a bit different).

from jpf-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.