Giter VIP home page Giter VIP logo

Comments (5)

cyrille-artho avatar cyrille-artho commented on July 25, 2024 1

ClassInfo classInfo = env.getClassInfo(cRef); Class<?> c = Class.forName(classInfo.getName());

Thanks for asking. This would get the information about class ClassInfo, not the class that you're actually looking for. Instead, return the modifiers from classInfo itself:
return classInfo.getModifiers();

from jpf-core.

cyrille-artho avatar cyrille-artho commented on July 25, 2024

As far as I can tell, JPF currently does not search inner classes (perhaps it should), so we can probably get away with delegating this to Class.getModifiers().
The native peer for that method is public int getModifiers____I (MJIEnv env, int clsRef).

from jpf-core.

gayanW avatar gayanW commented on July 25, 2024

When you say 'search' did you mean the resolving of the classes?. If so, I could confirm that it resolves not just the superclasses and interfaces of a requested class but also its static inner classes (eg: java.lang.String$CaseInsensitiveComparator), and nested interfaces (eg: java.lang.Thread$UncaughtExceptionHandler)

from jpf-core.

gayanW avatar gayanW commented on July 25, 2024

Reflection#getClassAccessFlags(java.lang.Class) is only called about twice for entire test units. I think it is safe to say that the native int getClassAccessFlags(Class<?> c) is never called with an inner class as the argument c, while running the tests.

I've tried the following implementation:

  /**
   * NativePeer method for {@link jdk.internal.reflect.Reflection#getClassAccessFlags(java.lang.Class)}
   */
  @MJI
  public static int getClassAccessFlags__Ljava_lang_Class_2__I(MJIEnv env, int clsObjRef, int cRef) {
    try {
      ClassInfo classInfo = env.getClassInfo(cRef);
      Class<?> c = Class.forName(classInfo.getName());
      return c.getModifiers();

    } catch (ClassNotFoundException e) {
      return MJIEnv.NULL;
    }
  }

But I'm not quite sure about the following code snippet:

  ClassInfo classInfo = env.getClassInfo(cRef);
  Class<?> c = Class.forName(classInfo.getName());

Is this the correct approach to retrieve a Class object associated with given class reference (int cRef)?

from jpf-core.

cyrille-artho avatar cyrille-artho commented on July 25, 2024

Yes, I meant the mechanism of searching super classes/interfaces for methods that cannot be found in the current class.

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.